refactor(recompiler): share the stage input info helpers
StageOf, VertexInfo, PixelInfo and ShaderWorkgroupInput were defined in the anonymous namespaces of up to three SPIR-V backend sources with identical bodies; they are now declared next to FailEmit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
80d4f6b716
commit
ac9287c2ef
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -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<std::uint32_t>::max();
|
||||
|
||||
std::uint32_t BuiltInForInput(StageInputKind kind) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue