1#include "EffectsD3D11.h"
3#include "GraphicsDeviceD3D11.h"
5#include "../Base/Utilities.h"
7#include "Foundation/Logging/Logger.h"
9#include <D3Dcompiler.h>
20 void dumpSource(
const Cogs::ProcessedContent content,
int firstLine = 1,
int lastLine = std::numeric_limits<int>::max())
22 const char* start = content.content.data();
23 const char* curr = start;
26 while ((*curr !=
'\0') && (line <= lastLine)) {
28 while ((*p !=
'\0') && (*p !=
'\n') && (*p !=
'\r')) { p++; }
30 if (firstLine <= line) {
32 while ((source < content.sourceStop.size()) && (content.sourceStop[source] <
static_cast<size_t>(curr - start))) source++;
34 if (source < content.sourceStop.size()) {
35 LOG_DEBUG(logger,
"%3d(%s): %s", line, content.sourceName[source].c_str(), std::string(curr, p - curr).c_str());
37 LOG_DEBUG(logger,
"??: %3d: %s", line, std::string(curr, p - curr).c_str());
44 if (*curr !=
'\0') { curr++; };
45 if ((*curr !=
'\0') && (*curr != *p) && ((*curr ==
'\n') || (*curr ==
'\r'))) { curr++; }
51 const static std::regex outputPattern(
"^[^(]*\\((\\d+),(\\d+)\\-?(\\d*)\\): (\\S+) X(\\d+): (.+)$");
53 std::string compilerMessageLine;
54 std::string t(output);
55 std::stringstream stream(t);
58 while (stream.good()) {
59 std::getline(stream, compilerMessageLine);
61 if (std::regex_search(compilerMessageLine, results, outputPattern)) {
62 int line = std::stoi(results[1].str());
63 int col0 = std::stoi(results[2].str());
64 auto col1 = results[3].str().empty() ? col0 : std::stoi(results[3].str());
65 auto cat = results[4].str();
66 int code = std::stoi(results[5].str());
67 auto what = results[6].str();
70 dumpSource(content, 1, line);
73 dumpSource(content, line - 3, line);
77 else if (!compilerMessageLine.empty()) {
78 LOG_ERROR(logger,
"Failed to parse HLSL compiler output.");
88 void dumpSource(
const std::string & src,
const std::vector<D3D_SHADER_MACRO> & macros,
int firstLine = 1,
int lastLine = std::numeric_limits<int>::max())
91 for (
size_t i = 0; i < macros.size(); i++) {
92 LOG_DEBUG(logger,
"PPM: %s: %s", macros[i].Name, macros[i].Definition);
98 const char* curr = src.data();
100 while ((*curr !=
'\0') && (line <= lastLine)) {
101 const char* p = curr;
102 while ((*p !=
'\0') && (*p !=
'\n') && (*p !=
'\r')) { p++; }
104 if (firstLine <= line) {
105 LOG_DEBUG(logger,
"%3d: %s", line, std::string(curr, p - curr).c_str());
110 if (*curr !=
'\0') { curr++; };
111 if ((*curr !=
'\0') && (*curr != *p) && ((*curr ==
'\n') || (*curr ==
'\r'))) { curr++; }
115 void logCompilerOutput(
Cogs::Logging::Category category,
const std::string& src,
const std::vector<D3D_SHADER_MACRO> & macros,
const char* output)
117 const static std::regex outputPattern(
"^[^(]*\\((\\d+),(\\d+)\\-?(\\d*)\\): (\\S+) X(\\d+): (.+)$");
119 std::string compilerMessageLine;
120 std::string t(output);
121 std::stringstream stream(t);
124 while (stream.good()) {
125 std::getline(stream, compilerMessageLine);
127 if (std::regex_search(compilerMessageLine, results, outputPattern)) {
128 int line = std::stoi(results[1].str());
129 int col0 = std::stoi(results[2].str());
130 auto col1 = results[3].str().empty() ? col0 : std::stoi(results[3].str());
131 auto cat = results[4].str();
132 int code = std::stoi(results[5].str());
133 auto what = results[6].str();
135 dumpSource(src, macros, line - 3, line);
137 }
else if (!compilerMessageLine.empty()) {
138 LOG_ERROR(logger,
"Failed to parse HLSL compiler output.");
144#ifdef COGSRENDERING_GFX_ANNOTATE
145 template<
typename ShaderType>
148 if (shader.shader && !name.
empty()) {
149 shader.shader.get<ShaderType>()->SetPrivateData(WKPDID_D3DDebugObjectName,
static_cast<UINT
>(name.
length()), name.
data());
155void Cogs::EffectsD3D11::setDevice(GraphicsDeviceD3D11 * graphicsDevice,
const ResourcePointer<ID3D11Device> & device)
157 this->graphicsDevice = graphicsDevice;
158 this->device = device;
160 EffectsCommon::initialize(graphicsDevice->getBuffers());
165#ifdef COGSRENDERING_GFX_ANNOTATE
166 auto nameStr = std::string(name);
167 doAnnotate<ID3D11VertexShader>(effects[handle].vertexShader, nameStr +
"_VS");
168 doAnnotate<ID3D11GeometryShader>(effects[handle].geometryShader, nameStr +
"_GS");
169 doAnnotate<ID3D11PixelShader>(effects[handle].pixelShader, nameStr +
"_PS");
170 doAnnotate<ID3D11ComputeShader>(effects[handle].computeShader, nameStr +
"_CS");
179#ifdef COGSRENDERING_GFX_ANNOTATE
180 doAnnotate<ID3D11VertexShader>(effects[handle].vertexShader, name);
189#ifdef COGSRENDERING_GFX_ANNOTATE
190 doAnnotate<ID3D11GeometryShader>(effects[handle].geometryShader, name);
199#ifdef COGSRENDERING_GFX_ANNOTATE
200 doAnnotate<ID3D11PixelShader>(effects[handle].pixelShader, name);
209#ifdef COGSRENDERING_GFX_ANNOTATE
210 doAnnotate<ID3D11ComputeShader>(effects[handle].computeShader, name);
220 this->effects.removeResource(handle);
233 Utilities::preprocessFile(handler, fileName, csSourceProcessed);
239 std::vector<D3D_SHADER_MACRO> macros(defines.size() + 1);
241 for (
size_t i = 0; i < defines.size(); ++i) {
242 D3D_SHADER_MACRO macro = { defines[i].first.c_str(), defines[i].second.c_str() };
247 UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL0 | D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY | D3DCOMPILE_DEBUG | D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
249 UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL3 | D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY | D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
254 std::string cacheName;
257 if (useShaderCache) {
258 StringView sourceView(csSourceProcessed.content);
263 for (
const auto & macro : macros) {
264 if (macro.Definition) {
265 shaderId =
Cogs::hash(macro.Definition, shaderId);
270 cacheName = std::to_string(shaderId) +
"cs_5_0.shadercache";
272 if (handler->exists(IIOHandler::FileType::ShaderCache, cacheName)) {
273 static thread_local std::vector<uint8_t> shaderCache;
275 handler->openBinaryFile(IIOHandler::FileType::ShaderCache, cacheName, shaderCache);
277 uint32_t indices[1] = { 0 };
278 hr = D3DDecompressShaders(shaderCache.data(), shaderCache.size(), 1, 0, indices, 0, byteCode.internalPointer(),
nullptr);
280 LOG_ERROR(logger,
"Failed to decompress shader cache item %s: %s", cacheName.c_str(), direct3D11ReturnCodeAsString(hr));
284 LOG_TRACE(logger,
"Retrieved compute shader cache item %s", cacheName.c_str());
290 if (FAILED(hr = D3DCompile(csSourceProcessed.content.c_str(),
291 csSourceProcessed.content.size(),
292 (csSourceProcessed.origin.empty() ?
nullptr : csSourceProcessed.origin.c_str()),
295 "main",
"cs_5_0", flags, 0,
296 byteCode.internalPointer(), errorBlob.internalPointer())))
298 LOG_ERROR(logger,
"Failed to compile compute shader: %s", direct3D11ReturnCodeAsString(hr));
299 logCompilerOutput(Logging::Category::Error, csSourceProcessed,
static_cast<const char*
>(errorBlob->GetBufferPointer()), effectFlags);
301 }
else if (errorBlob) {
302 logCompilerOutput(Logging::Category::Warning, csSourceProcessed,
static_cast<const char*
>(errorBlob->GetBufferPointer()), effectFlags);
303 LOG_WARNING(logger,
static_cast<char*
>(errorBlob->GetBufferPointer()));
306 if (useShaderCache && shaderId) {
307 D3D_SHADER_DATA shaderData;
308 shaderData.pBytecode = byteCode->GetBufferPointer();
309 shaderData.BytecodeLength = byteCode->GetBufferSize();
312 hr = D3DCompressShaders(1, &shaderData, D3D_COMPRESS_SHADER_KEEP_ALL_PARTS, compressedShader.internalPointer());
314 LOG_WARNING(logger,
"Failed to compress shader cache item %s: %s", cacheName.c_str(), direct3D11ReturnCodeAsString(hr));
317 if (!handler->writeBinaryFile(IIOHandler::FileType::ShaderCache,
319 compressedShader->GetBufferPointer(),
320 compressedShader->GetBufferSize()))
322 LOG_WARNING(logger,
"Failed to store compute shader cache item %s", cacheName.c_str());
325 LOG_TRACE(logger,
"Stored compute shader cache item %s", cacheName.c_str());
331 if (FAILED(hr = device->CreateComputeShader(byteCode->GetBufferPointer(), byteCode->GetBufferSize(),
nullptr, (ID3D11ComputeShader **)&effect.computeShader.shader))) {
332 LOG_ERROR(logger,
"Failed to create compute shader: %s", direct3D11ReturnCodeAsString(hr));
335 effect.computeShader.byteCode = &*byteCode;
336 effect.computeShader.byteCode->AddRef();
339 reflectShader(effect.computeShader);
341#ifdef COGSRENDERING_GFX_ANNOTATE
342 doAnnotate<ID3D11ComputeShader>(effect.computeShader, tryToName(csSourceProcessed.origin));
345 LOG_TRACE(logger,
"Created compute shader %p", effect.computeShader.shader.get<
void>());
348 return this->effects.addResource(std::move(effect));
353 this->effects.clear();
370 std::vector<D3D_SHADER_MACRO> macros(desc.definitions.size() + 1);
372 for (
size_t i = 0; i < desc.definitions.size(); ++i) {
373 D3D_SHADER_MACRO macro = { desc.definitions[i].first.c_str(), desc.definitions[i].second.c_str() };
378 UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL0 | D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY | D3DCOMPILE_DEBUG | D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
380 UINT flags = D3DCOMPILE_OPTIMIZATION_LEVEL3 | D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY | D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
383 const char * profiles[ShaderType::NumShaderTypes] = {
"vs_5_0",
"hs_5_0",
"ds_5_0",
"gs_5_0",
"ps_5_0" };
384 const ProcessedContent * sources[ShaderType::NumShaderTypes] = { &vsSource, &hsSource, &dsSource, &gsSource, &psSource };
385 const StringView * entryPoints[ShaderType::NumShaderTypes] = {
392 ResourcePointer<ID3DBlob> byteCode[ShaderType::NumShaderTypes];
397 size_t shaderIds[ShaderType::NumShaderTypes];
400 for (
int i = 0; i < ShaderType::NumShaderTypes; i++) {
401 if (sources[i]->content.empty()) {
406 std::string cacheName;
408 if (useShaderCache) {
409 StringView sourceView(sources[i]->content);
415 for (
const auto & macro : macros) {
416 if (macro.Definition) {
417 shaderId =
Cogs::hash(macro.Definition, shaderId);
422 shaderIds[i] = shaderId;
424 cacheName = std::to_string(shaderId) + profiles[i] +
".shadercache";
426 if (handler->exists(IIOHandler::FileType::ShaderCache, cacheName)) {
427 static thread_local std::vector<uint8_t> shaderCache;
429 handler->openBinaryFile(IIOHandler::FileType::ShaderCache, cacheName, shaderCache);
431 uint32_t indices[1] = { 0 };
432 assert(byteCode[i] ==
nullptr &&
"Leaking memory");
433 hr = D3DDecompressShaders(shaderCache.data(), shaderCache.size(), 1, 0, indices, 0, byteCode[i].internalPointer(),
nullptr);
435 LOG_ERROR(logger,
"Failed to decompress shader cache item %s: %s", cacheName.c_str(), direct3D11ReturnCodeAsString(hr));
436 byteCode[i]->Release();
439 LOG_TRACE(logger,
"Retrieved shader cache item %s", cacheName.c_str());
445 if (dumpShaderContents && (desc.name.size() || shaderId)) {
446 auto dumpName = desc.name.empty() ? std::to_string(shaderId) + profiles[i] +
".hlsl" : std::string(desc.name) +
"." + profiles[i] +
".hlsl";
447 handler->writeBinaryFile(IIOHandler::FileType::ShaderDump, dumpName, sources[i]->content.data(), sources[i]->content.size());
450 if (FAILED(hr = D3DCompile(sources[i]->content.c_str(),
451 sources[i]->content.size(),
455 entryPoints[i]->data(),
457 flags, 0, byteCode[i].internalPointer(), errorBlob.internalPointer())))
459 LOG_ERROR(logger,
"Failed to compile %s shader: %s", profiles[i], direct3D11ReturnCodeAsString(hr));
460 logCompilerOutput(Logging::Category::Error, *sources[i],
static_cast<const char*
>(errorBlob->GetBufferPointer()), desc.flags);
462 }
else if (errorBlob) {
463 logCompilerOutput(Logging::Category::Warning, *sources[i],
static_cast<const char*
>(errorBlob->GetBufferPointer()), desc.flags);
466 LOG_TRACE(logger,
"Built %s shader %zu", profiles[i], shaderId);
469 if (useShaderCache && shaderId) {
470 D3D_SHADER_DATA shaderData;
471 shaderData.pBytecode = byteCode[i]->GetBufferPointer();
472 shaderData.BytecodeLength = byteCode[i]->GetBufferSize();
474 ResourcePointer<ID3DBlob> compressedShader;
475 hr = D3DCompressShaders(1, &shaderData, D3D_COMPRESS_SHADER_KEEP_ALL_PARTS, compressedShader.internalPointer());
477 LOG_WARNING(logger,
"Failed to compress shader cache item %s: %s", cacheName.c_str(), direct3D11ReturnCodeAsString(hr));
480 if (!handler->writeBinaryFile(IIOHandler::FileType::ShaderCache,
482 compressedShader->GetBufferPointer(),
483 compressedShader->GetBufferSize()))
486 LOG_WARNING(logger,
"Failed to store compute shader cache item %s", cacheName.c_str());
489 LOG_TRACE(logger,
"Stored compute shader cache item %s", cacheName.c_str());
495 effect.shaders[i].byteCode = byteCode[i];
497 reflectShader(effect.shaders[i]);
499#ifdef COGSRENDERING_GFX_ANNOTATE
502 case ShaderType::VertexShader: doAnnotate<ID3D11VertexShader>(effect.shaders[i], tryToName(sources[i]->origin));
break;
503 case ShaderType::HullShader: doAnnotate<ID3D11HullShader>(effect.shaders[i], tryToName(sources[i]->origin));
break;
504 case ShaderType::DomainShader: doAnnotate<ID3D11DomainShader>(effect.shaders[i], tryToName(sources[i]->origin));
break;
505 case ShaderType::GeometryShader: doAnnotate<ID3D11GeometryShader>(effect.shaders[i], tryToName(sources[i]->origin));
break;
506 case ShaderType::PixelShader: doAnnotate<ID3D11PixelShader>(effect.shaders[i], tryToName(sources[i]->origin));
break;
507 case ShaderType::ComputeShader: doAnnotate<ID3D11ComputeShader>(effect.shaders[i], tryToName(sources[i]->origin));
break;
514 if (dumpShaderContents) {
520 meta.append(
" \"name\": ");
523 meta.append(desc.name.empty() ?
"N/A" : desc.name.data());
526 if (!desc.definitions.empty()) {
527 meta.append(
" \"definitions\": {\n");
529 for (
auto & d : desc.definitions) {
531 meta.append(d.first);
535 meta.append(d.second);
536 meta.append(
"\",\n");
539 meta.append(
" },\n");
543 for (
int i = 0; i < ShaderType::NumShaderTypes; i++) {
544 if (sources[i]->content.empty()) {
548 effectId =
Cogs::hash(shaderIds[i], effectId);
551 meta.append(profiles[i]);
554 auto dumpName = desc.name.empty() ? std::to_string(shaderIds[i]) + profiles[i] +
".dump.hlsl" : std::string(desc.name) +
"." + profiles[i] +
".hlsl";
556 meta.append(dumpName);
559 if (sources[i]->sourceName.size()) {
561 meta.append(profiles[i]);
562 meta.append(
"_includes\": [\n");
564 for (
auto & s : sources[i]->sourceName) {
565 if (s ==
"anonymous")
continue;
572 meta.append(
" ],\n");
578 auto metaName = desc.name.empty() ? std::to_string(effectId) +
".json" : std::string(desc.name) +
".d3d11.json";
579 handler->writeBinaryFile(IIOHandler::FileType::ShaderDump, metaName, meta.data(), meta.size());
582 if (FAILED(hr = device->CreateVertexShader(byteCode[0]->GetBufferPointer(), byteCode[0]->GetBufferSize(),
nullptr, (ID3D11VertexShader **)&effect.vertexShader.shader))) {
583 LOG_ERROR(logger,
"Failed to create vertex shader: %s", direct3D11ReturnCodeAsString(hr));
587 LOG_TRACE(logger,
"Created vertex shader %p", effect.vertexShader.shader.get<
void>());
590 if (!hsSource.content.empty()) {
591 if (FAILED(hr = device->CreateHullShader(byteCode[1]->GetBufferPointer(), byteCode[1]->GetBufferSize(),
nullptr, (ID3D11HullShader **)&effect.hullShader.shader))) {
592 LOG_ERROR(logger,
"Failed to create hull shader: %s", direct3D11ReturnCodeAsString(hr));
596 LOG_TRACE(logger,
"Created hull shader %p", effect.hullShader.shader.get<
void>());
600 if (!dsSource.content.empty()) {
601 if (FAILED(hr = device->CreateDomainShader(byteCode[2]->GetBufferPointer(), byteCode[2]->GetBufferSize(),
nullptr, (ID3D11DomainShader **)&effect.domainShader.shader))) {
602 LOG_ERROR(logger,
"Failed to create domain shader: %s", direct3D11ReturnCodeAsString(hr));
606 LOG_TRACE(logger,
"Created domain shader %p", effect.domainShader.shader.get<
void>());
610 if (!gsSource.content.empty()) {
611 if (FAILED(hr = device->CreateGeometryShader(byteCode[3]->GetBufferPointer(), byteCode[3]->GetBufferSize(),
nullptr, (ID3D11GeometryShader **)&effect.geometryShader.shader))) {
612 LOG_ERROR(logger,
"Failed to create geometry shader: %s", direct3D11ReturnCodeAsString(hr));
616 LOG_TRACE(logger,
"Created geometry shader %p", effect.geometryShader.shader.get<
void>());
620 if (!psSource.content.empty()) {
621 if (FAILED(hr = device->CreatePixelShader(byteCode[4]->GetBufferPointer(), byteCode[4]->GetBufferSize(),
nullptr, (ID3D11PixelShader **)&effect.pixelShader.shader))) {
622 LOG_ERROR(logger,
"Failed to create pixel shader: %s", direct3D11ReturnCodeAsString(hr));
626 LOG_TRACE(logger,
"Created pixel shader %p", effect.pixelShader.shader.get<
void>());
630 auto handle = effects.addResource(std::move(effect));
635void Cogs::EffectsD3D11::reflectShader(Shader & shader)
638 auto code = shader.byteCode.get<ID3DBlob>();
641 hr = D3DReflect(code->GetBufferPointer(), code->GetBufferSize(), IID_ID3D11ShaderReflection, (
void **) &reflector);
643 LOG_ERROR(logger,
"Failed to reflect on bytecode: %s", direct3D11ReturnCodeAsString(hr));
647 D3D11_SHADER_DESC shaderDesc;
648 hr = reflector->GetDesc(&shaderDesc);
650 LOG_ERROR(logger,
"Failed to get shader description on bytecode: %s", direct3D11ReturnCodeAsString(hr));
654 shader.reflection.constantBuffers.resize(shaderDesc.ConstantBuffers);
656 for (UINT i = 0; i < shaderDesc.ConstantBuffers; ++i) {
657 auto constantBufferReflect = reflector->GetConstantBufferByIndex(i);
658 auto & constantBuffer = shader.reflection.constantBuffers[i];
659 constantBuffer.slot = i;
660 constantBuffer.dirty =
true;
662 D3D11_SHADER_BUFFER_DESC cbDesc;
663 hr = constantBufferReflect->GetDesc(&cbDesc);
664 assert(SUCCEEDED(hr));
666 shader.reflection.slots[StringId(cbDesc.Name)] = i;
668 constantBuffer.memoryBuffer.resize(cbDesc.Size);
672 constantBuffer.offsets.resize(cbDesc.Variables);
673 constantBuffer.sizes.resize(cbDesc.Variables);
675 for (UINT j = 0; j < cbDesc.Variables; ++j) {
676 auto * variable = constantBufferReflect->GetVariableByIndex(j);
677 assert(variable !=
nullptr);
679 D3D11_SHADER_VARIABLE_DESC vDesc;
680 hr = variable->GetDesc(&vDesc);
681 assert(SUCCEEDED(hr));
683 D3D11_SHADER_TYPE_DESC tDesc;
684 hr = variable->GetType()->GetDesc(&tDesc);
685 assert(SUCCEEDED(hr));
687 constantBuffer.variables[StringId(vDesc.Name)] =
static_cast<uint16_t
>(j);
688 constantBuffer.offsets[j] = vDesc.StartOffset;
689 constantBuffer.sizes[j] = vDesc.Size;
693 for (UINT i = 0; i < shaderDesc.BoundResources; ++i) {
694 D3D11_SHADER_INPUT_BIND_DESC iDesc;
695 hr = reflector->GetResourceBindingDesc(i, &iDesc);
696 assert(SUCCEEDED(hr));
698 if (iDesc.Type == D3D_SIT_TEXTURE || iDesc.Type == D3D_SIT_UAV_RWTYPED) {
699 shader.reflection.textures[StringId(iDesc.Name)] = iDesc.BindPoint;
701 if (iDesc.BindCount > 1) {
702 for (UINT b = 1; b < iDesc.BindCount; ++b) {
703 shader.reflection.textures[StringId(iDesc.Name + std::to_string(b))] = iDesc.BindPoint + b;
706 }
else if (iDesc.Type == D3D_SIT_UAV_RWSTRUCTURED || iDesc.Type == D3D_SIT_UAV_RWBYTEADDRESS || iDesc.Type == D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER) {
707 shader.reflection.bufferUAVs[StringId(iDesc.Name)] = iDesc.BindPoint;
708 }
else if (iDesc.Type == D3D_SIT_STRUCTURED || iDesc.Type == D3D_SIT_BYTEADDRESS) {
709 shader.reflection.bufferSRVs[StringId(iDesc.Name)] = iDesc.BindPoint;
710 }
else if (iDesc.Type == D3D_SIT_SAMPLER) {
711 shader.reflection.samplers[StringId(iDesc.Name)] = iDesc.BindPoint;
712 }
else if (iDesc.Type != D3D_SIT_CBUFFER) {
713 LOG_WARNING(logger,
"Unsupported binding type in shader.");
Log implementation class.
void log(const Category category, uint32_t errorNumber, _Printf_format_string_ const char *fmt,...) const VALIDATE_ARGS(4)
Log a formatted message.
Provides a weakly referenced view over the contents of a string.
constexpr const char * data() const noexcept
Get the sequence of characters referenced by the string view.
constexpr size_t length() const noexcept
Get the length of the string.
constexpr bool empty() const noexcept
Check if the string is empty.
constexpr Log getLogger(const char(&name)[LEN]) noexcept
@ Unspecified
The default error number for legacy logger usage.
Category
Logging categories used to filter log messages.
constexpr size_t hash() noexcept
Simple getter function that returns the initial value for fnv1a hashing.
@ DumpShaderContents
Dump shader contents for debugging.
@ EnableShaderCache
Enables using a shader cache to avoid recompiling previously seen shaders.
@ EnableTraceLogging
Enables trace logging.
std::vector< PreprocessorDefinition > PreprocessorDefinitions
A set of preprocessor definitions.
@ Write
The buffer can be mapped and written to by the CPU after creation.
@ ConstantBuffer
The buffer can be bound as input to effects as a constant buffer.
Contains an effect description used to load a single effect.
EEffectFlags
Effect source flags.
@ LogShaderSource
Log the contents of the shader on error.
@ Pinned
Effect can only be released explicitly, not using releaseResources().
EffectHandle loadComputeEffect(const StringView &fileName, EffectFlags::EEffectFlags effectFlags) override
Load the compute shader with the given file name and create an effect.
void annotateVS(EffectHandle handle, const StringView &name) override
Associate a name with an object for use in graphics debugging.
void annotateGS(EffectHandle handle, const StringView &name) override
Associate a name with an object for use in graphics debugging.
void annotatePS(EffectHandle handle, const StringView &name) override
Associate a name with an object for use in graphics debugging.
void releaseEffect(EffectHandle handle) override
Release the effect with the given handle, freeing all resources generated during program loading.
void releaseResources() override
Release all allocated effect resources.
void annotateCS(EffectHandle handle, const StringView &name) override
Associate a name with an object for use in graphics debugging.
void annotate(EffectHandle handle, const StringView &name) override
Associate a name with an object for use in graphics debugging.
static const Handle_t InvalidHandle
Represents an invalid handle.
@ Dynamic
Buffer will be loaded and modified with some frequency.