diff --git a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterHelpers.hpp b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterHelpers.hpp index caec0c7bb..7d8f0874c 100644 --- a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterHelpers.hpp +++ b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterHelpers.hpp @@ -8,6 +8,10 @@ namespace ShaderRecompiler { [[noreturn]] void FailEmit(const std::string& reason); +IrShaderStage StageOf(const SpirvEmitterState& state); +const ShaderVertexInputInfo& VertexInfo(const SpirvEmitterState& state); +const ShaderPixelInputInfo& PixelInfo(const SpirvEmitterState& state); +const ShaderWorkgroupInputInfo* ShaderWorkgroupInput(const SpirvEmitterState& state); const RdnaImageDimensionInfo& RdnaImageDimensionInfoFor(RdnaImageDimension dimension); std::uint32_t TypeVoid(SpirvEmitterState& state); std::uint32_t TypeBool(SpirvEmitterState& state); diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp index b63540f83..e851e0d13 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp @@ -12,23 +12,6 @@ namespace ShaderRecompiler { namespace { - const ShaderWorkgroupInputInfo* ShaderWorkgroupInput(const SpirvEmitterState& state) { - switch (state.program.Resources().stage) { - case IrShaderStage::Compute: - if (state.inputInfo.compute == nullptr) { - FailEmit("compute input info is missing"); - } - return state.inputInfo.compute; - case IrShaderStage::Mesh: - if (state.inputInfo.vertex == nullptr) { - FailEmit("vertex input info is missing"); - } - return &state.inputInfo.vertex->mesh; - default: - return nullptr; - } - } - void EnsureLdsStorage(SpirvEmitterState& state) { if (state.ldsVariable != 0) { return; diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvDescriptors.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvDescriptors.cpp index 0fe12f8ef..a9de20d7d 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvDescriptors.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvDescriptors.cpp @@ -12,10 +12,6 @@ namespace ShaderRecompiler { namespace { -IrShaderStage StageOf(const SpirvEmitterState& state) { - return state.program.Resources().stage; -} - constexpr RdnaImageDimensionInfo ImageDimensions[] = { {RdnaImageDimension::Dim1D, spv::Dim1D, 1, 1, 0, 0}, {RdnaImageDimension::Dim2D, spv::Dim2D, 2, 2, 0, 0}, diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp index 0edb9069a..28a7bdf07 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp @@ -16,7 +16,16 @@ void FailEmit(const std::string& reason) { throw std::runtime_error("SPIR-V module emission failed: " + reason); } -namespace { +IrShaderStage StageOf(const SpirvEmitterState& state) { + return state.program.Resources().stage; +} + +const ShaderVertexInputInfo& VertexInfo(const SpirvEmitterState& state) { + if (state.inputInfo.vertex == nullptr) { + FailEmit("vertex input info is missing"); + } + return *state.inputInfo.vertex; +} const ShaderPixelInputInfo& PixelInfo(const SpirvEmitterState& state) { if (state.inputInfo.pixel == nullptr) { @@ -25,6 +34,25 @@ const ShaderPixelInputInfo& PixelInfo(const SpirvEmitterState& state) { return *state.inputInfo.pixel; } +const ShaderWorkgroupInputInfo* ShaderWorkgroupInput(const SpirvEmitterState& state) { + switch (state.program.Resources().stage) { + case IrShaderStage::Compute: + if (state.inputInfo.compute == nullptr) { + FailEmit("compute input info is missing"); + } + return state.inputInfo.compute; + case IrShaderStage::Mesh: + if (state.inputInfo.vertex == nullptr) { + FailEmit("vertex input info is missing"); + } + return &state.inputInfo.vertex->mesh; + default: + return nullptr; + } +} + +namespace { + constexpr std::uint32_t NoBuiltIn = std::numeric_limits::max(); std::uint32_t BuiltInForInput(StageInputKind kind) { diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvInputOutput.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvInputOutput.cpp index a4e551735..72f796336 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvInputOutput.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvInputOutput.cpp @@ -19,24 +19,6 @@ namespace ShaderRecompiler constexpr std::uint32_t PsInputFlatShade = 0x00000400u; constexpr std::uint32_t PixelParameterLimit = 32u; - IrShaderStage StageOf(const SpirvEmitterState& state) { - return state.program.Resources().stage; - } - - const ShaderVertexInputInfo& VertexInfo(const SpirvEmitterState& state) { - if (state.inputInfo.vertex == nullptr) { - FailEmit("vertex input info is missing"); - } - return *state.inputInfo.vertex; - } - - const ShaderPixelInputInfo& PixelInfo(const SpirvEmitterState& state) { - if (state.inputInfo.pixel == nullptr) { - FailEmit("pixel input info is missing"); - } - return *state.inputInfo.pixel; - } - bool IsVertexLikeStage(const SpirvEmitterState& state) { return StageOf(state) == IrShaderStage::Vertex || StageOf(state) == IrShaderStage::Local; } diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp index 9b42dde31..e17e8445b 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp @@ -10,45 +10,6 @@ namespace ShaderRecompiler { -namespace { - -IrShaderStage StageOf(const SpirvEmitterState& state) { - return state.program.Resources().stage; -} - -const ShaderVertexInputInfo& VertexInfo(const SpirvEmitterState& state) { - if (state.inputInfo.vertex == nullptr) { - FailEmit("vertex input info is missing"); - } - return *state.inputInfo.vertex; -} - -const ShaderPixelInputInfo& PixelInfo(const SpirvEmitterState& state) { - if (state.inputInfo.pixel == nullptr) { - FailEmit("pixel input info is missing"); - } - return *state.inputInfo.pixel; -} - -const ShaderWorkgroupInputInfo* ShaderWorkgroupInput(const SpirvEmitterState& state) { - switch (state.program.Resources().stage) { - case IrShaderStage::Compute: - if (state.inputInfo.compute == nullptr) { - FailEmit("compute input info is missing"); - } - return state.inputInfo.compute; - case IrShaderStage::Mesh: - if (state.inputInfo.vertex == nullptr) { - FailEmit("vertex input info is missing"); - } - return &state.inputInfo.vertex->mesh; - default: - return nullptr; - } -} - -} - void EmitModuleHeader(SpirvModule& module, const IrProgram& program, const BindingAllocationResult& bindings) { CheckBindings(program, bindings);