BsD3D11HLSLParamParser.h 1.9 KB

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