mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 00:42:48 +00:00
disable clipping for rect lists, apply vport transform
This commit is contained in:
parent
092db6829f
commit
b6f2ce34e0
@ -31,10 +31,30 @@ void ConvertPositionToClipSpace(EmitContext& ctx) {
|
|||||||
const Id y{ctx.OpCompositeExtract(type, position, 1u)};
|
const Id y{ctx.OpCompositeExtract(type, position, 1u)};
|
||||||
const Id z{ctx.OpCompositeExtract(type, position, 2u)};
|
const Id z{ctx.OpCompositeExtract(type, position, 2u)};
|
||||||
const Id w{ctx.OpCompositeExtract(type, position, 3u)};
|
const Id w{ctx.OpCompositeExtract(type, position, 3u)};
|
||||||
const Id ndc_x{ctx.OpFSub(type, ctx.OpFDiv(type, x, ctx.Constant(type, float(8_KB))),
|
const Id xoffset_ptr{ctx.OpAccessChain(ctx.TypePointer(spv::StorageClass::PushConstant, type),
|
||||||
ctx.Constant(type, 1.f))};
|
ctx.push_data_block,
|
||||||
const Id ndc_y{ctx.OpFSub(type, ctx.OpFDiv(type, y, ctx.Constant(type, float(8_KB))),
|
ctx.ConstU32(PushData::XOffsetIndex))};
|
||||||
ctx.Constant(type, 1.f))};
|
const Id xoffset{ctx.OpLoad(type, xoffset_ptr)};
|
||||||
|
const Id yoffset_ptr{ctx.OpAccessChain(ctx.TypePointer(spv::StorageClass::PushConstant, type),
|
||||||
|
ctx.push_data_block,
|
||||||
|
ctx.ConstU32(PushData::YOffsetIndex))};
|
||||||
|
const Id yoffset{ctx.OpLoad(type, yoffset_ptr)};
|
||||||
|
const Id xscale_ptr{ctx.OpAccessChain(ctx.TypePointer(spv::StorageClass::PushConstant, type),
|
||||||
|
ctx.push_data_block,
|
||||||
|
ctx.ConstU32(PushData::XScaleIndex))};
|
||||||
|
const Id xscale{ctx.OpLoad(type, xscale_ptr)};
|
||||||
|
const Id yscale_ptr{ctx.OpAccessChain(ctx.TypePointer(spv::StorageClass::PushConstant, type),
|
||||||
|
ctx.push_data_block,
|
||||||
|
ctx.ConstU32(PushData::YScaleIndex))};
|
||||||
|
const Id yscale{ctx.OpLoad(type, yscale_ptr)};
|
||||||
|
Id ndc_x = ctx.OpFMul(type, x, xscale);
|
||||||
|
ndc_x = ctx.OpFAdd(type, ndc_x, xoffset);
|
||||||
|
ndc_x = ctx.OpFDiv(type, ndc_x, ctx.Constant(type, float(8_KB)));
|
||||||
|
ndc_x = ctx.OpFSub(type, ndc_x, ctx.Constant(type, 1.f));
|
||||||
|
Id ndc_y = ctx.OpFMul(type, y, yscale);
|
||||||
|
ndc_y = ctx.OpFAdd(type, ndc_y, yoffset);
|
||||||
|
ndc_y = ctx.OpFDiv(type, ndc_y, ctx.Constant(type, float(8_KB)));
|
||||||
|
ndc_y = ctx.OpFSub(type, ndc_y, ctx.Constant(type, 1.f));
|
||||||
const Id vector{ctx.OpCompositeConstruct(ctx.F32[4], std::array<Id, 4>({ndc_x, ndc_y, z, w}))};
|
const Id vector{ctx.OpCompositeConstruct(ctx.F32[4], std::array<Id, 4>({ndc_x, ndc_y, z, w}))};
|
||||||
ctx.OpStore(ctx.output_position, vector);
|
ctx.OpStore(ctx.output_position, vector);
|
||||||
}
|
}
|
||||||
|
@ -568,25 +568,34 @@ void EmitContext::DefineOutputs() {
|
|||||||
|
|
||||||
void EmitContext::DefinePushDataBlock() {
|
void EmitContext::DefinePushDataBlock() {
|
||||||
// Create push constants block for instance steps rates
|
// Create push constants block for instance steps rates
|
||||||
const Id struct_type{Name(
|
const Id struct_type{Name(TypeStruct(U32[1], U32[1], U32[4], U32[4], U32[4], U32[4], U32[4],
|
||||||
TypeStruct(U32[1], U32[1], U32[4], U32[4], U32[4], U32[4], U32[4], U32[4]), "AuxData")};
|
U32[4], F32[1], F32[1], F32[1], F32[1]),
|
||||||
|
"AuxData")};
|
||||||
Decorate(struct_type, spv::Decoration::Block);
|
Decorate(struct_type, spv::Decoration::Block);
|
||||||
MemberName(struct_type, 0, "sr0");
|
MemberName(struct_type, 0, "sr0");
|
||||||
MemberName(struct_type, 1, "sr1");
|
MemberName(struct_type, 1, "sr1");
|
||||||
MemberName(struct_type, 2, "buf_offsets0");
|
MemberName(struct_type, Shader::PushData::BufOffsetIndex + 0, "buf_offsets0");
|
||||||
MemberName(struct_type, 3, "buf_offsets1");
|
MemberName(struct_type, Shader::PushData::BufOffsetIndex + 1, "buf_offsets1");
|
||||||
MemberName(struct_type, 4, "ud_regs0");
|
MemberName(struct_type, Shader::PushData::UdRegsIndex + 0, "ud_regs0");
|
||||||
MemberName(struct_type, 5, "ud_regs1");
|
MemberName(struct_type, Shader::PushData::UdRegsIndex + 1, "ud_regs1");
|
||||||
MemberName(struct_type, 6, "ud_regs2");
|
MemberName(struct_type, Shader::PushData::UdRegsIndex + 2, "ud_regs2");
|
||||||
MemberName(struct_type, 7, "ud_regs3");
|
MemberName(struct_type, Shader::PushData::UdRegsIndex + 3, "ud_regs3");
|
||||||
|
MemberName(struct_type, Shader::PushData::XOffsetIndex, "xoffset");
|
||||||
|
MemberName(struct_type, Shader::PushData::YOffsetIndex, "yoffset");
|
||||||
|
MemberName(struct_type, Shader::PushData::XScaleIndex, "xscale");
|
||||||
|
MemberName(struct_type, Shader::PushData::YScaleIndex, "yscale");
|
||||||
MemberDecorate(struct_type, 0, spv::Decoration::Offset, 0U);
|
MemberDecorate(struct_type, 0, spv::Decoration::Offset, 0U);
|
||||||
MemberDecorate(struct_type, 1, spv::Decoration::Offset, 4U);
|
MemberDecorate(struct_type, 1, spv::Decoration::Offset, 4U);
|
||||||
MemberDecorate(struct_type, 2, spv::Decoration::Offset, 8U);
|
MemberDecorate(struct_type, Shader::PushData::BufOffsetIndex + 0, spv::Decoration::Offset, 8U);
|
||||||
MemberDecorate(struct_type, 3, spv::Decoration::Offset, 24U);
|
MemberDecorate(struct_type, Shader::PushData::BufOffsetIndex + 1, spv::Decoration::Offset, 24U);
|
||||||
MemberDecorate(struct_type, 4, spv::Decoration::Offset, 40U);
|
MemberDecorate(struct_type, Shader::PushData::UdRegsIndex + 0, spv::Decoration::Offset, 40U);
|
||||||
MemberDecorate(struct_type, 5, spv::Decoration::Offset, 56U);
|
MemberDecorate(struct_type, Shader::PushData::UdRegsIndex + 1, spv::Decoration::Offset, 56U);
|
||||||
MemberDecorate(struct_type, 6, spv::Decoration::Offset, 72U);
|
MemberDecorate(struct_type, Shader::PushData::UdRegsIndex + 2, spv::Decoration::Offset, 72U);
|
||||||
MemberDecorate(struct_type, 7, spv::Decoration::Offset, 88U);
|
MemberDecorate(struct_type, Shader::PushData::UdRegsIndex + 3, spv::Decoration::Offset, 88U);
|
||||||
|
MemberDecorate(struct_type, Shader::PushData::XOffsetIndex, spv::Decoration::Offset, 104U);
|
||||||
|
MemberDecorate(struct_type, Shader::PushData::YOffsetIndex, spv::Decoration::Offset, 108U);
|
||||||
|
MemberDecorate(struct_type, Shader::PushData::XScaleIndex, spv::Decoration::Offset, 112U);
|
||||||
|
MemberDecorate(struct_type, Shader::PushData::YScaleIndex, spv::Decoration::Offset, 116U);
|
||||||
push_data_block = DefineVar(struct_type, spv::StorageClass::PushConstant);
|
push_data_block = DefineVar(struct_type, spv::StorageClass::PushConstant);
|
||||||
Name(push_data_block, "push_data");
|
Name(push_data_block, "push_data");
|
||||||
interfaces.push_back(push_data_block);
|
interfaces.push_back(push_data_block);
|
||||||
|
@ -96,11 +96,19 @@ using FMaskResourceList = boost::container::small_vector<FMaskResource, 16>;
|
|||||||
struct PushData {
|
struct PushData {
|
||||||
static constexpr u32 BufOffsetIndex = 2;
|
static constexpr u32 BufOffsetIndex = 2;
|
||||||
static constexpr u32 UdRegsIndex = 4;
|
static constexpr u32 UdRegsIndex = 4;
|
||||||
|
static constexpr u32 XOffsetIndex = 8;
|
||||||
|
static constexpr u32 YOffsetIndex = 9;
|
||||||
|
static constexpr u32 XScaleIndex = 10;
|
||||||
|
static constexpr u32 YScaleIndex = 11;
|
||||||
|
|
||||||
u32 step0;
|
u32 step0;
|
||||||
u32 step1;
|
u32 step1;
|
||||||
std::array<u8, 32> buf_offsets;
|
std::array<u8, 32> buf_offsets;
|
||||||
std::array<u32, NumUserDataRegs> ud_regs;
|
std::array<u32, NumUserDataRegs> ud_regs;
|
||||||
|
float xoffset;
|
||||||
|
float yoffset;
|
||||||
|
float xscale;
|
||||||
|
float yscale;
|
||||||
|
|
||||||
void AddOffset(u32 binding, u32 offset) {
|
void AddOffset(u32 binding, u32 offset) {
|
||||||
ASSERT(offset < 256 && binding < buf_offsets.size());
|
ASSERT(offset < 256 && binding < buf_offsets.size());
|
||||||
|
@ -262,15 +262,8 @@ bool PipelineCache::RefreshGraphicsKey() {
|
|||||||
auto& regs = liverpool->regs;
|
auto& regs = liverpool->regs;
|
||||||
auto& key = graphics_key;
|
auto& key = graphics_key;
|
||||||
|
|
||||||
const auto& vp_ctl = regs.viewport_control;
|
key.clip_disable =
|
||||||
|
regs.clipper_control.clip_disable || regs.primitive_type == AmdGpu::PrimitiveType::RectList;
|
||||||
// TODO(roamic): the statement below needs verification with a sample on the real HW.
|
|
||||||
// If there is no defined transform to convert from clip space to screen space we assume that
|
|
||||||
// clipping is also disabled.
|
|
||||||
const bool viewport_disabled = !vp_ctl.xoffset_enable && !vp_ctl.xscale_enable &&
|
|
||||||
!vp_ctl.yoffset_enable && !vp_ctl.yscale_enable &&
|
|
||||||
!vp_ctl.zoffset_enable && !vp_ctl.zscale_enable;
|
|
||||||
key.clip_disable = regs.clipper_control.clip_disable || viewport_disabled;
|
|
||||||
key.depth_test_enable = regs.depth_control.depth_enable;
|
key.depth_test_enable = regs.depth_control.depth_enable;
|
||||||
key.depth_write_enable =
|
key.depth_write_enable =
|
||||||
regs.depth_control.depth_write_enable && !regs.depth_render_control.depth_clear_enable;
|
regs.depth_control.depth_write_enable && !regs.depth_render_control.depth_clear_enable;
|
||||||
|
@ -504,6 +504,10 @@ bool Rasterizer::BindResources(const Pipeline* pipeline) {
|
|||||||
}
|
}
|
||||||
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;
|
||||||
|
push_data.xoffset = regs.viewport_control.xoffset_enable ? regs.viewports[0].xoffset : 0.f;
|
||||||
|
push_data.xscale = regs.viewport_control.xscale_enable ? regs.viewports[0].xscale : 1.f;
|
||||||
|
push_data.yoffset = regs.viewport_control.yoffset_enable ? regs.viewports[0].yoffset : 0.f;
|
||||||
|
push_data.yscale = regs.viewport_control.yscale_enable ? regs.viewports[0].yscale : 1.f;
|
||||||
stage->PushUd(binding, push_data);
|
stage->PushUd(binding, push_data);
|
||||||
|
|
||||||
BindBuffers(*stage, binding, push_data, set_writes, buffer_barriers);
|
BindBuffers(*stage, binding, push_data, set_writes, buffer_barriers);
|
||||||
|
Loading…
Reference in New Issue
Block a user