#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_GRAPHICS_INTROSPECTION_HLSLRESOURCEDEFINITIONSERIALIZER_H #define NUCLEX_GRAPHICS_INTROSPECTION_HLSLRESOURCEDEFINITIONSERIALIZER_H #include "Nuclex/Graphics/Config.h" #include "Nuclex/Graphics/Introspection/ShaderMetadata.h" #include "MiniReader.h" #include #include namespace Nuclex { namespace Graphics { namespace Introspection { // ------------------------------------------------------------------------------------------- // /// Reads the resource definition chunk from a compiled HLSL shader /// /// This could also be achieved via D3DReflect(), but that method requires an extra DLL /// (d3dcompiler_xx.dll) to be shipped and is not available to WinRT / Metro games. /// Doing it by hand is just a little bit more complicated and lets us obtain this /// information in a platform independent manner. /// class HlslResourceDefinitionSerializer { /// Parses a resource definition in the compiled shader bytecode /// /// Reader positioned at the start of the resource definition chunk /// /// /// Metadata structure in which the resource definition will be stored /// public: static void Read(const MiniReader &reader, ShaderMetadata &metadata); /// Reads metadata for a constant buffer from the resource definition /// Reader positioned at the chunk start /// /// Reader through which the constant buffer metadata will be read /// /// /// Constant buffer metadata structure that will be filled /// private: static void readConstantBuffer( const MiniReader &reader, MiniReader &constantBufferReader, ConstantBufferMetadata &constantBufferMetadata ); /// Reads metadata for a variable stored in a constant buffer /// Reader positioned at the chunk start /// /// Reader through which the metadata for the variable will be read /// /// Metadata structure that will be filled private: static void readConstantBufferVariable( const MiniReader &reader, MiniReader &variableReader, ConstantMetadata &constantMetadata ); /// Reads metadata for the type of a constant /// Reader positioned at the chunk start /// Reader through which the variable type will be read /// Metadata structure that will be filled private: static void readConstantBufferVariableType( const MiniReader &reader, MiniReader &typeReader, ConstantMetadata &constantMetadata ); /// Parses resources consumed by a shader /// Reader positioned at the chunk start /// /// Reader through which the resource metadata will be read /// /// Metadata structure that will be filled private: static void readResourceBinding( const MiniReader &reader, MiniReader &resourceBindingReader, ResourceMetadata &resourceMetadata ); }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Introspection #endif // NUCLEX_GRAPHICS_INTROSPECTION_HLSLRESOURCEDEFINITIONSERIALIZER_H