vk_graphics_pipeline: Fix regression

This commit is contained in:
IndecisiveTurtle 2024-08-08 17:00:08 +03:00
parent 341034fc30
commit 3fd2abdd5b
5 changed files with 9 additions and 9 deletions

View File

@ -129,7 +129,7 @@ Id EmitReadConst(EmitContext& ctx) {
Id EmitReadConstBuffer(EmitContext& ctx, u32 handle, Id index) { Id EmitReadConstBuffer(EmitContext& ctx, u32 handle, Id index) {
auto& buffer = ctx.buffers[handle]; auto& buffer = ctx.buffers[handle];
if (!Sirit::ValidId(buffer.offset)) { if (!Sirit::ValidId(buffer.offset)) {
buffer.offset = ctx.GetBufferOffset(handle); buffer.offset = ctx.GetBufferOffset(buffer.global_binding);
} }
const Id offset_dwords{ctx.OpShiftRightLogical(ctx.U32[1], buffer.offset, ctx.ConstU32(2U))}; const Id offset_dwords{ctx.OpShiftRightLogical(ctx.U32[1], buffer.offset, ctx.ConstU32(2U))};
index = ctx.OpIAdd(ctx.U32[1], index, offset_dwords); index = ctx.OpIAdd(ctx.U32[1], index, offset_dwords);
@ -230,7 +230,7 @@ template <u32 N>
static Id EmitLoadBufferF32xN(EmitContext& ctx, u32 handle, Id address) { static Id EmitLoadBufferF32xN(EmitContext& ctx, u32 handle, Id address) {
auto& buffer = ctx.buffers[handle]; auto& buffer = ctx.buffers[handle];
if (!Sirit::ValidId(buffer.offset)) { if (!Sirit::ValidId(buffer.offset)) {
buffer.offset = ctx.GetBufferOffset(handle); buffer.offset = ctx.GetBufferOffset(buffer.global_binding);
} }
address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset); address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset);
const Id index = ctx.OpShiftRightLogical(ctx.U32[1], address, ctx.ConstU32(2u)); const Id index = ctx.OpShiftRightLogical(ctx.U32[1], address, ctx.ConstU32(2u));
@ -412,7 +412,7 @@ template <u32 N>
static Id EmitLoadBufferFormatF32xN(EmitContext& ctx, IR::Inst* inst, u32 handle, Id address) { static Id EmitLoadBufferFormatF32xN(EmitContext& ctx, IR::Inst* inst, u32 handle, Id address) {
auto& buffer = ctx.buffers[handle]; auto& buffer = ctx.buffers[handle];
if (!Sirit::ValidId(buffer.offset)) { if (!Sirit::ValidId(buffer.offset)) {
buffer.offset = ctx.GetBufferOffset(handle); buffer.offset = ctx.GetBufferOffset(buffer.global_binding);
} }
address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset); address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset);
if constexpr (N == 1) { if constexpr (N == 1) {
@ -446,7 +446,7 @@ template <u32 N>
static void EmitStoreBufferF32xN(EmitContext& ctx, u32 handle, Id address, Id value) { static void EmitStoreBufferF32xN(EmitContext& ctx, u32 handle, Id address, Id value) {
auto& buffer = ctx.buffers[handle]; auto& buffer = ctx.buffers[handle];
if (!Sirit::ValidId(buffer.offset)) { if (!Sirit::ValidId(buffer.offset)) {
buffer.offset = ctx.GetBufferOffset(handle); buffer.offset = ctx.GetBufferOffset(buffer.global_binding);
} }
address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset); address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset);
const Id index = ctx.OpShiftRightLogical(ctx.U32[1], address, ctx.ConstU32(2u)); const Id index = ctx.OpShiftRightLogical(ctx.U32[1], address, ctx.ConstU32(2u));

View File

@ -352,9 +352,9 @@ void EmitContext::DefineBuffers() {
Decorate(id, spv::Decoration::DescriptorSet, 0U); Decorate(id, spv::Decoration::DescriptorSet, 0U);
Name(id, fmt::format("{}_{}", buffer.is_storage ? "ssbo" : "cbuf", buffer.sgpr_base)); Name(id, fmt::format("{}_{}", buffer.is_storage ? "ssbo" : "cbuf", buffer.sgpr_base));
binding++;
buffers.push_back({ buffers.push_back({
.id = id, .id = id,
.global_binding = binding++,
.data_types = data_types, .data_types = data_types,
.pointer_type = pointer_type, .pointer_type = pointer_type,
.buffer = buffer.GetVsharp(info), .buffer = buffer.GetVsharp(info),

View File

@ -203,6 +203,7 @@ public:
struct BufferDefinition { struct BufferDefinition {
Id id; Id id;
Id offset; Id offset;
u32 global_binding;
const VectorIds* data_types; const VectorIds* data_types;
Id pointer_type; Id pointer_type;
AmdGpu::Buffer buffer; AmdGpu::Buffer buffer;

View File

@ -125,7 +125,7 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache,
const u32 adjust = offset - offset_aligned; const u32 adjust = offset - offset_aligned;
if (adjust != 0) { if (adjust != 0) {
ASSERT(adjust % 4 == 0); ASSERT(adjust % 4 == 0);
push_data.AddOffset(i, adjust); push_data.AddOffset(binding, adjust);
} }
buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust); buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust);
set_writes.push_back({ set_writes.push_back({

View File

@ -343,7 +343,7 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs,
push_data.step0 = regs.vgt_instance_step_rate_0; push_data.step0 = regs.vgt_instance_step_rate_0;
push_data.step1 = regs.vgt_instance_step_rate_1; push_data.step1 = regs.vgt_instance_step_rate_1;
} }
for (u32 i = 0; const auto& buffer : stage.buffers) { for (const auto& buffer : stage.buffers) {
const auto vsharp = buffer.GetVsharp(stage); const auto vsharp = buffer.GetVsharp(stage);
if (vsharp) { if (vsharp) {
const VAddr address = vsharp.base_address; const VAddr address = vsharp.base_address;
@ -359,7 +359,7 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs,
const u32 adjust = offset - offset_aligned; const u32 adjust = offset - offset_aligned;
if (adjust != 0) { if (adjust != 0) {
ASSERT(adjust % 4 == 0); ASSERT(adjust % 4 == 0);
push_data.AddOffset(i, adjust); push_data.AddOffset(binding, adjust);
} }
buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust); buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust);
} else { } else {
@ -374,7 +374,6 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs,
: vk::DescriptorType::eUniformBuffer, : vk::DescriptorType::eUniformBuffer,
.pBufferInfo = &buffer_infos.back(), .pBufferInfo = &buffer_infos.back(),
}); });
i++;
} }
boost::container::static_vector<AmdGpu::Image, 16> tsharps; boost::container::static_vector<AmdGpu::Image, 16> tsharps;