BsD3D11HLSLParamParser.h 1.9 KB

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