Disable re-spirv and print out measurements for shader compilation.

This commit is contained in:
Dario 2024-08-10 15:51:38 -03:00
parent 1812bc03c3
commit 5d41a137ae
2 changed files with 18 additions and 0 deletions

View File

@ -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<RenderShader> vertexShader;
std::unique_ptr<RenderShader> pixelShader;
std::vector<RenderSpecConstant> 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<respv::SpecConstant> specConstants;
thread_local bool specConstantsSetup = false;
thread_local std::vector<uint8_t> 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);
}

View File

@ -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<RasterShader> newShader = std::make_unique<RasterShader>(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)) {