BsD3D11HLSLParamParser.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "BsD3D11Prerequisites.h"
  3. #include "BsVertexDeclaration.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Handles parsing of GPU program microcode and extracting constant and input parameter data.
  8. */
  9. class D3D11HLSLParamParser
  10. {
  11. public:
  12. /**
  13. * @brief Parses the provided microcode and outputs constant parameter descriptions, and optionally for
  14. * vertex GPU programs a set of input parameters.
  15. *
  16. * @param microcode Compiled GPU program microcode to parse.
  17. * @param desc Output object that will contain parameter descriptions.
  18. * @param inputParams Output object that will contain a set of program input parameters. Can be null if not required.
  19. * Only relevant for vertex programs.
  20. */
  21. void parse(ID3DBlob* microcode, GpuParamDesc& desc, List<VertexElement>* inputParams);
  22. private:
  23. /**
  24. * @brief Parses the provided constant buffer retrieving information about all of its members and storing
  25. * them in the provided GPU params description object.
  26. */
  27. void parseBuffer(ID3D11ShaderReflectionConstantBuffer* bufferReflection, GpuParamDesc& desc);
  28. /**
  29. * @brief Parses the resource description structure and stores it in the provided GPU params description object.
  30. */
  31. void parseResource(D3D11_SHADER_INPUT_BIND_DESC& resourceDesc, GpuParamDesc& desc);
  32. /**
  33. * @brief Parses a variable with the specified type and variable description. Adds the variable in the provided
  34. * GPU params description object and assigns it to the provided param block.
  35. */
  36. void parseVariable(D3D11_SHADER_TYPE_DESC& varTypeDesc, D3D11_SHADER_VARIABLE_DESC& varDesc, GpuParamDesc& desc, GpuParamBlockDesc& paramBlock);
  37. };
  38. }