From 8ebffc1018173903b4bfaf41561fb9bd2b006f74 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 15 Feb 2018 18:07:40 +0100 Subject: [PATCH] [dxbc] Added support for SV_RenderTargetID in pixel shaders --- src/dxbc/dxbc_compiler.cpp | 20 ++++++++++++++++++-- src/dxbc/dxbc_compiler.h | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index cfa1a835..82fd891a 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -4570,8 +4570,24 @@ namespace dxvk { ptrIn.type.ccount = 1; ptrIn.id = m_ps.builtinSampleId; - return emitRegisterExtract( - emitValueLoad(ptrIn), mask); + return emitValueLoad(ptrIn); + } break; + + case DxbcSystemValue::RenderTargetId: { + if (m_ps.builtinLayer == 0) { + m_ps.builtinLayer = emitNewBuiltinVariable({ + { DxbcScalarType::Uint32, 1, 0 }, + spv::StorageClassInput }, + spv::BuiltInLayer, + "ps_layer"); + } + + DxbcRegisterPointer ptr; + ptr.type.ctype = DxbcScalarType::Uint32; + ptr.type.ccount = 1; + ptr.id = m_ps.builtinLayer; + + return emitValueLoad(ptr); } break; default: diff --git a/src/dxbc/dxbc_compiler.h b/src/dxbc/dxbc_compiler.h index 6c42abfe..1b98da76 100644 --- a/src/dxbc/dxbc_compiler.h +++ b/src/dxbc/dxbc_compiler.h @@ -117,7 +117,7 @@ namespace dxvk { uint32_t outputVertexCount = 0; uint32_t functionId = 0; - uint32_t builtinLayer = 0; + uint32_t builtinLayer = 0; }; @@ -133,6 +133,7 @@ namespace dxvk { uint32_t builtinSampleId = 0; uint32_t builtinSampleMaskIn = 0; uint32_t builtinSampleMaskOut = 0; + uint32_t builtinLayer = 0; std::array oTypes; };