Support reverse RGBA16F render targets

This commit is contained in:
nmzik
2026-07-17 12:54:28 +02:00
parent dd58deae15
commit 0abe03af94
13 changed files with 245 additions and 16 deletions
@@ -285,7 +285,8 @@ void ResolveRenderColorTarget(uint64_t submit_id, CommandBuffer* buffer, const H
mask = 0x0f;
}
r->target_slot = rt_slot;
r->target_slot = rt_slot;
r->export_mapping = {};
if (rt.base.addr == 0 || mask == 0) {
if (graphics_debug_dump_enabled()) {
@@ -479,6 +480,7 @@ void ResolveRenderColorTarget(uint64_t submit_id, CommandBuffer* buffer, const H
r->extent = view_extent;
r->base_mip_level = rt.view.current_mip_level;
r->buffer_size = backing_size;
r->export_mapping = rt_format.export_mapping;
} else {
const auto layout = static_cast<Prospero::ChannelLayout>(rt.info.format);
const auto type = static_cast<Prospero::ChannelType>(rt.info.channel_type);
@@ -82,10 +82,10 @@ PipelineCache::GraphicsPipeline* PipelineCache::CreateGraphicsPipeline(
const HW::BlendColor& bclr = ctx->GetBlendColor();
uint32_t color_mask[RENDER_COLOR_ATTACHMENTS_MAX] = {};
for (uint32_t i = 0; i < color_count; i++) {
color_mask[i] =
(colors[i].vulkan_buffer != nullptr
? render_target_mask_slot(ctx->GetRenderTargetMask(), colors[i].target_slot)
: 0);
color_mask[i] = (colors[i].vulkan_buffer != nullptr
? colors[i].export_mapping.ApplyMask(render_target_mask_slot(
ctx->GetRenderTargetMask(), colors[i].target_slot))
: 0);
}
const HW::ModeControl& mc = ctx->GetModeControl();
@@ -748,6 +748,12 @@ static void RefreshShaders(HW::Context* ctx, HW::Shader* sh_ctx, const DrawCallI
state->vs_shader = {};
state->ps_shader = {};
state->ps_input_info = {};
std::array<Prospero::ColorComponentMapping, RENDER_COLOR_ATTACHMENTS_MAX>
target_export_mapping {};
for (uint32_t i = 0; i < state->color_count; i++) {
target_export_mapping[state->color_info[i].target_slot] =
state->color_info[i].export_mapping;
}
EXIT_IF(g_render_ctx == nullptr || g_render_ctx->GetGraphicCtx() == nullptr);
const auto lane_mask_mode = SelectGraphicsLaneMaskMode(*g_render_ctx->GetGraphicCtx(), 64u);
@@ -766,7 +772,8 @@ static void RefreshShaders(HW::Context* ctx, HW::Shader* sh_ctx, const DrawCallI
LogDrawPhase(draw.name, "ShaderCompileInfoPS");
}
if (!ShaderCompileInfoPS(&pixel_shader_info, &shader_regs, lane_mask_mode,
&state->vs_input_info, &state->ps_input_info, &state->ps_shader)) {
&state->vs_input_info, target_export_mapping, &state->ps_input_info,
&state->ps_shader)) {
EXIT("ShaderCompileInfoPS failed for draw %s\n", draw.name);
}
}
@@ -4,6 +4,7 @@
#include "common/abi.h"
#include "common/assert.h"
#include "common/common.h"
#include "graphics/guest_gpu/gpu_defs.h"
#include <cstdint>
#include <string>
@@ -241,6 +242,7 @@ struct RenderColorInfo {
uint64_t base_addr = 0;
uint64_t buffer_size = 0;
uint32_t target_slot = 0;
Prospero::ColorComponentMapping export_mapping;
bool color_clear_enable = false;
VkClearColorValue color_clear_value {};
};