Browse Source
shader: Implement NDC [-1, 1], attribute types and default varying initialization
nce_cpp
shader: Implement NDC [-1, 1], attribute types and default varying initialization
nce_cpp
committed by
ameerj
15 changed files with 186 additions and 43 deletions
-
1src/shader_recompiler/CMakeLists.txt
-
35src/shader_recompiler/backend/spirv/emit_context.cpp
-
10src/shader_recompiler/backend/spirv/emit_context.h
-
2src/shader_recompiler/backend/spirv/emit_spirv.h
-
63src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
-
35src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
-
8src/shader_recompiler/frontend/ir/ir_emitter.cpp
-
3src/shader_recompiler/frontend/ir/ir_emitter.h
-
2src/shader_recompiler/frontend/ir/microinstruction.cpp
-
4src/shader_recompiler/frontend/ir/opcodes.inc
-
7src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp
-
13src/shader_recompiler/profile.h
-
3src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
-
33src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
-
4src/video_core/renderer_vulkan/vk_pipeline_cache.h
@ -0,0 +1,35 @@ |
|||||
|
// Copyright 2021 yuzu Emulator Project
|
||||
|
// Licensed under GPLv2 or any later version
|
||||
|
// Refer to the license.txt file included.
|
||||
|
|
||||
|
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
||||
|
|
||||
|
namespace Shader::Backend::SPIRV { |
||||
|
|
||||
|
void EmitPrologue(EmitContext& ctx) { |
||||
|
if (ctx.stage == Stage::VertexB) { |
||||
|
const Id zero{ctx.Constant(ctx.F32[1], 0.0f)}; |
||||
|
const Id one{ctx.Constant(ctx.F32[1], 1.0f)}; |
||||
|
const Id null_vector{ctx.ConstantComposite(ctx.F32[4], zero, zero, zero, zero)}; |
||||
|
ctx.OpStore(ctx.output_position, ctx.ConstantComposite(ctx.F32[4], zero, zero, zero, one)); |
||||
|
for (const Id generic_id : ctx.output_generics) { |
||||
|
if (Sirit::ValidId(generic_id)) { |
||||
|
ctx.OpStore(generic_id, null_vector); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void EmitEpilogue(EmitContext& ctx) { |
||||
|
if (ctx.profile.convert_depth_mode) { |
||||
|
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); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} // namespace Shader::Backend::SPIRV
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue