From ba0d9d33d4f3038e3a07022619f00599eff099e8 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 24 Jun 2015 20:29:33 -0700 Subject: [PATCH] nir/spirv: Add support for some more decorations including built-in --- src/glsl/nir/spirv_to_nir.c | 71 +++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 1fc1b8bc5dc..dcb94fc43c2 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -415,6 +415,74 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, var->data.explicit_binding = true; var->data.binding = dec->literals[0]; break; + case SpvDecorationDescriptorSet: + var->data.descriptor_set = dec->literals[0]; + break; + case SpvDecorationBuiltIn: + var->data.read_only = true; + switch ((SpvBuiltIn)dec->literals[0]) { + case SpvBuiltInFrontFacing: + var->data.location = SYSTEM_VALUE_FRONT_FACE; + break; + case SpvBuiltInVertexId: + var->data.location = SYSTEM_VALUE_VERTEX_ID; + break; + case SpvBuiltInInstanceId: + var->data.location = SYSTEM_VALUE_INSTANCE_ID; + break; + case SpvBuiltInSampleId: + var->data.location = SYSTEM_VALUE_SAMPLE_ID; + break; + case SpvBuiltInSamplePosition: + var->data.location = SYSTEM_VALUE_SAMPLE_POS; + break; + case SpvBuiltInSampleMask: + var->data.location = SYSTEM_VALUE_SAMPLE_MASK_IN; + break; + case SpvBuiltInInvocationId: + var->data.location = SYSTEM_VALUE_INVOCATION_ID; + break; + case SpvBuiltInPrimitiveId: + case SpvBuiltInPosition: + case SpvBuiltInPointSize: + case SpvBuiltInClipVertex: + case SpvBuiltInClipDistance: + case SpvBuiltInCullDistance: + case SpvBuiltInLayer: + case SpvBuiltInViewportIndex: + case SpvBuiltInTessLevelOuter: + case SpvBuiltInTessLevelInner: + case SpvBuiltInTessCoord: + case SpvBuiltInPatchVertices: + case SpvBuiltInFragCoord: + case SpvBuiltInPointCoord: + case SpvBuiltInFragColor: + case SpvBuiltInFragDepth: + case SpvBuiltInHelperInvocation: + case SpvBuiltInNumWorkgroups: + case SpvBuiltInWorkgroupSize: + case SpvBuiltInWorkgroupId: + case SpvBuiltInLocalInvocationId: + case SpvBuiltInGlobalInvocationId: + case SpvBuiltInLocalInvocationIndex: + case SpvBuiltInWorkDim: + case SpvBuiltInGlobalSize: + case SpvBuiltInEnqueuedWorkgroupSize: + case SpvBuiltInGlobalOffset: + case SpvBuiltInGlobalLinearId: + case SpvBuiltInWorkgroupLinearId: + case SpvBuiltInSubgroupSize: + case SpvBuiltInSubgroupMaxSize: + case SpvBuiltInNumSubgroups: + case SpvBuiltInNumEnqueuedSubgroups: + case SpvBuiltInSubgroupId: + case SpvBuiltInSubgroupLocalInvocationId: + unreachable("Unhandled builtin enum"); + } + break; + case SpvDecorationNoStaticUse: + /* This can safely be ignored */ + break; case SpvDecorationBlock: case SpvDecorationBufferBlock: case SpvDecorationRowMajor: @@ -431,16 +499,13 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, case SpvDecorationNonreadable: case SpvDecorationUniform: /* This is really nice but we have no use for it right now. */ - case SpvDecorationNoStaticUse: case SpvDecorationCPacked: case SpvDecorationSaturatedConversion: case SpvDecorationStream: - case SpvDecorationDescriptorSet: case SpvDecorationOffset: case SpvDecorationAlignment: case SpvDecorationXfbBuffer: case SpvDecorationStride: - case SpvDecorationBuiltIn: case SpvDecorationFuncParamAttr: case SpvDecorationFPRoundingMode: case SpvDecorationFPFastMathMode: -- 2.30.2