XLE
v0.02.0
|
Represents a chunk of compiled shader code More...
#include <ShaderService.h>
Public Member Functions | |
std::pair< const void *, size_t > | GetByteCode () const |
::Assets::AssetState | TryGetByteCode (void const *&byteCode, size_t &size) |
::Assets::AssetState | StallWhilePending () const |
ShaderStage::Enum | GetStage () const |
bool | DynamicLinkingEnabled () const |
std::shared_ptr< std::vector< uint8 > > | GetErrors () const |
CompiledShaderByteCode (const ::Assets::ResChar initializer[], const ::Assets::ResChar definesTable[]=nullptr) | |
CompiledShaderByteCode (const char shaderInMemory[], const char entryPoint[], const char shaderModel[], const ::Assets::ResChar definesTable[]=nullptr) | |
CompiledShaderByteCode (std::shared_ptr<::Assets::PendingCompileMarker > &&marker) | |
CompiledShaderByteCode (const CompiledShaderByteCode &)=delete | |
CompiledShaderByteCode & | operator= (const CompiledShaderByteCode &)=delete |
CompiledShaderByteCode (CompiledShaderByteCode &&) | |
CompiledShaderByteCode & | operator= (CompiledShaderByteCode &&) |
auto | GetDependencyValidation () const -> const std::shared_ptr<::Assets::DependencyValidation > & |
const char * | Initializer () const |
Static Public Attributes | |
static const uint64 | CompileProcessType = ConstHash64<'Shad', 'erCo', 'mpil', 'e'>::Value |
Represents a chunk of compiled shader code
Typically we construct CompiledShaderByteCode with either a reference to a file or a string containing high-level shader code.
When loading a shader from a file, there is a special syntax for the "initializer":
For example:
This will load the file shaders/basic.psh, and look for the entry point MainFunction. The shader will be compiled with pixel shader 5.0 shader model.
Most clients will want to use the default shader model for a given stage. To use the default shader model, use ":ps_*". This will always use a shader model that is valid for the current hardware. Normally use of an explicit shader model is only required when pre-compiling many shaders for the final game image.
The constructor will invoke background compile operations. The resulting compiled byte code can be accessed using GetByteCode() However, GetByteCode can throw exceptions (such as Assets::Exceptions::PendingAsset and Assets::Exceptions::InvalidAsset). If the background compile operation has not completed yet, a PendingAsset exception will be thrown.
Alternatively, use TryGetByteCode() to return an error code instead of throwing an exception. But note that TryGetByteCode() can still throw exceptions – but only in unusual situations (such as programming errors or hardware faults)