mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-21 02:45:00 +00:00
vulkan: Emulate depth clip control when extension is not available. (#762)
This commit is contained in:
parent
e340583a7f
commit
b87e6f3838
7 changed files with 38 additions and 12 deletions
|
@ -10,7 +10,21 @@ void EmitPrologue(EmitContext& ctx) {
|
|||
ctx.DefineBufferOffsets();
|
||||
}
|
||||
|
||||
void EmitEpilogue(EmitContext& ctx) {}
|
||||
void ConvertDepthMode(EmitContext& ctx) {
|
||||
const Id type{ctx.F32[1]};
|
||||
const Id position{ctx.OpLoad(ctx.F32[4], ctx.output_position)};
|
||||
const Id z{ctx.OpCompositeExtract(type, position, 2u)};
|
||||
const Id w{ctx.OpCompositeExtract(type, position, 3u)};
|
||||
const Id screen_depth{ctx.OpFMul(type, ctx.OpFAdd(type, z, w), ctx.Constant(type, 0.5f))};
|
||||
const Id vector{ctx.OpCompositeInsert(ctx.F32[4], screen_depth, position, 2u)};
|
||||
ctx.OpStore(ctx.output_position, vector);
|
||||
}
|
||||
|
||||
void EmitEpilogue(EmitContext& ctx) {
|
||||
if (ctx.stage == Stage::Vertex && ctx.runtime_info.vs_info.emulate_depth_negative_one_to_one) {
|
||||
ConvertDepthMode(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void EmitDiscard(EmitContext& ctx) {
|
||||
ctx.OpDemoteToHelperInvocationEXT();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue