From c67764d7fe956448cb170139d19db3ac1ff6bddf Mon Sep 17 00:00:00 2001 From: MaranBr Date: Fri, 26 Dec 2025 12:40:00 -0400 Subject: [PATCH] Fix CONST_A for different component sizes in MaxwellDMA Launch --- src/video_core/engines/maxwell_dma.cpp | 35 +++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index e2aa6c7e49..26aa2e10c8 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp @@ -96,15 +96,32 @@ void MaxwellDMA::Launch() { auto& accelerate = rasterizer->AccessAccelerateDMA(); const bool is_const_a_dst = regs.remap_const.dst_x == RemapConst::Swizzle::CONST_A; if (regs.launch_dma.remap_enable != 0 && is_const_a_dst) { - ASSERT(regs.remap_const.component_size_minus_one == 3); - accelerate.BufferClear(regs.offset_out, regs.line_length_in, - regs.remap_const.remap_consta_value); - read_buffer.resize_destructive(regs.line_length_in * sizeof(u32)); - std::span span(reinterpret_cast(read_buffer.data()), regs.line_length_in); - std::ranges::fill(span, regs.remap_const.remap_consta_value); - memory_manager.WriteBlockUnsafe(regs.offset_out, - reinterpret_cast(read_buffer.data()), - regs.line_length_in * sizeof(u32)); + const u32 component_size = regs.remap_const.component_size_minus_one + 1; + const u32 line_length = regs.line_length_in; + read_buffer.resize_destructive(line_length * component_size); + u8* buf = read_buffer.data(); + switch (component_size) { + case 1: { + std::span span(buf, line_length); + std::ranges::fill(span, static_cast(regs.remap_const.remap_consta_value & 0xFF)); + break; + } + case 2: { + std::span span(reinterpret_cast(buf), line_length); + std::ranges::fill(span, static_cast(regs.remap_const.remap_consta_value & 0xFFFF)); + break; + } + case 4: { + std::span span(reinterpret_cast(buf), line_length); + std::ranges::fill(span, regs.remap_const.remap_consta_value); + break; + } + default: + LOG_WARNING(Render_OpenGL, "Remap CONST_A with unsupported component size {} bytes", component_size); + break; + } + memory_manager.WriteBlockUnsafe(regs.offset_out, buf, line_length * component_size); + accelerate.BufferClear(regs.offset_out, line_length, regs.remap_const.remap_consta_value); } else { memory_manager.FlushCaching(); const auto convert_linear_2_blocklinear_addr = [](u64 address) {