4

I have total 9 texture resources among them I need 2 resources together for a pixel shader. In that case what should be the texture slot start index if I need the 7th and 8th texture resources only. (e.g. Texture2D foo1 : register(t7) and Texture2D foo2 : register(t8))

void PSSetShaderResources(
   UINT                     StartSlot,
   UINT                     NumViews,
   ID3D11ShaderResourceView * const *ppShaderResourceViews
);

EDIT: I have a wrapper class for managing shaders where I am dealing with multiple resources like below:

ID3D11DeviceContextPtr context = renderer->Context();
std::vector<ID3D11ShaderResourceView*> srvs;

    for(auto texture : m_textures)
    {
        srvs.push_back(texture->ShaderResourceView());
    }
    context->PSSetShaderResources(m_startSlot, srvs.size(), srvs.data());
  • Unless you need to use all 8 textures in a single shader in one rendering, you don't and shouldn't be binding more than a few at any one time. You should just be using slot 0 and for the dual-texture case, slot 0 & 1. – Chuck Walbourn Jan 10 '19 at 22:47
  • So, If I need 7th and 8th then StartSlot should be 7 and for two textures NumVIews should be 2. Is that right? – Tajuddin Khandaker Jan 15 '19 at 10:41
  • I am not sure if you can do that. But you can definitely use multiple calls to set your resource, e.g. ID3D11ShaderResourceView* textureArray[2]; context->PSSetShaderResources(0, 1, &textureArray[0]); context->PSSetShaderResources(1, 1, &textureArray[1]); startSlot indicates the slot number of device, not the array index of shader resource view. – Liton Jan 15 '19 at 14:36
  • Is there some reason you can't just use ``t0`` and ``t1`` in that shader? – Chuck Walbourn Jan 15 '19 at 19:27
  • No, those slots are already in use for other purpose - linear sampling. But Is it possible without doing multiple calls of PSSetShaderResources() ? Unless it's the only way to achieve the purpose. – Tajuddin Khandaker Jan 16 '19 at 04:57
  • I have used following sampler and texture array with other textures if I use start slot 7 debug layer suggests 8 and if I use 8 it suggests 7 as start slot. What should I do? // Texture and Sampler for video image mixer texture(s) Texture2D imageMixTexture[5] : register(t7); SamplerState imageMixSampler[5] : register(s7); // Texture and Sampler for UYVY converted video image texture Texture2D imageTexture : register(t8); SamplerState imageSampler : register(s8); – Tajuddin Khandaker Feb 14 '19 at 12:39
  • @Liton have found that you may provide a resource collection of textures at once and mention a start index from where to collect them from buffer it's provided. So I think start index is related to the collection index which will provided in PSSetShaderResources() – Tajuddin Khandaker Feb 18 '19 at 08:15

1 Answers1

0

I have found from this post that you may provide a resource collection of textures at once and mention a start index from where to collect them from buffer it's provided.