diff --git a/renderdoc/Makefile b/renderdoc/Makefile index e1920c642..b402f9d01 100644 --- a/renderdoc/Makefile +++ b/renderdoc/Makefile @@ -71,6 +71,9 @@ data/spv/textfs.spvo \ data/spv/genericvs.spvo \ data/spv/genericfs.spvo \ data/spv/fixedcolfs.spvo \ +data/spv/meshvs.spvo \ +data/spv/meshgs.spvo \ +data/spv/meshfs.spvo \ data/sourcecodepro.ttfo .PHONY: all diff --git a/renderdoc/data/embedded_files.h b/renderdoc/data/embedded_files.h index caf344bbd..a3e0d600b 100644 --- a/renderdoc/data/embedded_files.h +++ b/renderdoc/data/embedded_files.h @@ -55,5 +55,8 @@ DECLARE_EMBED(textfs_spv); DECLARE_EMBED(genericvs_spv); DECLARE_EMBED(genericfs_spv); DECLARE_EMBED(fixedcolfs_spv); +DECLARE_EMBED(meshvs_spv); +DECLARE_EMBED(meshgs_spv); +DECLARE_EMBED(meshfs_spv); #undef DECLARE_EMBED diff --git a/renderdoc/data/renderdoc.rc b/renderdoc/data/renderdoc.rc index b37da86ab..05b4395ff 100644 --- a/renderdoc/data/renderdoc.rc +++ b/renderdoc/data/renderdoc.rc @@ -139,6 +139,9 @@ RESOURCE_textfs_spv TYPE_EMBED "spv/textfs.spv" RESOURCE_genericvs_spv TYPE_EMBED "spv/genericvs.spv" RESOURCE_genericfs_spv TYPE_EMBED "spv/genericfs.spv" RESOURCE_fixedcolfs_spv TYPE_EMBED "spv/fixedcolfs.spv" +RESOURCE_meshvs_spv TYPE_EMBED "spv/meshvs.spv" +RESOURCE_meshgs_spv TYPE_EMBED "spv/meshfs.spv" +RESOURCE_meshfs_spv TYPE_EMBED "spv/meshfs.spv" #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// diff --git a/renderdoc/data/resource.h b/renderdoc/data/resource.h index 999ef0d85..852722b58 100644 --- a/renderdoc/data/resource.h +++ b/renderdoc/data/resource.h @@ -41,6 +41,9 @@ #define RESOURCE_genericvs_spv 406 #define RESOURCE_genericfs_spv 407 #define RESOURCE_fixedcolfs_spv 408 +#define RESOURCE_meshvs_spv 409 +#define RESOURCE_meshgs_spv 410 +#define RESOURCE_meshfs_spv 411 #if !defined(STRINGIZE) #define STRINGIZE2(a) #a diff --git a/renderdoc/data/spv/mesh.frag b/renderdoc/data/spv/mesh.frag new file mode 100644 index 000000000..d40a61dc9 --- /dev/null +++ b/renderdoc/data/spv/mesh.frag @@ -0,0 +1,78 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2015 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#version 420 core + +// VKTODOHIGH LunarG sample driver doesn't support in/out blocks yet it seems +/* +in v2f +{ + vec4 secondary; + vec4 norm; +} IN; +*/ + +layout (location = 0) in vec4 INsecondary; +layout (location = 1) in vec4 INnorm; + +layout (binding = 0, std140) uniform meshuniforms +{ + mat4 mvp; + mat4 invProj; + vec4 color; + uint displayFormat; + uint homogenousInput; + vec2 pointSpriteSize; +} Mesh; + +layout (location = 0) out vec4 color_out; + +#define MESHDISPLAY_SOLID 0x1 +#define MESHDISPLAY_FACELIT 0x2 +#define MESHDISPLAY_SECONDARY 0x3 +#define MESHDISPLAY_SECONDARY_ALPHA 0x4 + +void main(void) +{ + uint type = Mesh.displayFormat; + + if(type == MESHDISPLAY_SECONDARY) + { + color_out = vec4(INsecondary.xyz, 1); + } + else if(type == MESHDISPLAY_SECONDARY_ALPHA) + { + color_out = vec4(INsecondary.www, 1); + } + else if(type == MESHDISPLAY_FACELIT) + { + vec3 lightDir = normalize(vec3(0, -0.3f, -1)); + + color_out = vec4(Mesh.color.xyz*abs(dot(lightDir, INnorm.xyz)), 1); + } + else //if(type == MESHDISPLAY_SOLID) + { + color_out = vec4(Mesh.color.xyz, 1); + } +} diff --git a/renderdoc/data/spv/mesh.geom b/renderdoc/data/spv/mesh.geom new file mode 100644 index 000000000..3f6c6ff8a --- /dev/null +++ b/renderdoc/data/spv/mesh.geom @@ -0,0 +1,73 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2015 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#version 420 core + +layout(triangles, invocations = 1) in; +layout(triangle_strip, max_vertices = 3) out; + +in v2f +{ + vec4 secondary; + vec4 norm; +} IN[]; + +out v2f +{ + vec4 secondary; + vec4 norm; +} OUT; + +layout (binding = 0, std140) uniform meshuniforms +{ + mat4 mvp; + mat4 invProj; + vec4 color; + uint displayFormat; + uint homogenousInput; + vec2 pointSpriteSize; +} Mesh; + +out gl_PerVertex +{ + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +}; + +void main() +{ + vec4 faceEdgeA = (Mesh.invProj * gl_in[1].gl_Position) - (Mesh.invProj * gl_in[0].gl_Position); + vec4 faceEdgeB = (Mesh.invProj * gl_in[2].gl_Position) - (Mesh.invProj * gl_in[0].gl_Position); + vec3 faceNormal = normalize( cross(faceEdgeA.xyz, faceEdgeB.xyz) ); + + for(int i=0; i < 3; i++) + { + gl_Position = gl_in[i].gl_Position; + OUT.secondary = IN[i].secondary; + OUT.norm = vec4(faceNormal.xyz, 1); + EmitVertex(); + } + EndPrimitive(); +} diff --git a/renderdoc/data/spv/mesh.vert b/renderdoc/data/spv/mesh.vert new file mode 100644 index 000000000..123bb7cf8 --- /dev/null +++ b/renderdoc/data/spv/mesh.vert @@ -0,0 +1,81 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2014 Crytek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#version 420 core + +layout (location = 0) in vec4 position; +layout (location = 1) in vec4 secondary; + +layout (binding = 0, std140) uniform meshuniforms +{ + mat4 mvp; + mat4 invProj; + vec4 color; + uint displayFormat; + uint homogenousInput; + vec2 pointSpriteSize; +} Mesh; + +out gl_PerVertex +{ + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +}; + +// VKTODOHIGH LunarG sample driver doesn't support in/out blocks yet it seems +/* +out v2f +{ + vec4 secondary; + vec4 norm; +} OUT; +*/ + +layout (location = 0) out vec4 OUTsecondary; +layout (location = 1) out vec4 OUTnorm; + +void main(void) +{ + vec2 psprite[4] = + { + vec2(-1.0f, -1.0f), + vec2(-1.0f, 1.0f), + vec2( 1.0f, -1.0f), + vec2( 1.0f, 1.0f) + }; + + vec4 pos = position; + if(Mesh.homogenousInput == 0) + pos = vec4(position.xyz, 1); + + gl_Position = Mesh.mvp * pos; + gl_Position.xy += Mesh.pointSpriteSize.xy*0.01f*psprite[gl_VertexID%4]*gl_Position.w; + OUTsecondary = secondary; + OUTnorm = vec4(0, 0, 1, 1); + + // GL->VK conventions + gl_Position.y = -gl_Position.y; + gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0; +} diff --git a/renderdoc/data/spv/text.frag b/renderdoc/data/spv/text.frag index 095ca61e8..d2cf5c7af 100644 --- a/renderdoc/data/spv/text.frag +++ b/renderdoc/data/spv/text.frag @@ -27,7 +27,7 @@ layout (binding = 3) uniform sampler2D tex0; layout (location = 0) out vec4 color_out; -// LunarG sample driver doesn't support in/out blocks yet it seems +// VKTODOHIGH LunarG sample driver doesn't support in/out blocks yet it seems /* in v2f { diff --git a/renderdoc/data/spv/text.vert b/renderdoc/data/spv/text.vert index 1dedd0250..6d480a1d5 100644 --- a/renderdoc/data/spv/text.vert +++ b/renderdoc/data/spv/text.vert @@ -57,7 +57,7 @@ out gl_PerVertex float gl_ClipDistance[]; }; -// LunarG sample driver doesn't support in/out blocks yet it seems +// VKTODOHIGH LunarG sample driver doesn't support in/out blocks yet it seems /* out v2f { diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj index 74db12c46..7e72e5b83 100644 --- a/renderdoc/renderdoc.vcxproj +++ b/renderdoc/renderdoc.vcxproj @@ -367,6 +367,12 @@ + + + + + + diff --git a/renderdoc/renderdoc.vcxproj.filters b/renderdoc/renderdoc.vcxproj.filters index e967ba72b..c1106db9d 100644 --- a/renderdoc/renderdoc.vcxproj.filters +++ b/renderdoc/renderdoc.vcxproj.filters @@ -478,6 +478,24 @@ Resources\spv + + Resources\spv + + + Resources\spv + + + Resources\spv + + + Resources\spv + + + Resources\spv + + + Resources\spv +