Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrigory Dzhavadyan <grigoryj@google.com>2018-10-30 09:31:32 +0300
committernicebyte <nicebyte@mailinator.com>2018-11-01 10:39:09 +0300
commita5d82d1138dd43ab4cd9351bf7d942e55eca0931 (patch)
tree633a6918dbe19a183b6d5c20634ac09cd9f58485 /reference/opt/shaders/comp
parentdfd1bf8c564f51534da2953fcd5b51840e9d7544 (diff)
Alter the handling of spec consts in non-Vulkan GLSL
Previously, when generating non-Vulkan GLSL, each use of a spec constant would be subsituted for its default value and the declaration of the constant itself would be omitted completely. This change slightly alters this behavior. The uses of the constant are kept, as well as the declaration, although the latter is stripped of the layout qualifier. The declaration is also prepended with the following code: #ifndef <constant name>_value #define <constant name> <default constant value> #endif and the constant itself now looks like const <constant type> <constant name> = <constant name>_value; The rationale for this change is that it gives the user a way to provide custom values for specialization constants even when the target does not support them.
Diffstat (limited to 'reference/opt/shaders/comp')
-rw-r--r--reference/opt/shaders/comp/composite-array-initialization.comp8
1 files changed, 7 insertions, 1 deletions
diff --git a/reference/opt/shaders/comp/composite-array-initialization.comp b/reference/opt/shaders/comp/composite-array-initialization.comp
index a47b64f1..6f5ea3a7 100644
--- a/reference/opt/shaders/comp/composite-array-initialization.comp
+++ b/reference/opt/shaders/comp/composite-array-initialization.comp
@@ -1,6 +1,12 @@
#version 310 es
layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in;
+#ifndef SPIRV_CROSS_CONSTANT_ID_0
+#define SPIRV_CROSS_CONSTANT_ID_0 4.0
+#endif
+const float X = SPIRV_CROSS_CONSTANT_ID_0;
+
+
struct Data
{
float a;
@@ -15,7 +21,7 @@ layout(binding = 0, std430) buffer SSBO
void main()
{
Data data[2] = Data[](Data(1.0, 2.0), Data(3.0, 4.0));
- Data data2[2] = Data[](Data(4.0, 2.0), Data(3.0, 5.0));
+ Data data2[2] = Data[](Data(X, 2.0), Data(3.0, 5.0));
_53.outdata[gl_WorkGroupID.x].a = data[gl_LocalInvocationID.x].a + data2[gl_LocalInvocationID.x].a;
_53.outdata[gl_WorkGroupID.x].b = data[gl_LocalInvocationID.x].b + data2[gl_LocalInvocationID.x].b;
}