mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-30 09:08:19 +00:00
shader: type packed integer vertex inputs by their component type
This commit is contained in:
1 parent
b65dd18224
commit
1703836d06
4 files changed
+13
-38
No files matched your search
@@ -173,7 +173,7 @@ uint32_t EmitVertexParameterComponentU32(EmitterState& state, const InputBinding
|
|||||||
state.builder.AddFunction(spv::OpLoad, scalar_type, raw, pointer);
|
state.builder.AddFunction(spv::OpLoad, scalar_type, raw, pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == VertexInputScalarKind::Uint) {
|
if (kind == Format::ComponentType::Uint) {
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,8 +273,6 @@ struct ValueEmitContext {
|
|||||||
uint32_t half = 0;
|
uint32_t half = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class VertexInputScalarKind { Float, Sint, Uint };
|
|
||||||
|
|
||||||
constexpr uint32_t NoImageComponent = 0xffffffffu;
|
constexpr uint32_t NoImageComponent = 0xffffffffu;
|
||||||
|
|
||||||
struct DppTargetLane {
|
struct DppTargetLane {
|
||||||
@@ -304,12 +302,11 @@ bool PixelParameterIsFlat(const EmitterState& state, uint32_t attr);
|
|||||||
|
|
||||||
bool PixelParameterIsCustom(const EmitterState& state, uint32_t attr);
|
bool PixelParameterIsCustom(const EmitterState& state, uint32_t attr);
|
||||||
|
|
||||||
VertexInputScalarKind VertexParameterScalarKind(const EmitterState& state, uint32_t location);
|
Format::ComponentType VertexParameterScalarKind(const EmitterState& state, uint32_t location);
|
||||||
|
|
||||||
uint32_t VertexParameterComponentCount(const InputBinding& input);
|
uint32_t VertexParameterComponentCount(const InputBinding& input);
|
||||||
|
|
||||||
uint32_t VertexParameterScalarType(EmitterState& state, VertexInputScalarKind kind);
|
uint32_t VertexParameterScalarType(EmitterState& state, Format::ComponentType kind);
|
||||||
|
|
||||||
|
|
||||||
uint32_t OutputVariableForExport(const EmitterState& state, const IR::ExportInfo& exp);
|
uint32_t OutputVariableForExport(const EmitterState& state, const IR::ExportInfo& exp);
|
||||||
uint32_t MrtOutputType(EmitterState& state, uint32_t index);
|
uint32_t MrtOutputType(EmitterState& state, uint32_t index);
|
||||||
|
|||||||
@@ -402,47 +402,23 @@ uint32_t GlslStd450(EmitterState& state) {
|
|||||||
return state.builder.Import("GLSL.std.450");
|
return state.builder.Import("GLSL.std.450");
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexInputScalarKind VertexParameterScalarKind(const EmitterState& state, uint32_t location) {
|
Format::ComponentType VertexParameterScalarKind(const EmitterState& state, uint32_t location) {
|
||||||
if ((state.program.stage != ShaderType::Vertex && state.program.stage != ShaderType::Local) ||
|
if ((state.program.stage != ShaderType::Vertex && state.program.stage != ShaderType::Local) ||
|
||||||
location >= ShaderVertexInputInfo::RES_MAX ||
|
location >= ShaderVertexInputInfo::RES_MAX ||
|
||||||
location >= static_cast<uint32_t>(state.input_info.vertex->resources_num)) {
|
location >= static_cast<uint32_t>(state.input_info.vertex->resources_num)) {
|
||||||
return VertexInputScalarKind::Float;
|
return Format::ComponentType::Float;
|
||||||
}
|
|
||||||
|
|
||||||
switch (state.input_info.vertex->resources[location].Format()) {
|
|
||||||
case Prospero::BufferFormat::k8UInt:
|
|
||||||
case Prospero::BufferFormat::k16UInt:
|
|
||||||
case Prospero::BufferFormat::k8_8UInt:
|
|
||||||
case Prospero::BufferFormat::k32UInt:
|
|
||||||
case Prospero::BufferFormat::k16_16UInt:
|
|
||||||
case Prospero::BufferFormat::k8_8_8_8UInt:
|
|
||||||
case Prospero::BufferFormat::k32_32UInt:
|
|
||||||
case Prospero::BufferFormat::k16_16_16_16UInt:
|
|
||||||
case Prospero::BufferFormat::k32_32_32UInt:
|
|
||||||
case Prospero::BufferFormat::k32_32_32_32UInt: return VertexInputScalarKind::Uint;
|
|
||||||
case Prospero::BufferFormat::k8SInt:
|
|
||||||
case Prospero::BufferFormat::k16SInt:
|
|
||||||
case Prospero::BufferFormat::k8_8SInt:
|
|
||||||
case Prospero::BufferFormat::k32SInt:
|
|
||||||
case Prospero::BufferFormat::k16_16SInt:
|
|
||||||
case Prospero::BufferFormat::k8_8_8_8SInt:
|
|
||||||
case Prospero::BufferFormat::k32_32SInt:
|
|
||||||
case Prospero::BufferFormat::k16_16_16_16SInt:
|
|
||||||
case Prospero::BufferFormat::k32_32_32SInt:
|
|
||||||
case Prospero::BufferFormat::k32_32_32_32SInt: return VertexInputScalarKind::Sint;
|
|
||||||
default: return VertexInputScalarKind::Float;
|
|
||||||
}
|
}
|
||||||
|
return Format::GetFormatComponentType(state.input_info.vertex->resources[location].Format());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VertexParameterComponentCount(const InputBinding& input) {
|
uint32_t VertexParameterComponentCount(const InputBinding& input) {
|
||||||
return std::clamp(input.component_count, 1u, 4u);
|
return std::clamp(input.component_count, 1u, 4u);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t VertexParameterScalarType(EmitterState& state, VertexInputScalarKind kind) {
|
uint32_t VertexParameterScalarType(EmitterState& state, Format::ComponentType kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case VertexInputScalarKind::Sint: return TypeI32(state);
|
case Format::ComponentType::Sint: return TypeI32(state);
|
||||||
case VertexInputScalarKind::Uint: return TypeU32(state);
|
case Format::ComponentType::Uint: return TypeU32(state);
|
||||||
case VertexInputScalarKind::Float:
|
|
||||||
default: return TypeF32(state);
|
default: return TypeF32(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48040,8 +48040,10 @@ void CheckEmbeddedFetchVertexOffset() {
|
|||||||
return ResolveDrawOffsets(0, vertex).second;
|
return ResolveDrawOffsets(0, vertex).second;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Packed integer formats load integers too.
|
||||||
for (const auto format : {Prospero::BufferFormat::k32_32_32_32Float,
|
for (const auto format : {Prospero::BufferFormat::k32_32_32_32Float,
|
||||||
Prospero::BufferFormat::k32_32_32_32UInt}) {
|
Prospero::BufferFormat::k32_32_32_32UInt,
|
||||||
|
Prospero::BufferFormat::k10_10_10_2UInt}) {
|
||||||
const auto local = Compile("LocalEmbeddedFetch", MakeFetch({}, {}, 0, false, true),
|
const auto local = Compile("LocalEmbeddedFetch", MakeFetch({}, {}, 0, false, true),
|
||||||
0, ShaderType::Local, format);
|
0, ShaderType::Local, format);
|
||||||
ValidateSpirv("LocalEmbeddedFetch", local.spirv);
|
ValidateSpirv("LocalEmbeddedFetch", local.spirv);
|
||||||
@@ -48050,7 +48052,7 @@ void CheckEmbeddedFetchVertexOffset() {
|
|||||||
return input.kind == ShaderRecompiler::IR::StageInputKind::Parameter &&
|
return input.kind == ShaderRecompiler::IR::StageInputKind::Parameter &&
|
||||||
input.location == 0;
|
input.location == 0;
|
||||||
}), "LS indexed fetch must consume native vertex attributes");
|
}), "LS indexed fetch must consume native vertex attributes");
|
||||||
if (format == Prospero::BufferFormat::k32_32_32_32UInt) {
|
if (format != Prospero::BufferFormat::k32_32_32_32Float) {
|
||||||
spvtools::SpirvTools tools(SPV_ENV_VULKAN_1_2);
|
spvtools::SpirvTools tools(SPV_ENV_VULKAN_1_2);
|
||||||
std::string assembly;
|
std::string assembly;
|
||||||
Require("LocalEmbeddedFetch", "disassembly", tools.Disassemble(local.spirv, &assembly),
|
Require("LocalEmbeddedFetch", "disassembly", tools.Disassemble(local.spirv, &assembly),
|
||||||
|
|||||||
Reference in new issue
Block a user