mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
shader: fix missing homogeneous semantics
This commit is contained in:
@@ -222,8 +222,8 @@ Prospero::BufferFormat BufferFormat(const ValueEmitContext& ctx, const IR::Inst&
|
||||
|
||||
IR::MemoryInfo RebaseFormattedComponent(IR::MemoryInfo mem, Prospero::BufferFormat format,
|
||||
uint32_t component) {
|
||||
if (!mem.typed && component != 0u) {
|
||||
const auto component_slot = component * 4u;
|
||||
if (!mem.typed) {
|
||||
const auto component_slot = mem.component_index * 4u;
|
||||
mem.offset = mem.offset >= component_slot ? mem.offset - component_slot : 0u;
|
||||
mem.offset += Format::GetFormatComponentByteOffset(format, component);
|
||||
}
|
||||
@@ -234,12 +234,27 @@ uint32_t FormattedLoad(ValueEmitContext& ctx, const IR::Inst& inst, const IR::Me
|
||||
const auto format = BufferFormat(ctx, inst, mem);
|
||||
if (!Format::IsKnownFormat(format)) return LoadWord(ctx, inst, mem);
|
||||
const auto info = Format::GetFormatInfo(format);
|
||||
const auto component = mem.component_index;
|
||||
auto component = mem.component_index;
|
||||
if (!mem.typed) {
|
||||
const auto selector =
|
||||
GetDstSel(ctx.state.program.info.buffers[mem.resource].descriptor_swizzle, component);
|
||||
if (selector == 0u) return ConstantU32(ctx.state, 0);
|
||||
if (selector == 1u) {
|
||||
const auto integer = info.type == Format::ComponentType::Uint ||
|
||||
info.type == Format::ComponentType::Sint;
|
||||
return ConstantU32(ctx.state, integer ? 1u : 0x3f800000u);
|
||||
}
|
||||
if (selector < 4u) {
|
||||
ExitDescriptorBindingFailure(ctx.state, IR::DescriptorBindingKind::Buffers,
|
||||
mem.resource, "buffer descriptor has reserved dst_sel");
|
||||
}
|
||||
component = selector - 4u;
|
||||
}
|
||||
if (component >= info.component_count) return ConstantU32(ctx.state, 0);
|
||||
uint32_t raw = 0;
|
||||
const auto bits = info.component_bits[component];
|
||||
if (info.packed_bitfield) {
|
||||
raw = LoadWord(ctx, inst, mem);
|
||||
raw = LoadWord(ctx, inst, RebaseFormattedComponent(mem, format, component));
|
||||
const auto type =
|
||||
IsSignedFormatComponent(info.type) ? ctx.state.int_type : ctx.state.uint_type;
|
||||
const auto source =
|
||||
|
||||
@@ -168,17 +168,18 @@ struct DescriptorValue {
|
||||
struct BufferResource {
|
||||
static constexpr uint32_t NoImageAlias = UINT32_MAX;
|
||||
|
||||
uint32_t source = 0;
|
||||
uint32_t first_use_pc = 0;
|
||||
uint32_t max_byte_extent = 0;
|
||||
uint32_t packed_stride = 0;
|
||||
Prospero::BufferFormat descriptor_format = Prospero::BufferFormat::kInvalid;
|
||||
uint32_t image_alias = NoImageAlias;
|
||||
bool read = false;
|
||||
bool written = false;
|
||||
bool atomic = false;
|
||||
bool formatted = false;
|
||||
bool scalar = false;
|
||||
uint32_t source = 0;
|
||||
uint32_t first_use_pc = 0;
|
||||
uint32_t max_byte_extent = 0;
|
||||
uint32_t packed_stride = 0;
|
||||
Prospero::BufferFormat descriptor_format = Prospero::BufferFormat::kInvalid;
|
||||
uint32_t descriptor_swizzle = DstSel(4, 5, 6, 7);
|
||||
uint32_t image_alias = NoImageAlias;
|
||||
bool read = false;
|
||||
bool written = false;
|
||||
bool atomic = false;
|
||||
bool formatted = false;
|
||||
bool scalar = false;
|
||||
|
||||
bool operator==(const BufferResource& other) const = default;
|
||||
};
|
||||
|
||||
@@ -190,7 +190,8 @@ bool ValidateResourceSpecialization(const Program& program, const ResourceSnapsh
|
||||
return false;
|
||||
}
|
||||
if (buffer.packed_stride != descriptor.PackedStride() ||
|
||||
buffer.descriptor_format != descriptor.Format()) {
|
||||
buffer.descriptor_format != descriptor.Format() ||
|
||||
buffer.descriptor_swizzle != descriptor.DstSelXYZW()) {
|
||||
if (error != nullptr) {
|
||||
*error = fmt::format("buffer descriptor {} no longer matches specialization", i);
|
||||
}
|
||||
@@ -392,8 +393,9 @@ bool SpecializeResources(Program& program, const ResourceSnapshot& snapshot, std
|
||||
}
|
||||
return false;
|
||||
}
|
||||
next.buffers[i].packed_stride = descriptor.PackedStride();
|
||||
next.buffers[i].descriptor_format = descriptor.Format();
|
||||
next.buffers[i].packed_stride = descriptor.PackedStride();
|
||||
next.buffers[i].descriptor_format = descriptor.Format();
|
||||
next.buffers[i].descriptor_swizzle = descriptor.DstSelXYZW();
|
||||
}
|
||||
for (uint32_t i = 0; i < next.addresses.size(); i++) {
|
||||
next.addresses[i].specialized_base =
|
||||
|
||||
@@ -1016,8 +1016,9 @@ static std::string ShaderDescribeSpecialization(const ShaderRecompiler::IR::Prog
|
||||
program.values != nullptr ? program.values->srt_reads.size() : 0u);
|
||||
for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
|
||||
const auto& buffer = program.info.buffers[i];
|
||||
ret += fmt::format(" b{}[stride={} format={}]", i, buffer.packed_stride,
|
||||
static_cast<uint32_t>(buffer.descriptor_format));
|
||||
ret +=
|
||||
fmt::format(" b{}[stride={} format={} swizzle=0x{:03x}]", i, buffer.packed_stride,
|
||||
static_cast<uint32_t>(buffer.descriptor_format), buffer.descriptor_swizzle);
|
||||
}
|
||||
for (uint32_t i = 0; i < program.info.images.size(); i++) {
|
||||
const auto& image = program.info.images[i];
|
||||
@@ -1054,6 +1055,7 @@ static void ShaderAppendNativeSpecialization(std::vector<uint32_t>&
|
||||
for (const auto& buffer: program.info.buffers) {
|
||||
ids.push_back(buffer.packed_stride);
|
||||
ids.push_back(static_cast<uint32_t>(buffer.descriptor_format));
|
||||
ids.push_back(buffer.descriptor_swizzle);
|
||||
}
|
||||
ids.push_back(static_cast<uint32_t>(program.info.images.size()));
|
||||
for (const auto& image: program.info.images) {
|
||||
|
||||
Reference in New Issue
Block a user