diff --git a/src/render/rt64_raster_shader.cpp b/src/render/rt64_raster_shader.cpp index 69fcda5..d794e2b 100644 --- a/src/render/rt64_raster_shader.cpp +++ b/src/render/rt64_raster_shader.cpp @@ -35,6 +35,8 @@ #include "rt64_descriptor_sets.h" #include "rt64_render_target.h" +#define RESPIRV_ENABLED 0 + namespace RT64 { static const RenderFormat RasterPositionFormat = RenderFormat::R32G32B32A32_FLOAT; static const RenderFormat RasterTexcoordFormat = RenderFormat::R32G32_FLOAT; @@ -86,6 +88,7 @@ namespace RT64 { const bool useMSAA = (multisampling.sampleCount > 1); std::unique_ptr vertexShader; std::unique_ptr pixelShader; + std::vector specConstants; if (shaderFormat == RenderShaderFormat::SPIRV) { // Choose the pre-compiled shader permutations. const respv::Shader *VS = nullptr; @@ -111,6 +114,7 @@ namespace RT64 { } } +# if RESPIRV_ENABLED thread_local std::vector specConstants; thread_local bool specConstantsSetup = false; thread_local std::vector optimizedVS; @@ -135,6 +139,15 @@ namespace RT64 { vertexShader = device->createShader(optimizedVS.data(), optimizedVS.size(), "VSMain", shaderFormat); pixelShader = device->createShader(optimizedPS.data(), optimizedPS.size(), "PSMain", shaderFormat); +# else + specConstants.emplace_back(0, desc.otherMode.L); + specConstants.emplace_back(1, desc.otherMode.H); + specConstants.emplace_back(2, desc.colorCombiner.L); + specConstants.emplace_back(3, desc.colorCombiner.H); + specConstants.emplace_back(4, desc.flags.value); + vertexShader = device->createShader(VS->spirvWords, VS->spirvWordCount * sizeof(uint32_t), "VSMain", shaderFormat); + pixelShader = device->createShader(PS->spirvWords, PS->spirvWordCount * sizeof(uint32_t), "PSMain", shaderFormat); +# endif } else { # if defined(_WIN32) @@ -207,6 +220,7 @@ namespace RT64 { creation.cvgAdd = (desc.otherMode.cvgDst() == CVG_DST_WRAP) || (desc.otherMode.cvgDst() == CVG_DST_SAVE); creation.NoN = desc.flags.NoN; creation.usesHDR = desc.flags.usesHDR; + creation.specConstants = specConstants; creation.multisampling = multisampling; pipeline = createPipeline(creation); } diff --git a/src/render/rt64_raster_shader_cache.cpp b/src/render/rt64_raster_shader_cache.cpp index 353f8c2..6812f94 100644 --- a/src/render/rt64_raster_shader_cache.cpp +++ b/src/render/rt64_raster_shader_cache.cpp @@ -4,6 +4,7 @@ #include "rt64_raster_shader_cache.h" +#include "common/rt64_elapsed_timer.h" #include "common/rt64_thread.h" #define ENABLE_OPTIMIZED_SHADER_GENERATION @@ -209,7 +210,10 @@ namespace RT64 { assert((shaderCache->shaderUber != nullptr) && "Ubershader should've been created by the time a new shader is submitted to the cache."); const RenderPipelineLayout *uberPipelineLayout = shaderCache->shaderUber->pipelineLayout.get(); const RenderMultisampling multisampling = shaderCache->multisampling; + const bool useMSAA = (multisampling.sampleCount > 1); + ElapsedTimer elapsedTimer; std::unique_ptr newShader = std::make_unique(shaderCache->device, shaderDesc, uberPipelineLayout, shaderCache->shaderFormat, multisampling, shaderCache->shaderCompiler.get(), &shaderCache->optimizerCacheSPIRV, shaderVsBytes, shaderPsBytes, useShaderBytes); + fprintf(stdout, "%f, %d, %d, %d, %u, %u, %u, %u, %u\n", elapsedTimer.elapsedMilliseconds(), shaderDesc.outputDepth(useMSAA), shaderDesc.flags.smoothShade, useMSAA, shaderDesc.otherMode.L, shaderDesc.otherMode.H, shaderDesc.colorCombiner.L, shaderDesc.colorCombiner.H, shaderDesc.flags.value); // Dump the bytes of the shader if requested. if (!useShaderBytes && (shaderVsBytes != nullptr) && (shaderPsBytes != nullptr)) {