-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2391 from KhronosGroup/hlsl-barycentrics
HLSL: Implement SV_Barycentrics.
- Loading branch information
Showing
12 changed files
with
285 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#version 450 | ||
#extension GL_EXT_fragment_shader_barycentric : require | ||
|
||
layout(location = 0) out vec2 value; | ||
layout(location = 0) pervertexEXT in vec2 vUV[3]; | ||
layout(location = 1) pervertexEXT in vec2 vUV2[3]; | ||
layout(location = 2) pervertexEXT in Foo | ||
{ | ||
vec2 a; | ||
vec2 b; | ||
} foo[3]; | ||
|
||
|
||
void main() | ||
{ | ||
value = ((vUV[0] * gl_BaryCoordEXT.x) + (vUV[1] * gl_BaryCoordEXT.y)) + (vUV[2] * gl_BaryCoordEXT.z); | ||
value += (((vUV2[0] * gl_BaryCoordNoPerspEXT.x) + (vUV2[1] * gl_BaryCoordNoPerspEXT.y)) + (vUV2[2] * gl_BaryCoordNoPerspEXT.z)); | ||
value += (foo[0].a * gl_BaryCoordEXT.x); | ||
value += (foo[0].b * gl_BaryCoordEXT.y); | ||
value += (foo[1].a * gl_BaryCoordEXT.z); | ||
value += (foo[1].b * gl_BaryCoordEXT.x); | ||
value += (foo[2].a * gl_BaryCoordEXT.y); | ||
value += (foo[2].b * gl_BaryCoordEXT.z); | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
reference/shaders-hlsl-no-opt/frag/barycentric-khr-nopersp.sm61.fxconly.nofxc.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
static float3 gl_BaryCoordNoPerspEXT; | ||
static float2 value; | ||
static float2 vUV2[3]; | ||
|
||
struct SPIRV_Cross_Input | ||
{ | ||
nointerpolation float2 vUV2 : TEXCOORD1; | ||
noperspective float3 gl_BaryCoordNoPerspEXT : SV_Barycentrics; | ||
}; | ||
|
||
struct SPIRV_Cross_Output | ||
{ | ||
float2 value : SV_Target0; | ||
}; | ||
|
||
void frag_main() | ||
{ | ||
value = ((vUV2[0] * gl_BaryCoordNoPerspEXT.x) + (vUV2[1] * gl_BaryCoordNoPerspEXT.y)) + (vUV2[2] * gl_BaryCoordNoPerspEXT.z); | ||
} | ||
|
||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) | ||
{ | ||
gl_BaryCoordNoPerspEXT = stage_input.gl_BaryCoordNoPerspEXT; | ||
vUV2[0] = GetAttributeAtVertex(stage_input.vUV2, 0); | ||
vUV2[1] = GetAttributeAtVertex(stage_input.vUV2, 1); | ||
vUV2[2] = GetAttributeAtVertex(stage_input.vUV2, 2); | ||
frag_main(); | ||
SPIRV_Cross_Output stage_output; | ||
stage_output.value = value; | ||
return stage_output; | ||
} |
31 changes: 31 additions & 0 deletions
31
reference/shaders-hlsl-no-opt/frag/barycentric-khr-persp.sm61.fxconly.nofxc.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
static float3 gl_BaryCoordEXT; | ||
static float2 value; | ||
static float2 vUV[3]; | ||
|
||
struct SPIRV_Cross_Input | ||
{ | ||
nointerpolation float2 vUV : TEXCOORD0; | ||
float3 gl_BaryCoordEXT : SV_Barycentrics; | ||
}; | ||
|
||
struct SPIRV_Cross_Output | ||
{ | ||
float2 value : SV_Target0; | ||
}; | ||
|
||
void frag_main() | ||
{ | ||
value = ((vUV[0] * gl_BaryCoordEXT.x) + (vUV[1] * gl_BaryCoordEXT.y)) + (vUV[2] * gl_BaryCoordEXT.z); | ||
} | ||
|
||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) | ||
{ | ||
gl_BaryCoordEXT = stage_input.gl_BaryCoordEXT; | ||
vUV[0] = GetAttributeAtVertex(stage_input.vUV, 0); | ||
vUV[1] = GetAttributeAtVertex(stage_input.vUV, 1); | ||
vUV[2] = GetAttributeAtVertex(stage_input.vUV, 2); | ||
frag_main(); | ||
SPIRV_Cross_Output stage_output; | ||
stage_output.value = value; | ||
return stage_output; | ||
} |
61 changes: 61 additions & 0 deletions
61
reference/shaders-hlsl-no-opt/frag/barycentric-khr.sm61.fxconly.nofxc.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
struct Foo | ||
{ | ||
float2 a; | ||
float2 b; | ||
}; | ||
|
||
static float3 gl_BaryCoordEXT; | ||
static float3 gl_BaryCoordNoPerspEXT; | ||
static float2 value; | ||
static float2 vUV[3]; | ||
static float2 vUV2[3]; | ||
static Foo foo[3]; | ||
|
||
struct SPIRV_Cross_Input | ||
{ | ||
nointerpolation float2 vUV : TEXCOORD0; | ||
nointerpolation float2 vUV2 : TEXCOORD1; | ||
nointerpolation float2 Foo_a : TEXCOORD2; | ||
nointerpolation float2 Foo_b : TEXCOORD3; | ||
float3 gl_BaryCoordEXT : SV_Barycentrics0; | ||
noperspective float3 gl_BaryCoordNoPerspEXT : SV_Barycentrics1; | ||
}; | ||
|
||
struct SPIRV_Cross_Output | ||
{ | ||
float2 value : SV_Target0; | ||
}; | ||
|
||
void frag_main() | ||
{ | ||
value = ((vUV[0] * gl_BaryCoordEXT.x) + (vUV[1] * gl_BaryCoordEXT.y)) + (vUV[2] * gl_BaryCoordEXT.z); | ||
value += (((vUV2[0] * gl_BaryCoordNoPerspEXT.x) + (vUV2[1] * gl_BaryCoordNoPerspEXT.y)) + (vUV2[2] * gl_BaryCoordNoPerspEXT.z)); | ||
value += (foo[0].a * gl_BaryCoordEXT.x); | ||
value += (foo[0].b * gl_BaryCoordEXT.y); | ||
value += (foo[1].a * gl_BaryCoordEXT.z); | ||
value += (foo[1].b * gl_BaryCoordEXT.x); | ||
value += (foo[2].a * gl_BaryCoordEXT.y); | ||
value += (foo[2].b * gl_BaryCoordEXT.z); | ||
} | ||
|
||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) | ||
{ | ||
gl_BaryCoordEXT = stage_input.gl_BaryCoordEXT; | ||
gl_BaryCoordNoPerspEXT = stage_input.gl_BaryCoordNoPerspEXT; | ||
vUV[0] = GetAttributeAtVertex(stage_input.vUV, 0); | ||
vUV[1] = GetAttributeAtVertex(stage_input.vUV, 1); | ||
vUV[2] = GetAttributeAtVertex(stage_input.vUV, 2); | ||
vUV2[0] = GetAttributeAtVertex(stage_input.vUV2, 0); | ||
vUV2[1] = GetAttributeAtVertex(stage_input.vUV2, 1); | ||
vUV2[2] = GetAttributeAtVertex(stage_input.vUV2, 2); | ||
foo[0].a = GetAttributeAtVertex(stage_input.Foo_a, 0); | ||
foo[1].a = GetAttributeAtVertex(stage_input.Foo_a, 1); | ||
foo[2].a = GetAttributeAtVertex(stage_input.Foo_a, 2); | ||
foo[0].b = GetAttributeAtVertex(stage_input.Foo_b, 0); | ||
foo[1].b = GetAttributeAtVertex(stage_input.Foo_b, 1); | ||
foo[2].b = GetAttributeAtVertex(stage_input.Foo_b, 2); | ||
frag_main(); | ||
SPIRV_Cross_Output stage_output; | ||
stage_output.value = value; | ||
return stage_output; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#version 450 | ||
#extension GL_EXT_fragment_shader_barycentric : require | ||
|
||
layout(location = 0) out vec2 value; | ||
layout(location = 0) pervertexEXT in vec2 vUV[3]; | ||
layout(location = 1) pervertexEXT in vec2 vUV2[3]; | ||
layout(location = 2) pervertexEXT in Foo | ||
{ | ||
vec2 a; | ||
vec2 b; | ||
} foo[3]; | ||
|
||
|
||
void main() | ||
{ | ||
value = ((vUV[0] * gl_BaryCoordEXT.x) + (vUV[1] * gl_BaryCoordEXT.y)) + (vUV[2] * gl_BaryCoordEXT.z); | ||
value += (((vUV2[0] * gl_BaryCoordNoPerspEXT.x) + (vUV2[1] * gl_BaryCoordNoPerspEXT.y)) + (vUV2[2] * gl_BaryCoordNoPerspEXT.z)); | ||
value += (foo[0].a * gl_BaryCoordEXT.x); | ||
value += (foo[0].b * gl_BaryCoordEXT.y); | ||
value += (foo[1].a * gl_BaryCoordEXT.z); | ||
value += (foo[1].b * gl_BaryCoordEXT.x); | ||
value += (foo[2].a * gl_BaryCoordEXT.y); | ||
value += (foo[2].b * gl_BaryCoordEXT.z); | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
shaders-hlsl-no-opt/frag/barycentric-khr-nopersp.sm61.fxconly.nofxc.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 450 | ||
#extension GL_EXT_fragment_shader_barycentric : require | ||
|
||
layout(location = 0) out vec2 value; | ||
layout(location = 1) pervertexEXT in vec2 vUV2[3]; | ||
|
||
void main () { | ||
value = gl_BaryCoordNoPerspEXT.x * vUV2[0] + gl_BaryCoordNoPerspEXT.y * vUV2[1] + gl_BaryCoordNoPerspEXT.z * vUV2[2]; | ||
} |
9 changes: 9 additions & 0 deletions
9
shaders-hlsl-no-opt/frag/barycentric-khr-persp.sm61.fxconly.nofxc.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 450 | ||
#extension GL_EXT_fragment_shader_barycentric : require | ||
|
||
layout(location = 0) out vec2 value; | ||
layout(location = 0) pervertexEXT in vec2 vUV[3]; | ||
|
||
void main () { | ||
value = gl_BaryCoordEXT.x * vUV[0] + gl_BaryCoordEXT.y * vUV[1] + gl_BaryCoordEXT.z * vUV[2]; | ||
} |
23 changes: 23 additions & 0 deletions
23
shaders-hlsl-no-opt/frag/barycentric-khr.sm61.fxconly.nofxc.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#version 450 | ||
#extension GL_EXT_fragment_shader_barycentric : require | ||
|
||
layout(location = 0) out vec2 value; | ||
layout(location = 0) pervertexEXT in vec2 vUV[3]; | ||
layout(location = 1) pervertexEXT in vec2 vUV2[3]; | ||
|
||
layout(location = 2) pervertexEXT in Foo | ||
{ | ||
vec2 a; | ||
vec2 b; | ||
} foo[3]; | ||
|
||
void main () { | ||
value = gl_BaryCoordEXT.x * vUV[0] + gl_BaryCoordEXT.y * vUV[1] + gl_BaryCoordEXT.z * vUV[2]; | ||
value += gl_BaryCoordNoPerspEXT.x * vUV2[0] + gl_BaryCoordNoPerspEXT.y * vUV2[1] + gl_BaryCoordNoPerspEXT.z * vUV2[2]; | ||
value += gl_BaryCoordEXT.x * foo[0].a; | ||
value += gl_BaryCoordEXT.y * foo[0].b; | ||
value += gl_BaryCoordEXT.z * foo[1].a; | ||
value += gl_BaryCoordEXT.x * foo[1].b; | ||
value += gl_BaryCoordEXT.y * foo[2].a; | ||
value += gl_BaryCoordEXT.z * foo[2].b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#version 450 | ||
#extension GL_EXT_fragment_shader_barycentric : require | ||
|
||
layout(location = 0) out vec2 value; | ||
layout(location = 0) pervertexEXT in vec2 vUV[3]; | ||
layout(location = 1) pervertexEXT in vec2 vUV2[3]; | ||
|
||
layout(location = 2) pervertexEXT in Foo | ||
{ | ||
vec2 a; | ||
vec2 b; | ||
} foo[3]; | ||
|
||
void main () { | ||
value = gl_BaryCoordEXT.x * vUV[0] + gl_BaryCoordEXT.y * vUV[1] + gl_BaryCoordEXT.z * vUV[2]; | ||
value += gl_BaryCoordNoPerspEXT.x * vUV2[0] + gl_BaryCoordNoPerspEXT.y * vUV2[1] + gl_BaryCoordNoPerspEXT.z * vUV2[2]; | ||
value += gl_BaryCoordEXT.x * foo[0].a; | ||
value += gl_BaryCoordEXT.y * foo[0].b; | ||
value += gl_BaryCoordEXT.z * foo[1].a; | ||
value += gl_BaryCoordEXT.x * foo[1].b; | ||
value += gl_BaryCoordEXT.y * foo[2].a; | ||
value += gl_BaryCoordEXT.z * foo[2].b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters