#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_HLSLSHADERREFLECTOR_H #define NUCLEX_GRAPHICS_INTROSPECTION_HLSLSHADERREFLECTOR_H #include "Nuclex/Graphics/Config.h" #include "Nuclex/Graphics/Introspection/ShaderMetadata.h" #include "MiniReader.h" #include #include namespace Nuclex { namespace Graphics { namespace Introspection { // ------------------------------------------------------------------------------------------- // /// Extracts the input layout from a compiled HLSL shader (*.cbo) /// /// 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 HlslShaderReflector { /// Checks whether the provided byte code is from an HLSL shader /// Address at which the compiled shader code is stored /// Length of the compiled shader code in bytes /// True if the specified byte code contains a compiled HLSL shader public: static bool IsHlslShader(const std::uint8_t *bytecode, std::size_t length); /// Parses the compiled shader bytecode /// Address at which the compiled shader code is stored /// Length of the compiled shader code in bytes /// /// Receives the metadata describing the shader's inputs and constants /// public: static void Read( const std::uint8_t *bytecode, std::size_t length, ShaderMetadata &metadata ); /// Parses a chunk of data in the compiled shader bytecode /// Reader through which the data chunk will be read /// Metadata container that will be filled private: static void readChunk(MiniReader &reader, ShaderMetadata &metadata); }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Introspection #endif // NUCLEX_GRAPHICS_INTROSPECTION_HLSLSHADERREFLECTOR_H