mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
Support reverse RGBA16F render targets
This commit is contained in:
@@ -50,6 +50,23 @@ uint32_t EmitExportVec4F32(EmitterState* state, const IR::Instruction& inst) {
|
||||
return vec;
|
||||
}
|
||||
|
||||
uint32_t ApplyMrtExportMapping(EmitterState* state, const IR::Instruction& inst, uint32_t value) {
|
||||
if (inst.export_info.kind != IR::ExportTargetKind::Mrt || state->pixel_input_info == nullptr ||
|
||||
inst.export_info.index >= state->pixel_input_info->target_export_mapping.size()) {
|
||||
return value;
|
||||
}
|
||||
|
||||
const auto mapping = state->pixel_input_info->target_export_mapping[inst.export_info.index];
|
||||
if (mapping.IsIdentity()) {
|
||||
return value;
|
||||
}
|
||||
|
||||
const auto mapped = state->builder.AllocateId();
|
||||
state->builder.AddFunction({OpVectorShuffle, state->vec4_float_type, mapped, value, value,
|
||||
mapping.Map(0), mapping.Map(1), mapping.Map(2), mapping.Map(3)});
|
||||
return mapped;
|
||||
}
|
||||
|
||||
bool ExportWritesData(const IR::Instruction& inst) {
|
||||
switch (inst.export_info.kind) {
|
||||
case IR::ExportTargetKind::Null:
|
||||
@@ -97,7 +114,7 @@ void EmitExport(EmitterState* state, const IR::Instruction& inst) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto value = EmitExportVec4F32(state, inst);
|
||||
const auto value = ApplyMrtExportMapping(state, inst, EmitExportVec4F32(state, inst));
|
||||
if (inst.export_info.kind == IR::ExportTargetKind::Position) {
|
||||
const auto pointer = state->builder.AllocateId();
|
||||
state->builder.AddFunction({OpAccessChain, state->ptr_output_vec4_float, pointer, variable,
|
||||
|
||||
@@ -135,6 +135,7 @@ enum : uint32_t {
|
||||
OpArrayLength = 68,
|
||||
OpDecorate = 71,
|
||||
OpMemberDecorate = 72,
|
||||
OpVectorShuffle = 79,
|
||||
OpCompositeConstruct = 80,
|
||||
OpCompositeExtract = 81,
|
||||
OpSampledImage = 86,
|
||||
|
||||
@@ -791,10 +791,11 @@ static bool ShaderGetStaticInputInfoVS(const HW::VertexShaderInfo* regs,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ShaderGetStaticInputInfoPS(const HW::PixelShaderInfo* regs,
|
||||
const HW::ShaderRegisters* sh,
|
||||
const ShaderVertexInputInfo* vs_info,
|
||||
ShaderPixelInputInfo* ps_info) {
|
||||
static void ShaderGetStaticInputInfoPS(
|
||||
const HW::PixelShaderInfo* regs, const HW::ShaderRegisters* sh,
|
||||
const ShaderVertexInputInfo* vs_info,
|
||||
std::span<const Prospero::ColorComponentMapping, 8> target_export_mapping,
|
||||
ShaderPixelInputInfo* ps_info) {
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
|
||||
EXIT_IF(vs_info == nullptr);
|
||||
@@ -834,6 +835,9 @@ static void ShaderGetStaticInputInfoPS(const HW::PixelShaderInfo* regs,
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ps_info->target_output_mode[i] = sh->target_output_mode[i];
|
||||
ps_info->target_export_mapping[i] =
|
||||
sh->target_output_mode[i] != 0 ? target_export_mapping[i]
|
||||
: Prospero::ColorComponentMapping {};
|
||||
}
|
||||
ps_info->mrt_output_mask = 0;
|
||||
}
|
||||
@@ -1105,11 +1109,12 @@ bool ShaderCompileInfoVS(const HW::VertexShaderInfo* regs, const HW::ShaderRegis
|
||||
|
||||
bool ShaderCompileInfoPS(const HW::PixelShaderInfo* regs, const HW::ShaderRegisters* sh,
|
||||
ShaderLaneMaskMode lane_mask_mode, const ShaderVertexInputInfo* vs_info,
|
||||
std::span<const Prospero::ColorComponentMapping, 8> target_export_mapping,
|
||||
ShaderPixelInputInfo* ps_info, std::span<const uint32_t>* spirv) {
|
||||
EXIT_IF(spirv == nullptr);
|
||||
*spirv = {};
|
||||
|
||||
ShaderGetStaticInputInfoPS(regs, sh, vs_info, ps_info);
|
||||
ShaderGetStaticInputInfoPS(regs, sh, vs_info, target_export_mapping, ps_info);
|
||||
const auto shader_hash =
|
||||
regs->ps_regs.chksum != 0 ? regs->ps_regs.chksum : regs->ps_regs.data_addr;
|
||||
const auto program_id = ShaderGetIdPS(regs, ps_info, false);
|
||||
@@ -1632,6 +1637,14 @@ ShaderId ShaderGetIdPS(const HW::PixelShaderInfo* regs, const ShaderPixelInputIn
|
||||
for (auto mode: input_info->target_output_mode) {
|
||||
ret.ids.push_back(mode);
|
||||
}
|
||||
for (uint32_t base = 0; base < input_info->target_export_mapping.size(); base += 4u) {
|
||||
uint32_t packed = 0;
|
||||
for (uint32_t i = 0; i < 4u; i++) {
|
||||
packed |= static_cast<uint32_t>(input_info->target_export_mapping[base + i].packed)
|
||||
<< (i * 8u);
|
||||
}
|
||||
ret.ids.push_back(packed);
|
||||
}
|
||||
ret.ids.push_back(input_info->mrt_output_mask);
|
||||
|
||||
for (uint32_t i = 0; i < input_info->input_num; i++) {
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
|
||||
#include "common/abi.h"
|
||||
#include "common/common.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/shader/shaderBindings.h"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
@@ -98,6 +100,7 @@ struct ShaderPixelInputInfo {
|
||||
uint32_t input_num = 0;
|
||||
uint32_t ps_system_input_base = 0;
|
||||
uint8_t target_output_mode[8] = {};
|
||||
std::array<Prospero::ColorComponentMapping, 8> target_export_mapping = {};
|
||||
uint32_t mrt_output_mask = 0;
|
||||
uint32_t descriptor_set = 0;
|
||||
bool ps_pos_x = false;
|
||||
@@ -227,6 +230,7 @@ bool ShaderCompileInfoVS(const HW::VertexShaderInfo* regs, const HW::ShaderRegis
|
||||
std::span<const uint32_t>* spirv);
|
||||
bool ShaderCompileInfoPS(const HW::PixelShaderInfo* regs, const HW::ShaderRegisters* sh,
|
||||
ShaderLaneMaskMode lane_mask_mode, const ShaderVertexInputInfo* vs_info,
|
||||
std::span<const Prospero::ColorComponentMapping, 8> target_export_mapping,
|
||||
ShaderPixelInputInfo* input_info, std::span<const uint32_t>* spirv);
|
||||
bool ShaderCompileInfoCS(const HW::ComputeShaderInfo* regs, const HW::ShaderRegisters* sh,
|
||||
ShaderComputeInputInfo* input_info, std::span<const uint32_t>* spirv);
|
||||
|
||||
Reference in New Issue
Block a user