diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 55 | ||||
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 12 |
2 files changed, 67 insertions, 0 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index a9280d9ad..adbe6f9c8 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -1805,6 +1805,61 @@ matrix<T, N, M> fwidth(matrix<T, N, M> x) MATRIX_MAP_UNARY(T, N, M, fwidth, x); } +/// Get the value of a vertex attribute at a specific vertex. +/// +/// The `GetAttributeAtVertex()` function can be used in a fragment shader +/// to get the value of the given `attribute` at the vertex of the primitive +/// that corresponds to the given `vertexIndex`. +/// +/// Note that the `attribute` must have been a declared varying input to +/// the fragment shader with the `nointerpolation` modifier. +/// +/// This function can be applied to scalars, vectors, and matrices of +/// built-in scalar types. +/// +/// Note: these functions are not curently implemented for Vulkan/SPIR-V output. +/// +__generic<T : __BuiltinType> +[__readNone] +T GetAttributeAtVertex(T attribute, uint vertexIndex); + +/// Get the value of a vertex attribute at a specific vertex. +/// +/// The `GetAttributeAtVertex()` function can be used in a fragment shader +/// to get the value of the given `attribute` at the vertex of the primitive +/// that corresponds to the given `vertexIndex`. +/// +/// Note that the `attribute` must have been a declared varying input to +/// the fragment shader with the `nointerpolation` modifier. +/// +/// This function can be applied to scalars, vectors, and matrices of +/// built-in scalar types. +/// +/// Note: these functions are not curently implemented for Vulkan/SPIR-V output. +/// +__generic<T : __BuiltinType, let N : int> +[__readNone] +vector<T,N> GetAttributeAtVertex(vector<T,N> attribute, uint vertexIndex); + +/// Get the value of a vertex attribute at a specific vertex. +/// +/// The `GetAttributeAtVertex()` function can be used in a fragment shader +/// to get the value of the given `attribute` at the vertex of the primitive +/// that corresponds to the given `vertexIndex`. +/// +/// Note that the `attribute` must have been a declared varying input to +/// the fragment shader with the `nointerpolation` modifier. +/// +/// This function can be applied to scalars, vectors, and matrices of +/// built-in scalar types. +/// +/// Note: these functions are not curently implemented for Vulkan/SPIR-V output. +/// +__generic<T : __BuiltinType, let N : int, let M : int> +[__readNone] +matrix<T,N,M> GetAttributeAtVertex(matrix<T,N,M> attribute, uint vertexIndex); + + // Get number of samples in render target uint GetRenderTargetSampleCount(); diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 0bd6efad3..d099af255 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -2663,6 +2663,18 @@ void CLikeSourceEmitter::emitSimpleFuncParamImpl(IRParam* param) auto paramName = getName(param); auto paramType = param->getDataType(); + if(auto layoutDecoration = param->findDecoration<IRLayoutDecoration>() ) + { + auto layout = as<IRVarLayout>(layoutDecoration->getLayout()); + SLANG_ASSERT(layout); + + if(layout->usesResourceKind(LayoutResourceKind::VaryingInput) + || layout->usesResourceKind(LayoutResourceKind::VaryingOutput)) + { + emitInterpolationModifiers(param, paramType, layout); + } + } + emitParamType(paramType, paramName); emitSemantics(param); } |
