MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / GetBoundResources

Method GetBoundResources

GTE/Graphics/DX11/HLSLShaderFactory.cpp:345–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345bool HLSLShaderFactory::GetBoundResources(ID3DShaderReflection* reflector, HLSLReflection& shader)
346{
347 // TODO: It appears that D3DCompile never produces a resource with a bind
348 // count larger than 1. For example, "Texture2D texture[2];" comes
349 // through with names "texture[0]" and "texture[1]", each having a bind
350 // count of 1 (with consecutive bind points). So it appears that passing
351 // a bind count in D3D interfaces that is larger than 1 is something a
352 // programmer can do only if he manually combines the texture resources
353 // into his own data structure. If the statement about D3DCompiler is
354 // true, we do not need the loops with upper bound resDesc.BindCount.
355
356 UINT const numResources = shader.GetDescription().numBoundResources;
357 for (UINT i = 0; i < numResources; ++i)
358 {
359 D3D_SHADER_INPUT_BIND_DESC resDesc;
360 DX11Log(reflector->GetResourceBindingDesc(i, &resDesc));
361
362 if (resDesc.Type == D3D_SIT_CBUFFER // cbuffer
363 || resDesc.Type == D3D_SIT_TBUFFER) // tbuffer
364 {
365 // These were processed in the previous loop.
366 }
367 else if (
368 resDesc.Type == D3D_SIT_TEXTURE // Texture*
369 || resDesc.Type == D3D_SIT_UAV_RWTYPED) // RWTexture*
370 {
371 if (IsTextureArray(resDesc.Dimension))
372 {
373 if (resDesc.BindCount == 1)
374 {
375 shader.Insert(HLSLTextureArray(resDesc));
376 }
377 else
378 {
379 for (UINT j = 0; j < resDesc.BindCount; ++j)
380 {
381 shader.Insert(HLSLTextureArray(resDesc, j));
382 }
383 }
384 }
385 else
386 {
387 if (resDesc.BindCount == 1)
388 {
389 shader.Insert(HLSLTexture(resDesc));
390 }
391 else
392 {
393 for (UINT j = 0; j < resDesc.BindCount; ++j)
394 {
395 shader.Insert(HLSLTexture(resDesc, j));
396 }
397 }
398 }
399 }
400 else if (resDesc.Type == D3D_SIT_SAMPLER) // SamplerState
401 {
402 if (resDesc.BindCount == 1)

Callers

nothing calls this directly

Calls 7

HLSLTextureArrayClass · 0.85
HLSLTextureClass · 0.85
HLSLSamplerStateClass · 0.85
GetDescriptionMethod · 0.80
InsertMethod · 0.45

Tested by

no test coverage detected