Apply clang-format to embedded internal shader source

* It gets a couple of things less than ideal, mostly glsl block names being on
  the next line, but otherwise it's readable and stops mixed tabs/spaces which
  had snuck in without checks.
This commit is contained in:
baldurk
2018-12-17 13:11:30 +00:00
parent 6b40a82a80
commit b08d277b61
31 changed files with 2145 additions and 2156 deletions
+13 -11
View File
@@ -25,7 +25,7 @@
//#extension_nongles GL_ARB_compute_shader : require
//#extension_gles GL_OES_texture_storage_multisample_2d_array : require
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0) uniform PRECISION usampler2DArray srcArray;
// binding = 1 used as stencil read in the depth-stencil copy fragment shaders
@@ -35,11 +35,12 @@ layout(rgba32ui, binding = 2) writeonly uniform PRECISION uimage2DMSArray dstMS;
layout(push_constant) uniform multisamplePush
{
int numMultiSamples;
int sampleOffset;
int sliceOffset;
uint currentStencil;
} mscopy;
int numMultiSamples;
int sampleOffset;
int sliceOffset;
uint currentStencil;
}
mscopy;
#define numMultiSamples (mscopy.numMultiSamples)
#define sampleOffset (mscopy.sampleOffset)
@@ -59,12 +60,13 @@ uniform ivec4 mscopy;
void main()
{
ivec3 id = ivec3(gl_GlobalInvocationID);
ivec3 id = ivec3(gl_GlobalInvocationID);
int slice = sliceOffset + int(id.z / numMultiSamples);
int sampleIdx = sampleOffset + int(id.z % numMultiSamples);
int slice = sliceOffset + int(id.z / numMultiSamples);
int sampleIdx = sampleOffset + int(id.z % numMultiSamples);
uvec4 data = texelFetch(srcArray, ivec3(int(id.x), int(id.y), slice * numMultiSamples + sampleIdx), 0);
uvec4 data =
texelFetch(srcArray, ivec3(int(id.x), int(id.y), slice *numMultiSamples + sampleIdx), 0);
imageStore(dstMS, ivec3(int(id.x), int(id.y), slice), sampleIdx, data);
imageStore(dstMS, ivec3(int(id.x), int(id.y), slice), sampleIdx, data);
}
+11 -13
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -25,20 +25,18 @@
#ifndef OPENGL_ES
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
vec4 gl_Position;
float gl_PointSize;
};
#endif
layout (location = 0) out vec2 uv;
layout(location = 0) out vec2 uv;
void main(void)
{
const vec4 verts[4] = vec4[4](vec4(-1.0, -1.0, 0.5, 1.0),
vec4( 1.0, -1.0, 0.5, 1.0),
vec4(-1.0, 1.0, 0.5, 1.0),
vec4( 1.0, 1.0, 0.5, 1.0));
const vec4 verts[4] = vec4[4](vec4(-1.0, -1.0, 0.5, 1.0), vec4(1.0, -1.0, 0.5, 1.0),
vec4(-1.0, 1.0, 0.5, 1.0), vec4(1.0, 1.0, 0.5, 1.0));
gl_Position = verts[VERTEX_ID];
uv = gl_Position.xy * 0.5f + 0.5f;
gl_Position = verts[VERTEX_ID];
uv = gl_Position.xy * 0.5f + 0.5f;
}
+20 -22
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -23,29 +23,27 @@
******************************************************************************/
// for GLES compatibility where we must match blit.vert
layout (location = 0) in vec2 uv;
layout(location = 0) in vec2 uv;
layout (location = 0) out vec4 color_out;
layout(location = 0) out vec4 color_out;
layout (binding = 0, std140) uniform checkeruniforms
layout(binding = 0, std140) uniform checkeruniforms
{
vec4 lightCol;
vec4 darkCol;
} checker;
vec4 lightCol;
vec4 darkCol;
}
checker;
void main(void)
{
vec2 ab = mod(gl_FragCoord.xy, vec2(128.0f));
vec2 ab = mod(gl_FragCoord.xy, vec2(128.0f));
if(
(ab.x < 64.0f && ab.y < 64.0f) ||
(ab.x > 64.0f && ab.y > 64.0f)
)
{
color_out = vec4(checker.darkCol.rgb*checker.darkCol.rgb, 1);
}
else
{
color_out = vec4(checker.lightCol.rgb*checker.lightCol.rgb, 1);
}
if((ab.x < 64.0f && ab.y < 64.0f) || (ab.x > 64.0f && ab.y > 64.0f))
{
color_out = vec4(checker.darkCol.rgb * checker.darkCol.rgb, 1);
}
else
{
color_out = vec4(checker.lightCol.rgb * checker.lightCol.rgb, 1);
}
}
+20 -18
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
//#extension_glcore GL_ARB_sample_shading : require
layout(binding = 0) uniform PRECISION sampler2DArray srcDepthArray;
@@ -32,11 +32,12 @@ layout(binding = 1) uniform PRECISION usampler2DArray srcStencilArray;
layout(push_constant) uniform multisamplePush
{
int numMultiSamples;
int currentSample;
int currentSlice;
uint currentStencil;
} mscopy;
int numMultiSamples;
int currentSample;
int currentSlice;
uint currentStencil;
}
mscopy;
#define numMultiSamples (mscopy.numMultiSamples)
#define currentSample (mscopy.currentSample)
@@ -56,15 +57,16 @@ uniform ivec4 mscopy;
void main()
{
ivec3 srcCoord = ivec3(int(gl_FragCoord.x), int(gl_FragCoord.y), currentSlice*numMultiSamples + gl_SampleID);
ivec3 srcCoord =
ivec3(int(gl_FragCoord.x), int(gl_FragCoord.y), currentSlice *numMultiSamples + gl_SampleID);
if(currentStencil < 256u)
{
uint stencil = texelFetch(srcStencilArray, srcCoord, 0).x;
if(currentStencil < 256u)
{
uint stencil = texelFetch(srcStencilArray, srcCoord, 0).x;
if(stencil != currentStencil)
discard;
}
if(stencil != currentStencil)
discard;
}
gl_FragDepth = texelFetch(srcDepthArray, srcCoord, 0).x;
gl_FragDepth = texelFetch(srcDepthArray, srcCoord, 0).x;
}
+18 -17
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -30,11 +30,12 @@ layout(binding = 1) uniform PRECISION usampler2DMSArray srcStencilMS;
layout(push_constant) uniform multisamplePush
{
int numMultiSamples;
int currentSample;
int currentSlice;
uint currentStencil;
} mscopy;
int numMultiSamples;
int currentSample;
int currentSlice;
uint currentStencil;
}
mscopy;
#define numMultiSamples (mscopy.numMultiSamples)
#define currentSample (mscopy.currentSample)
@@ -54,15 +55,15 @@ uniform ivec4 mscopy;
void main()
{
ivec3 srcCoord = ivec3(int(gl_FragCoord.x), int(gl_FragCoord.y), currentSlice);
ivec3 srcCoord = ivec3(int(gl_FragCoord.x), int(gl_FragCoord.y), currentSlice);
if(currentStencil < 256u)
{
uint stencil = texelFetch(srcStencilMS, srcCoord, currentSample).x;
if(currentStencil < 256u)
{
uint stencil = texelFetch(srcStencilMS, srcCoord, currentSample).x;
if(stencil != currentStencil)
discard;
}
if(stencil != currentStencil)
discard;
}
gl_FragDepth = texelFetch(srcDepthMS, srcCoord, currentSample).x;
gl_FragDepth = texelFetch(srcDepthMS, srcCoord, currentSample).x;
}
+12 -12
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -32,23 +32,23 @@
//#extension_nongles GL_ARB_explicit_attrib_location : require
// otherwise we use a proper output
layout (location = 0) out vec4 color_out;
layout(location = 0) out vec4 color_out;
#endif
#ifndef VULKAN // OpenGL can't use SPIR-V patching
#ifndef VULKAN // OpenGL can't use SPIR-V patching
uniform vec4 RENDERDOC_Fixed_Color;
#endif
void main(void)
{
#ifdef VULKAN
// used to have a shader-replacement pixel shader
// that outputs a fixed colour, without needing a
// slot in a descriptor set. We re-write the SPIR-V
// on the fly to replace these constants
color_out = vec4(1.1f, 2.2f, 3.3f, 4.4f);
// used to have a shader-replacement pixel shader
// that outputs a fixed colour, without needing a
// slot in a descriptor set. We re-write the SPIR-V
// on the fly to replace these constants
color_out = vec4(1.1f, 2.2f, 3.3f, 4.4f);
#else
color_out = RENDERDOC_Fixed_Color;
color_out = RENDERDOC_Fixed_Color;
#endif
}
+13 -14
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -29,16 +29,15 @@ varying vec2 glyphuv;
void main(void)
{
float text = 0.0;
float text = 0.0;
if(glyphuv.x >= 0.0 && glyphuv.x <= 1.0 &&
glyphuv.y >= 0.0 && glyphuv.y <= 1.0)
{
vec2 uv;
uv.x = mix(tex.x, tex.z, glyphuv.x);
uv.y = mix(tex.y, tex.w, glyphuv.y);
text = texture2D(font_tex, uv).x;
}
if(glyphuv.x >= 0.0 && glyphuv.x <= 1.0 && glyphuv.y >= 0.0 && glyphuv.y <= 1.0)
{
vec2 uv;
uv.x = mix(tex.x, tex.z, glyphuv.x);
uv.y = mix(tex.y, tex.w, glyphuv.y);
text = texture2D(font_tex, uv).x;
}
gl_FragColor = vec4(vec3(text), clamp(text + 0.5, 0.0, 1.0));
gl_FragColor = vec4(vec3(text), clamp(text + 0.5, 0.0, 1.0));
}
+10 -10
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -38,10 +38,10 @@ uniform vec4 uvdata[FONT_LAST_CHAR - FONT_FIRST_CHAR + 1];
void main(void)
{
vec4 glyphposdata = posdata[int(charidx)];
vec4 glyphuvdata = uvdata[int(charidx)];
gl_Position = vec4(pos, 1, 1);
glyphuv.xy = (uv.xy - glyphposdata.xy) * glyphposdata.zw;
tex = glyphuvdata;
vec4 glyphposdata = posdata[int(charidx)];
vec4 glyphuvdata = uvdata[int(charidx)];
gl_Position = vec4(pos, 1, 1);
glyphuv.xy = (uv.xy - glyphposdata.xy) * glyphposdata.zw;
tex = glyphuvdata;
}
+137 -138
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2014-2018 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
@@ -24,170 +24,169 @@
//#include "texsample.h" // while includes aren't supported in glslang, this will be added in code
layout(binding=0, std430) buffer minmaxresultdest
layout(binding = 0, std430) buffer minmaxresultdest
{
uint result[HGRAM_NUM_BUCKETS];
} dest;
uint result[HGRAM_NUM_BUCKETS];
}
dest;
layout (local_size_x = HGRAM_TILES_PER_BLOCK, local_size_y = HGRAM_TILES_PER_BLOCK) in;
layout(local_size_x = HGRAM_TILES_PER_BLOCK, local_size_y = HGRAM_TILES_PER_BLOCK) in;
void main()
{
uvec3 tid = gl_LocalInvocationID;
uvec3 gid = gl_WorkGroupID;
uvec3 tid = gl_LocalInvocationID;
uvec3 gid = gl_WorkGroupID;
int texType = SHADER_RESTYPE;
int texType = SHADER_RESTYPE;
uvec3 texDim = uvec3(histogram_minmax.HistogramTextureResolution);
uvec3 texDim = uvec3(histogram_minmax.HistogramTextureResolution);
uint blocksX = uint(ceil(float(texDim.x)/float(HGRAM_PIXELS_PER_TILE*HGRAM_TILES_PER_BLOCK)));
uint blocksX = uint(ceil(float(texDim.x) / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK)));
uvec2 topleft = (gid.xy*HGRAM_TILES_PER_BLOCK + tid.xy)*HGRAM_PIXELS_PER_TILE;
uvec2 topleft = (gid.xy * HGRAM_TILES_PER_BLOCK + tid.xy) * HGRAM_PIXELS_PER_TILE;
int i=0;
int i = 0;
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uint bucketIdx = HGRAM_NUM_BUCKETS+1u;
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uint bucketIdx = HGRAM_NUM_BUCKETS + 1u;
#if UINT_TEX
{
uvec4 data = SampleTextureUInt4(texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice,
histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample,
histogram_minmax.HistogramTextureResolution);
{
uvec4 data = SampleTextureUInt4(
texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice, histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample, histogram_minmax.HistogramTextureResolution);
float divisor = 0.0f;
uint sum = 0u;
if((histogram_minmax.HistogramChannels & 0x1u) > 0u)
{
sum += data.x;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x2u) > 0u)
{
sum += data.y;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x4u) > 0u)
{
sum += data.z;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x8u) > 0u)
{
sum += data.w;
divisor += 1.0f;
}
float divisor = 0.0f;
uint sum = 0u;
if((histogram_minmax.HistogramChannels & 0x1u) > 0u)
{
sum += data.x;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x2u) > 0u)
{
sum += data.y;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x4u) > 0u)
{
sum += data.z;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x8u) > 0u)
{
sum += data.w;
divisor += 1.0f;
}
if(divisor > 0.0f)
{
float val = float(sum)/divisor;
if(divisor > 0.0f)
{
float val = float(sum) / divisor;
float normalisedVal = (val - histogram_minmax.HistogramMin)/(histogram_minmax.HistogramMax - histogram_minmax.HistogramMin);
float normalisedVal = (val - histogram_minmax.HistogramMin) /
(histogram_minmax.HistogramMax - histogram_minmax.HistogramMin);
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
bucketIdx = uint(floor(normalisedVal*float(HGRAM_NUM_BUCKETS)));
}
}
bucketIdx = uint(floor(normalisedVal * float(HGRAM_NUM_BUCKETS)));
}
}
#elif SINT_TEX
{
ivec4 data = SampleTextureSInt4(texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice,
histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample,
histogram_minmax.HistogramTextureResolution);
{
ivec4 data = SampleTextureSInt4(
texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice, histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample, histogram_minmax.HistogramTextureResolution);
float divisor = 0.0f;
int sum = 0;
if((histogram_minmax.HistogramChannels & 0x1u) > 0u)
{
sum += data.x;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x2u) > 0u)
{
sum += data.y;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x4u) > 0u)
{
sum += data.z;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x8u) > 0u)
{
sum += data.w;
divisor += 1.0f;
}
float divisor = 0.0f;
int sum = 0;
if((histogram_minmax.HistogramChannels & 0x1u) > 0u)
{
sum += data.x;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x2u) > 0u)
{
sum += data.y;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x4u) > 0u)
{
sum += data.z;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x8u) > 0u)
{
sum += data.w;
divisor += 1.0f;
}
if(divisor > 0.0f)
{
float val = float(sum)/divisor;
if(divisor > 0.0f)
{
float val = float(sum) / divisor;
float normalisedVal = (val - histogram_minmax.HistogramMin)/(histogram_minmax.HistogramMax - histogram_minmax.HistogramMin);
float normalisedVal = (val - histogram_minmax.HistogramMin) /
(histogram_minmax.HistogramMax - histogram_minmax.HistogramMin);
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
bucketIdx = uint(floor(normalisedVal*float(HGRAM_NUM_BUCKETS)));
}
}
bucketIdx = uint(floor(normalisedVal * float(HGRAM_NUM_BUCKETS)));
}
}
#else
{
vec4 data = SampleTextureFloat4(texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice,
histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample,
histogram_minmax.HistogramTextureResolution,
histogram_minmax.HistogramYUVDownsampleRate,
histogram_minmax.HistogramYUVAChannels);
{
vec4 data = SampleTextureFloat4(
texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice, histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample, histogram_minmax.HistogramTextureResolution,
histogram_minmax.HistogramYUVDownsampleRate, histogram_minmax.HistogramYUVAChannels);
float divisor = 0.0f;
float sum = 0.0f;
if((histogram_minmax.HistogramChannels & 0x1u) > 0u)
{
sum += data.x;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x2u) > 0u)
{
sum += data.y;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x4u) > 0u)
{
sum += data.z;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x8u) > 0u)
{
sum += data.w;
divisor += 1.0f;
}
float divisor = 0.0f;
float sum = 0.0f;
if((histogram_minmax.HistogramChannels & 0x1u) > 0u)
{
sum += data.x;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x2u) > 0u)
{
sum += data.y;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x4u) > 0u)
{
sum += data.z;
divisor += 1.0f;
}
if((histogram_minmax.HistogramChannels & 0x8u) > 0u)
{
sum += data.w;
divisor += 1.0f;
}
if(divisor > 0.0f)
{
float val = sum/divisor;
if(divisor > 0.0f)
{
float val = sum / divisor;
float normalisedVal = (val - histogram_minmax.HistogramMin)/(histogram_minmax.HistogramMax - histogram_minmax.HistogramMin);
float normalisedVal = (val - histogram_minmax.HistogramMin) /
(histogram_minmax.HistogramMax - histogram_minmax.HistogramMin);
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
bucketIdx = uint(floor(normalisedVal*float(HGRAM_NUM_BUCKETS)));
}
}
bucketIdx = uint(floor(normalisedVal * float(HGRAM_NUM_BUCKETS)));
}
}
#endif
if(bucketIdx < HGRAM_NUM_BUCKETS)
atomicAdd(dest.result[bucketIdx], 1U);
}
}
if(bucketIdx < HGRAM_NUM_BUCKETS)
atomicAdd(dest.result[bucketIdx], 1U);
}
}
}
+162 -161
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2016-2018 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
@@ -24,208 +24,209 @@
layout(binding = 1, std140) readonly buffer vertex_data
{
vec4 data[];
} vb;
vec4 data[];
}
vb;
layout(binding = 2, std430) readonly buffer index_data
{
uint data[];
} ib;
uint data[];
}
ib;
layout(binding = 3, std140) buffer pickresult_buffer
{
uint counter;
// individual padding to prevent uint/uint3 packing woes
uint pad0;
uint pad1;
uint pad2;
uint counter;
// individual padding to prevent uint/uint3 packing woes
uint pad0;
uint pad1;
uint pad2;
uvec4 results[];
} pickresult;
uvec4 results[];
}
pickresult;
layout (local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
layout(local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
bool TriangleRayIntersect(vec3 A, vec3 B, vec3 C,
vec3 RayPosition, vec3 RayDirection, out vec3 HitPosition)
bool TriangleRayIntersect(vec3 A, vec3 B, vec3 C, vec3 RayPosition, vec3 RayDirection,
out vec3 HitPosition)
{
bool Result = false;
bool Result = false;
vec3 v0v1 = B - A;
vec3 v0v2 = C - A;
vec3 pvec = cross(RayDirection, v0v2);
float det = dot(v0v1, pvec);
vec3 v0v1 = B - A;
vec3 v0v2 = C - A;
vec3 pvec = cross(RayDirection, v0v2);
float det = dot(v0v1, pvec);
// if the determinant is negative the triangle is backfacing, but we still take those!
// if the determinant is close to 0, the ray misses the triangle
if (abs(det) > 0.0f)
{
float invDet = 1.0f / det;
// if the determinant is negative the triangle is backfacing, but we still take those!
// if the determinant is close to 0, the ray misses the triangle
if(abs(det) > 0.0f)
{
float invDet = 1.0f / det;
vec3 tvec = RayPosition - A;
vec3 qvec = cross(tvec, v0v1);
float u = dot(tvec, pvec) * invDet;
float v = dot(RayDirection, qvec) * invDet;
vec3 tvec = RayPosition - A;
vec3 qvec = cross(tvec, v0v1);
float u = dot(tvec, pvec) * invDet;
float v = dot(RayDirection, qvec) * invDet;
if (u >= 0.0f && u <= 1.0f &&
v >= 0.0f && u + v <= 1.0f)
{
float t = dot(v0v2, qvec) * invDet;
if (t > 0.0f)
{
HitPosition = RayPosition + (RayDirection * t);
Result = true;
}
if(u >= 0.0f && u <= 1.0f && v >= 0.0f && u + v <= 1.0f)
{
float t = dot(v0v2, qvec) * invDet;
if(t > 0.0f)
{
HitPosition = RayPosition + (RayDirection * t);
Result = true;
}
}
}
}
}
return Result;
return Result;
}
void trianglePath(uint threadID)
{
uint vertid = uint(mod(float(threadID), float(meshpick.numVerts)));
uint vertid = uint(mod(float(threadID), float(meshpick.numVerts)));
uint vertid0 = 0u;
uint vertid1 = 0u;
uint vertid2 = 0u;
switch (meshpick.meshMode)
{
case MESH_TRIANGLE_LIST:
{
vertid *= 3u;
vertid0 = vertid;
vertid1 = vertid+1u;
vertid2 = vertid+2u;
break;
}
case MESH_TRIANGLE_STRIP:
{
vertid0 = vertid;
vertid1 = vertid+1u;
vertid2 = vertid+2u;
break;
}
case MESH_TRIANGLE_FAN:
{
vertid0 = 0u;
vertid1 = vertid+1u;
vertid2 = vertid+2u;
break;
}
case MESH_TRIANGLE_LIST_ADJ:
{
vertid *= 6u;
vertid0 = vertid;
vertid1 = vertid+2u;
vertid2 = vertid+4u;
break;
}
case MESH_TRIANGLE_STRIP_ADJ:
{
vertid *= 2u;
vertid0 = vertid;
vertid1 = vertid+2u;
vertid2 = vertid+4u;
break;
}
}
uint vertid0 = 0u;
uint vertid1 = 0u;
uint vertid2 = 0u;
switch(meshpick.meshMode)
{
case MESH_TRIANGLE_LIST:
{
vertid *= 3u;
vertid0 = vertid;
vertid1 = vertid + 1u;
vertid2 = vertid + 2u;
break;
}
case MESH_TRIANGLE_STRIP:
{
vertid0 = vertid;
vertid1 = vertid + 1u;
vertid2 = vertid + 2u;
break;
}
case MESH_TRIANGLE_FAN:
{
vertid0 = 0u;
vertid1 = vertid + 1u;
vertid2 = vertid + 2u;
break;
}
case MESH_TRIANGLE_LIST_ADJ:
{
vertid *= 6u;
vertid0 = vertid;
vertid1 = vertid + 2u;
vertid2 = vertid + 4u;
break;
}
case MESH_TRIANGLE_STRIP_ADJ:
{
vertid *= 2u;
vertid0 = vertid;
vertid1 = vertid + 2u;
vertid2 = vertid + 4u;
break;
}
}
vec4 pos0 = meshpick.use_indices != 0u ? vb.data[ib.data[vertid0]] : vb.data[vertid0];
vec4 pos1 = meshpick.use_indices != 0u ? vb.data[ib.data[vertid1]] : vb.data[vertid1];
vec4 pos2 = meshpick.use_indices != 0u ? vb.data[ib.data[vertid2]] : vb.data[vertid2];
vec4 pos0 = meshpick.use_indices != 0u ? vb.data[ib.data[vertid0]] : vb.data[vertid0];
vec4 pos1 = meshpick.use_indices != 0u ? vb.data[ib.data[vertid1]] : vb.data[vertid1];
vec4 pos2 = meshpick.use_indices != 0u ? vb.data[ib.data[vertid2]] : vb.data[vertid2];
#ifdef VULKAN
if(meshpick.unproject == 1u)
{
pos0 = vec4(pos0.x, -pos0.y, pos0.z, pos0.w);
pos1 = vec4(pos1.x, -pos1.y, pos1.z, pos1.w);
pos2 = vec4(pos2.x, -pos2.y, pos2.z, pos2.w);
}
if(meshpick.unproject == 1u)
{
pos0 = vec4(pos0.x, -pos0.y, pos0.z, pos0.w);
pos1 = vec4(pos1.x, -pos1.y, pos1.z, pos1.w);
pos2 = vec4(pos2.x, -pos2.y, pos2.z, pos2.w);
}
#endif
vec3 hitPosition;
bool hit;
if (meshpick.unproject == 1u)
{
hit = TriangleRayIntersect(pos0.xyz / pos0.w, pos1.xyz / pos1.w, pos2.xyz / pos2.w,
meshpick.rayPos, meshpick.rayDir,
/*out*/ hitPosition);
}
else
{
hit = TriangleRayIntersect(pos0.xyz, pos1.xyz, pos2.xyz,
meshpick.rayPos, meshpick.rayDir,
/*out*/ hitPosition);
}
vec3 hitPosition;
bool hit;
if(meshpick.unproject == 1u)
{
hit = TriangleRayIntersect(pos0.xyz / pos0.w, pos1.xyz / pos1.w, pos2.xyz / pos2.w,
meshpick.rayPos, meshpick.rayDir,
/*out*/ hitPosition);
}
else
{
hit = TriangleRayIntersect(pos0.xyz, pos1.xyz, pos2.xyz, meshpick.rayPos, meshpick.rayDir,
/*out*/ hitPosition);
}
// ray hit a triangle, so return the vertex that was closest
// to the triangle/ray intersection point
if (hit)
{
float dist0 = distance(pos0.xyz/pos0.w, hitPosition);
float dist1 = distance(pos1.xyz/pos1.w, hitPosition);
float dist2 = distance(pos2.xyz/pos2.w, hitPosition);
// ray hit a triangle, so return the vertex that was closest
// to the triangle/ray intersection point
if(hit)
{
float dist0 = distance(pos0.xyz / pos0.w, hitPosition);
float dist1 = distance(pos1.xyz / pos1.w, hitPosition);
float dist2 = distance(pos2.xyz / pos2.w, hitPosition);
uint result_idx = atomicAdd(pickresult.counter, 1u);
uint meshVert = vertid0;
if (dist1 < dist0 && dist1 < dist2)
{
meshVert = vertid1;
}
else if (dist2 < dist0 && dist2 < dist1)
{
meshVert = vertid2;
}
pickresult.results[result_idx] = uvec4(meshVert,
floatBitsToUint(hitPosition.x), floatBitsToUint(hitPosition.y), floatBitsToUint(hitPosition.z));
}
uint result_idx = atomicAdd(pickresult.counter, 1u);
uint meshVert = vertid0;
if(dist1 < dist0 && dist1 < dist2)
{
meshVert = vertid1;
}
else if(dist2 < dist0 && dist2 < dist1)
{
meshVert = vertid2;
}
pickresult.results[result_idx] =
uvec4(meshVert, floatBitsToUint(hitPosition.x), floatBitsToUint(hitPosition.y),
floatBitsToUint(hitPosition.z));
}
}
void defaultPath(uint threadID)
{
uint vertid = threadID;
uint vertid = threadID;
if(vertid >= meshpick.numVerts)
return;
if(vertid >= meshpick.numVerts)
return;
uint idx = meshpick.use_indices != 0u ? ib.data[vertid] : vertid;
uint idx = meshpick.use_indices != 0u ? ib.data[vertid] : vertid;
vec4 pos = vb.data[idx];
vec4 pos = vb.data[idx];
#ifdef VULKAN
if(meshpick.unproject == 1u)
pos = vec4(pos.x, -pos.y, pos.z, pos.w);
if(meshpick.unproject == 1u)
pos = vec4(pos.x, -pos.y, pos.z, pos.w);
#endif
vec4 wpos = meshpick.mvp * pos;
vec4 wpos = meshpick.mvp * pos;
if(meshpick.unproject == 1u)
wpos.xyz /= wpos.www;
if(meshpick.unproject == 1u)
wpos.xyz /= wpos.www;
wpos.xy *= vec2(1.0f, -1.0f);
wpos.xy *= vec2(1.0f, -1.0f);
vec2 scr = (wpos.xy + 1.0f) * 0.5f * meshpick.viewport;
vec2 scr = (wpos.xy + 1.0f) * 0.5f * meshpick.viewport;
// close to target co-ords? add to list
float len = length(scr - meshpick.coords);
if(len < 35.0f)
{
uint result_idx = atomicAdd(pickresult.counter, 1u);
pickresult.results[result_idx] = uvec4(vertid, idx, floatBitsToUint(len), floatBitsToUint(wpos.z));
}
// close to target co-ords? add to list
float len = length(scr - meshpick.coords);
if(len < 35.0f)
{
uint result_idx = atomicAdd(pickresult.counter, 1u);
pickresult.results[result_idx] =
uvec4(vertid, idx, floatBitsToUint(len), floatBitsToUint(wpos.z));
}
}
void main()
{
if (meshpick.meshMode == MESH_OTHER)
{
defaultPath(gl_GlobalInvocationID.x);
}
else
{
trianglePath(gl_GlobalInvocationID.x);
}
if(meshpick.meshMode == MESH_OTHER)
{
defaultPath(gl_GlobalInvocationID.x);
}
else
{
trianglePath(gl_GlobalInvocationID.x);
}
}
+26 -26
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -22,31 +22,31 @@
* THE SOFTWARE.
******************************************************************************/
layout (location = 0) in vec4 secondary;
layout (location = 1) in vec4 norm;
layout(location = 0) in vec4 secondary;
layout(location = 1) in vec4 norm;
layout (location = 0) out vec4 color_out;
layout(location = 0) out vec4 color_out;
void main(void)
{
int type = Mesh.displayFormat;
if(type == MESHDISPLAY_SECONDARY)
{
color_out = vec4(secondary.xyz, 1);
}
else if(type == MESHDISPLAY_SECONDARY_ALPHA)
{
color_out = vec4(secondary.www, 1);
}
else if(type == MESHDISPLAY_FACELIT)
{
vec3 lightDir = normalize(vec3(0, -0.3f, -1));
int type = Mesh.displayFormat;
color_out = vec4(Mesh.color.xyz*abs(dot(lightDir, norm.xyz)), 1);
}
else //if(type == MESHDISPLAY_SOLID)
{
color_out = vec4(Mesh.color.xyz, 1);
}
if(type == MESHDISPLAY_SECONDARY)
{
color_out = vec4(secondary.xyz, 1);
}
else if(type == MESHDISPLAY_SECONDARY_ALPHA)
{
color_out = vec4(secondary.www, 1);
}
else if(type == MESHDISPLAY_FACELIT)
{
vec3 lightDir = normalize(vec3(0, -0.3f, -1));
color_out = vec4(Mesh.color.xyz * abs(dot(lightDir, norm.xyz)), 1);
}
else // if(type == MESHDISPLAY_SOLID)
{
color_out = vec4(Mesh.color.xyz, 1);
}
}
+23 -22
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -29,38 +29,39 @@
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
layout (location = 0) in vec4 IN_secondary[3];
layout (location = 1) in vec4 IN_norm[3];
layout(location = 0) in vec4 IN_secondary[3];
layout(location = 1) in vec4 IN_norm[3];
layout (location = 0) out vec4 secondary;
layout (location = 1) out vec4 norm;
layout(location = 0) out vec4 secondary;
layout(location = 1) out vec4 norm;
#ifndef OPENGL_ES
in gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
} gl_in[];
}
gl_in[];
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
vec4 gl_Position;
float gl_PointSize;
};
#endif
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) );
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;
secondary = IN_secondary[i];
norm = vec4(faceNormal.xyz, 1);
EmitVertex();
}
EndPrimitive();
for(int i = 0; i < 3; i++)
{
gl_Position = gl_in[i].gl_Position;
secondary = IN_secondary[i];
norm = vec4(faceNormal.xyz, 1);
EmitVertex();
}
EndPrimitive();
}
+32 -37
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -22,55 +22,50 @@
* THE SOFTWARE.
******************************************************************************/
layout (location = 0) in vec4 position;
layout (location = 1) in vec4 IN_secondary;
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 IN_secondary;
#ifndef OPENGL_ES
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
vec4 gl_Position;
float gl_PointSize;
};
#endif
layout (location = 0) out vec4 secondary;
layout (location = 1) out vec4 norm;
layout(location = 0) out vec4 secondary;
layout(location = 1) out vec4 norm;
void main(void)
{
vec2 psprite[4] = vec2[]
(
vec2(-1.0f, -1.0f),
vec2(-1.0f, 1.0f),
vec2( 1.0f, -1.0f),
vec2( 1.0f, 1.0f)
);
vec2 psprite[4] =
vec2[](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 == 0u)
{
pos = vec4(position.xyz, 1);
}
else
{
vec4 pos = position;
if(Mesh.homogenousInput == 0u)
{
pos = vec4(position.xyz, 1);
}
else
{
#ifdef VULKAN
pos = vec4(position.x, -position.y, position.z, position.w);
pos = vec4(position.x, -position.y, position.z, position.w);
#endif
}
}
gl_Position = Mesh.mvp * pos;
gl_Position.xy += Mesh.pointSpriteSize.xy*0.01f*psprite[VERTEX_ID%4]*gl_Position.w;
secondary = IN_secondary;
norm = vec4(0, 0, 1, 1);
gl_Position = Mesh.mvp * pos;
gl_Position.xy += Mesh.pointSpriteSize.xy * 0.01f * psprite[VERTEX_ID % 4] * gl_Position.w;
secondary = IN_secondary;
norm = vec4(0, 0, 1, 1);
#ifdef VULKAN
// GL->VK conventions
gl_Position.y = -gl_Position.y;
if(Mesh.rawoutput == 0)
{
gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;
}
// GL->VK conventions
gl_Position.y = -gl_Position.y;
if(Mesh.rawoutput == 0)
{
gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;
}
gl_PointSize = 4.0f;
gl_PointSize = 4.0f;
#endif
}
+56 -53
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2014-2018 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
@@ -22,84 +22,87 @@
* THE SOFTWARE.
******************************************************************************/
layout(binding=0, std140) writeonly buffer minmaxresultdest
layout(binding = 0, std140) writeonly buffer minmaxresultdest
{
#if UINT_TEX
uvec4 result[2];
uvec4 result[2];
#elif SINT_TEX
ivec4 result[2];
ivec4 result[2];
#else
vec4 result[2];
vec4 result[2];
#endif
} dest;
}
dest;
layout(binding=1, std140) readonly buffer minmaxtilesrc
layout(binding = 1, std140) readonly buffer minmaxtilesrc
{
#if UINT_TEX
uvec4 tiles[];
uvec4 tiles[];
#elif SINT_TEX
ivec4 tiles[];
ivec4 tiles[];
#else
vec4 tiles[];
vec4 tiles[];
#endif
} src;
}
src;
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main()
{
uvec3 texDim = uvec3(histogram_minmax.HistogramTextureResolution);
uvec3 texDim = uvec3(histogram_minmax.HistogramTextureResolution);
uint blocksX = uint(ceil(float(texDim.x)/float(HGRAM_PIXELS_PER_TILE*HGRAM_TILES_PER_BLOCK)));
uint blocksY = uint(ceil(float(texDim.y)/float(HGRAM_PIXELS_PER_TILE*HGRAM_TILES_PER_BLOCK)));
uint blocksX = uint(ceil(float(texDim.x) / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK)));
uint blocksY = uint(ceil(float(texDim.y) / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK)));
#if UINT_TEX
uvec4 minvalU = src.tiles[0];
uvec4 maxvalU = src.tiles[1];
uvec4 minvalU = src.tiles[0];
uvec4 maxvalU = src.tiles[1];
#elif SINT_TEX
ivec4 minvalI = src.tiles[0];
ivec4 maxvalI = src.tiles[1];
ivec4 minvalI = src.tiles[0];
ivec4 maxvalI = src.tiles[1];
#else
vec4 minvalF = src.tiles[0];
vec4 maxvalF = src.tiles[1];
vec4 minvalF = src.tiles[0];
vec4 maxvalF = src.tiles[1];
#endif
// i is the tile we're looking at
for(uint i=1u; i < blocksX*blocksY*HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK; i++)
{
uint blockIdx = i/(HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK);
uint tileIdx = i%(HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK);
// which block and tile is this in
uvec2 blockXY = uvec2(blockIdx % blocksX, blockIdx / blocksX);
uvec2 tileXY = uvec2(tileIdx % HGRAM_TILES_PER_BLOCK, tileIdx / HGRAM_TILES_PER_BLOCK);
// i is the tile we're looking at
for(uint i = 1u; i < blocksX * blocksY * HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK; i++)
{
uint blockIdx = i / (HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK);
uint tileIdx = i % (HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK);
// if this is at least partially within the texture, include it.
if(blockXY.x*(HGRAM_TILES_PER_BLOCK*HGRAM_PIXELS_PER_TILE) + tileXY.x*HGRAM_PIXELS_PER_TILE < texDim.x &&
blockXY.y*(HGRAM_TILES_PER_BLOCK*HGRAM_PIXELS_PER_TILE) + tileXY.y*HGRAM_PIXELS_PER_TILE < texDim.y)
{
// which block and tile is this in
uvec2 blockXY = uvec2(blockIdx % blocksX, blockIdx / blocksX);
uvec2 tileXY = uvec2(tileIdx % HGRAM_TILES_PER_BLOCK, tileIdx / HGRAM_TILES_PER_BLOCK);
// if this is at least partially within the texture, include it.
if(blockXY.x * (HGRAM_TILES_PER_BLOCK * HGRAM_PIXELS_PER_TILE) + tileXY.x * HGRAM_PIXELS_PER_TILE <
texDim.x &&
blockXY.y * (HGRAM_TILES_PER_BLOCK * HGRAM_PIXELS_PER_TILE) + tileXY.y * HGRAM_PIXELS_PER_TILE <
texDim.y)
{
#if UINT_TEX
minvalU = min(minvalU, src.tiles[i*2u + 0u]);
maxvalU = max(maxvalU, src.tiles[i*2u + 1u]);
minvalU = min(minvalU, src.tiles[i * 2u + 0u]);
maxvalU = max(maxvalU, src.tiles[i * 2u + 1u]);
#elif SINT_TEX
minvalI = min(minvalI, src.tiles[i*2u + 0u]);
maxvalI = max(maxvalI, src.tiles[i*2u + 1u]);
minvalI = min(minvalI, src.tiles[i * 2u + 0u]);
maxvalI = max(maxvalI, src.tiles[i * 2u + 1u]);
#else
minvalF = min(minvalF, src.tiles[i*2u + 0u]);
maxvalF = max(maxvalF, src.tiles[i*2u + 1u]);
minvalF = min(minvalF, src.tiles[i * 2u + 0u]);
maxvalF = max(maxvalF, src.tiles[i * 2u + 1u]);
#endif
}
}
}
}
#if UINT_TEX
dest.result[0] = minvalU;
dest.result[1] = maxvalU;
dest.result[0] = minvalU;
dest.result[1] = maxvalU;
#elif SINT_TEX
dest.result[0] = minvalI;
dest.result[1] = maxvalI;
dest.result[0] = minvalI;
dest.result[1] = maxvalI;
#else
dest.result[0] = minvalF;
dest.result[1] = maxvalF;
dest.result[0] = minvalF;
dest.result[1] = maxvalF;
#endif
}
+99 -102
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2014-2018 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
@@ -24,134 +24,131 @@
//#include "texsample.h" // while includes aren't supported in glslang, this will be added in code
layout(binding=0, std140) writeonly buffer minmaxtiledest
layout(binding = 0, std140) writeonly buffer minmaxtiledest
{
#if UINT_TEX
uvec4 tiles[];
uvec4 tiles[];
#elif SINT_TEX
ivec4 tiles[];
ivec4 tiles[];
#else
vec4 tiles[];
vec4 tiles[];
#endif
} dest;
}
dest;
layout (local_size_x = HGRAM_TILES_PER_BLOCK, local_size_y = HGRAM_TILES_PER_BLOCK) in;
layout(local_size_x = HGRAM_TILES_PER_BLOCK, local_size_y = HGRAM_TILES_PER_BLOCK) in;
void main()
{
uvec3 tid = gl_LocalInvocationID;
uvec3 gid = gl_WorkGroupID;
uvec3 tid = gl_LocalInvocationID;
uvec3 gid = gl_WorkGroupID;
int texType = SHADER_RESTYPE;
int texType = SHADER_RESTYPE;
uvec3 texDim = uvec3(histogram_minmax.HistogramTextureResolution);
uvec3 texDim = uvec3(histogram_minmax.HistogramTextureResolution);
uint blocksX = uint(ceil(float(texDim.x)/float(HGRAM_PIXELS_PER_TILE*HGRAM_TILES_PER_BLOCK)));
uint blocksX = uint(ceil(float(texDim.x) / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK)));
uvec2 topleft = (gid.xy*HGRAM_TILES_PER_BLOCK + tid.xy)*HGRAM_PIXELS_PER_TILE;
uvec2 topleft = (gid.xy * HGRAM_TILES_PER_BLOCK + tid.xy) * HGRAM_PIXELS_PER_TILE;
uint outIdx = (tid.y*HGRAM_TILES_PER_BLOCK + tid.x) + (gid.y*blocksX + gid.x)*(HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK);
uint outIdx = (tid.y * HGRAM_TILES_PER_BLOCK + tid.x) +
(gid.y * blocksX + gid.x) * (HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK);
int i=0;
int i = 0;
#if UINT_TEX
{
uvec4 minval = uvec4(0,0,0,0);
uvec4 maxval = uvec4(0,0,0,0);
{
uvec4 minval = uvec4(0, 0, 0, 0);
uvec4 maxval = uvec4(0, 0, 0, 0);
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uvec4 data = SampleTextureUInt4(texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice,
histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample,
histogram_minmax.HistogramTextureResolution);
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uvec4 data = SampleTextureUInt4(
texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice, histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample, histogram_minmax.HistogramTextureResolution);
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
i++;
}
}
i++;
}
}
dest.tiles[outIdx*2u+0u] = minval;
dest.tiles[outIdx*2u+1u] = maxval;
}
dest.tiles[outIdx * 2u + 0u] = minval;
dest.tiles[outIdx * 2u + 1u] = maxval;
}
#elif SINT_TEX
{
ivec4 minval = ivec4(0,0,0,0);
ivec4 maxval = ivec4(0,0,0,0);
{
ivec4 minval = ivec4(0, 0, 0, 0);
ivec4 maxval = ivec4(0, 0, 0, 0);
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
ivec4 data = SampleTextureSInt4(texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice,
histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample,
histogram_minmax.HistogramTextureResolution);
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
ivec4 data = SampleTextureSInt4(
texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice, histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample, histogram_minmax.HistogramTextureResolution);
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
i++;
}
}
i++;
}
}
dest.tiles[outIdx*2u+0u] = minval;
dest.tiles[outIdx*2u+1u] = maxval;
}
dest.tiles[outIdx * 2u + 0u] = minval;
dest.tiles[outIdx * 2u + 1u] = maxval;
}
#else
{
vec4 minval = vec4(0,0,0,0);
vec4 maxval = vec4(0,0,0,0);
{
vec4 minval = vec4(0, 0, 0, 0);
vec4 maxval = vec4(0, 0, 0, 0);
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
vec4 data = SampleTextureFloat4(texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice,
histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample,
histogram_minmax.HistogramTextureResolution,
histogram_minmax.HistogramYUVDownsampleRate,
histogram_minmax.HistogramYUVAChannels);
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
vec4 data = SampleTextureFloat4(
texType, vec2(x, y) / histogram_minmax.HistogramTextureResolution.xy,
histogram_minmax.HistogramSlice, histogram_minmax.HistogramMip,
histogram_minmax.HistogramSample, histogram_minmax.HistogramTextureResolution,
histogram_minmax.HistogramYUVDownsampleRate, histogram_minmax.HistogramYUVAChannels);
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
i++;
}
}
i++;
}
}
dest.tiles[outIdx*2u+0u] = minval;
dest.tiles[outIdx*2u+1u] = maxval;
}
dest.tiles[outIdx * 2u + 0u] = minval;
dest.tiles[outIdx * 2u + 1u] = maxval;
}
#endif
}
+12 -12
View File
@@ -24,22 +24,22 @@
//#extension_nongles GL_ARB_compute_shader : require
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0) uniform PRECISION usampler2DMSArray srcMS;
// binding = 1 used as stencil read in the depth-stencil copy fragment shaders
layout(rgba32ui, binding = 2) writeonly uniform PRECISION uimage2DArray dstArray;
#ifdef VULKAN
layout(push_constant) uniform multisamplePush
{
int numMultiSamples;
int currentSample;
int currentSlice;
uint currentStencil;
} mscopy;
int numMultiSamples;
int currentSample;
int currentSlice;
uint currentStencil;
}
mscopy;
#define numMultiSamples (mscopy.numMultiSamples)
#define currentSample (mscopy.currentSample)
@@ -59,12 +59,12 @@ uniform ivec4 mscopy;
void main()
{
ivec3 id = ivec3(gl_GlobalInvocationID);
ivec3 id = ivec3(gl_GlobalInvocationID);
int slice = int(id.z / numMultiSamples);
int sampleIdx = int(id.z % numMultiSamples);
int slice = int(id.z / numMultiSamples);
int sampleIdx = int(id.z % numMultiSamples);
uvec4 data = texelFetch(srcMS, ivec3(int(id.x), int(id.y), slice), sampleIdx);
uvec4 data = texelFetch(srcMS, ivec3(int(id.x), int(id.y), slice), sampleIdx);
imageStore(dstArray, ivec3(int(id.x), int(id.y), int(id.z)), data);
imageStore(dstArray, ivec3(int(id.x), int(id.y), int(id.z)), data);
}
+32 -35
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -22,42 +22,39 @@
* THE SOFTWARE.
******************************************************************************/
layout (location = 0) out vec4 color_out;
layout(location = 0) out vec4 color_out;
void main(void)
{
vec4 ret = outline.Inner_Color;
vec4 ret = outline.Inner_Color;
vec2 rectPos = gl_FragCoord.xy - outline.ViewRect.xy;
vec2 rectSize = outline.ViewRect.zw;
vec2 ab = mod(rectPos.xy, vec2(32.0f));
vec2 rectPos = gl_FragCoord.xy - outline.ViewRect.xy;
vec2 rectSize = outline.ViewRect.zw;
bool checkerVariant = (
(ab.x < 16.0f && ab.y < 16.0f) ||
(ab.x > 16.0f && ab.y > 16.0f)
);
vec2 ab = mod(rectPos.xy, vec2(32.0f));
if(outline.Scissor == 0u)
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f ||
rectPos.y < 3.0f || rectPos.y > rectSize.y - 3.0f)
{
ret = outline.Border_Color;
}
}
else
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f ||
rectPos.y < 3.0f || rectPos.y > rectSize.y - 3.0f)
{
ret = checkerVariant ? vec4(1, 1, 1, 1) : vec4(0, 0, 0, 1);
}
else
{
ret = vec4(0, 0, 0, 0);
}
}
bool checkerVariant = ((ab.x < 16.0f && ab.y < 16.0f) || (ab.x > 16.0f && ab.y > 16.0f));
color_out = ret;
if(outline.Scissor == 0u)
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f || rectPos.y < 3.0f ||
rectPos.y > rectSize.y - 3.0f)
{
ret = outline.Border_Color;
}
}
else
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f || rectPos.y < 3.0f ||
rectPos.y > rectSize.y - 3.0f)
{
ret = checkerVariant ? vec4(1, 1, 1, 1) : vec4(0, 0, 0, 1);
}
else
{
ret = vec4(0, 0, 0, 0);
}
}
color_out = ret;
}
+11 -11
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -23,7 +23,7 @@
******************************************************************************/
//#extension_nongles GL_ARB_shader_image_load_store : require
////////////////////////////////////////////////////////////////////////////////////////////
// Below shaders courtesy of Stephen Hill (@self_shadow), converted to glsl trivially
//
@@ -33,17 +33,17 @@
layout(binding = 0, r32ui) uniform PRECISION coherent uimage2DArray overdrawImage;
layout (location = 0) out vec4 color_out;
layout(location = 0) out vec4 color_out;
void main()
{
ivec2 quad = ivec2(gl_FragCoord.xy*0.5f);
ivec2 quad = ivec2(gl_FragCoord.xy * 0.5f);
uint overdraw = 0u;
for(uint i = 0u; i < 4u; i++)
overdraw += imageLoad(overdrawImage, ivec3(quad, i)).x/(i + 1u);
uint overdraw = 0u;
for(uint i = 0u; i < 4u; i++)
overdraw += imageLoad(overdrawImage, ivec3(quad, i)).x / (i + 1u);
color_out = vec4(overdraw);
color_out = vec4(overdraw);
}
////////////////////////////////////////////////////////////////////////////////////////////
+18 -19
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -30,7 +30,6 @@
//#extension_nongles GL_ARB_shader_image_load_store : require
//#extension_nongles GL_ARB_gpu_shader5 : require
////////////////////////////////////////////////////////////////////////////////////////////
// Below shaders courtesy of Stephen Hill (@self_shadow), converted to glsl trivially
//
@@ -41,29 +40,29 @@
#ifdef VULKAN
// descriptor set will be patched from 0 to whichever descriptor set we're using in code
layout(set = 0, binding = 0, r32ui) uniform coherent uimage2DArray overdrawImage;
#else // OPENGL and OPENGL_ES
#else // OPENGL and OPENGL_ES
layout(r32ui) uniform coherent uimage2DArray overdrawImage;
#endif
layout(early_fragment_tests) in;
void main()
{
uint c0 = uint(gl_SampleMaskIn[0]);
uint c0 = uint(gl_SampleMaskIn[0]);
// Obtain coverage for all pixels in the quad, via 'message passing'*.
// (* For more details, see:
// "Shader Amortization using Pixel Quad Message Passing", Eric Penner, GPU Pro 2.)
uvec2 p = uvec2(uint(gl_FragCoord.x) & 1u, uint(gl_FragCoord.y) & 1u);
ivec2 sign = ivec2(p.x > 0u ? -1 : 1, p.y > 0u ? -1 : 1);
uint c1 = c0 + uint(sign.x*int(dFdxFine(c0)));
uint c2 = c0 + uint(sign.y*int(dFdyFine(c0)));
uint c3 = c2 + uint(sign.x*int(dFdxFine(c2)));
// Obtain coverage for all pixels in the quad, via 'message passing'*.
// (* For more details, see:
// "Shader Amortization using Pixel Quad Message Passing", Eric Penner, GPU Pro 2.)
uvec2 p = uvec2(uint(gl_FragCoord.x) & 1u, uint(gl_FragCoord.y) & 1u);
ivec2 sign = ivec2(p.x > 0u ? -1 : 1, p.y > 0u ? -1 : 1);
uint c1 = c0 + uint(sign.x * int(dFdxFine(c0)));
uint c2 = c0 + uint(sign.y * int(dFdyFine(c0)));
uint c3 = c2 + uint(sign.x * int(dFdxFine(c2)));
// Count the live pixels, minus 1 (zero indexing)
uint pixelCount = c0 + c1 + c2 + c3 - 1u;
// Count the live pixels, minus 1 (zero indexing)
uint pixelCount = c0 + c1 + c2 + c3 - 1u;
ivec3 quad = ivec3(gl_FragCoord.xy*0.5, pixelCount);
imageAtomicAdd(overdrawImage, quad, 1);
ivec3 quad = ivec3(gl_FragCoord.xy * 0.5, pixelCount);
imageAtomicAdd(overdrawImage, quad, 1);
}
////////////////////////////////////////////////////////////////////////////////////////////
+224 -215
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -22,10 +22,10 @@
* THE SOFTWARE.
******************************************************************************/
layout (location = 0) out vec4 color_out;
layout(location = 0) out vec4 color_out;
#ifdef OPENGL_ES
// Required otherwise the shader compiler could remove the 'uv' from the vertex shader also.
layout (location = 0) in vec2 uv;
layout(location = 0) in vec2 uv;
#endif
//#extension_gles GL_EXT_texture_cube_map_array : enable
@@ -36,264 +36,273 @@ layout (location = 0) in vec2 uv;
float ConvertSRGBToLinear(float srgb)
{
if (srgb <= 0.04045f)
return srgb / 12.92f;
else
return pow(( clamp(srgb, 0.0f, 1.0f) + 0.055f) / 1.055f, 2.4f);
if(srgb <= 0.04045f)
return srgb / 12.92f;
else
return pow((clamp(srgb, 0.0f, 1.0f) + 0.055f) / 1.055f, 2.4f);
}
void main(void)
{
#ifdef VULKAN // vulkan combines all three types
bool uintTex = (texdisplay.OutputDisplayFormat & TEXDISPLAY_UINT_TEX) != 0;
bool sintTex = (texdisplay.OutputDisplayFormat & TEXDISPLAY_SINT_TEX) != 0;
#else // OPENGL
#ifdef VULKAN // vulkan combines all three types
bool uintTex = (texdisplay.OutputDisplayFormat & TEXDISPLAY_UINT_TEX) != 0;
bool sintTex = (texdisplay.OutputDisplayFormat & TEXDISPLAY_SINT_TEX) != 0;
#else // OPENGL
#if UINT_TEX
const bool uintTex = true;
const bool sintTex = false;
const bool uintTex = true;
const bool sintTex = false;
#elif SINT_TEX
const bool uintTex = false;
const bool sintTex = true;
const bool uintTex = false;
const bool sintTex = true;
#else
const bool uintTex = false;
const bool sintTex = false;
const bool uintTex = false;
const bool sintTex = false;
#endif
#endif // OPENGL
#endif // OPENGL
int texType = (texdisplay.OutputDisplayFormat & TEXDISPLAY_TYPEMASK);
int texType = (texdisplay.OutputDisplayFormat & TEXDISPLAY_TYPEMASK);
vec4 col;
uvec4 ucol;
ivec4 scol;
vec4 col;
uvec4 ucol;
ivec4 scol;
// calc screen co-ords with origin top left, modified by Position
vec2 scr = gl_FragCoord.xy;
// calc screen co-ords with origin top left, modified by Position
vec2 scr = gl_FragCoord.xy;
#ifdef OPENGL
scr.y = texdisplay.OutputRes.y - scr.y;
scr.y = texdisplay.OutputRes.y - scr.y;
#endif
scr -= texdisplay.Position.xy;
scr -= texdisplay.Position.xy;
scr /= texdisplay.TextureResolutionPS.xy;
scr /= texdisplay.TextureResolutionPS.xy;
scr /= texdisplay.Scale;
scr /= texdisplay.Scale;
scr /= vec2(texdisplay.MipShift, texdisplay.MipShift);
vec2 scr2 = scr;
scr /= vec2(texdisplay.MipShift, texdisplay.MipShift);
vec2 scr2 = scr;
#ifdef VULKAN
if(texType == RESTYPE_TEX1D)
if(texType == RESTYPE_TEX1D)
#else
if(texType == RESTYPE_TEX1D || texType == RESTYPE_TEXBUFFER || texType == RESTYPE_TEX1DARRAY)
if(texType == RESTYPE_TEX1D || texType == RESTYPE_TEXBUFFER || texType == RESTYPE_TEX1DARRAY)
#endif
{
// by convention display 1D textures as 100 high
if(scr2.x < 0.0f || scr2.x > 1.0f || scr2.y < 0.0f || scr2.y > 100.0f)
{
color_out = vec4(0, 0, 0, 0);
return;
}
}
else
{
if(scr2.x < 0.0f || scr2.y < 0.0f ||
scr2.x > 1.0f || scr2.y > 1.0f)
{
color_out = vec4(0, 0, 0, 0);
return;
}
}
{
// by convention display 1D textures as 100 high
if(scr2.x < 0.0f || scr2.x > 1.0f || scr2.y < 0.0f || scr2.y > 100.0f)
{
color_out = vec4(0, 0, 0, 0);
return;
}
}
else
{
if(scr2.x < 0.0f || scr2.y < 0.0f || scr2.x > 1.0f || scr2.y > 1.0f)
{
color_out = vec4(0, 0, 0, 0);
return;
}
}
#ifdef VULKAN
const int defaultFlipY = 0;
#else // OPENGL
const int defaultFlipY = 1;
const int defaultFlipY = 0;
#else // OPENGL
const int defaultFlipY = 1;
#endif
if (texdisplay.FlipY != defaultFlipY)
scr.y = 1.0f - scr.y;
if(texdisplay.FlipY != defaultFlipY)
scr.y = 1.0f - scr.y;
if(uintTex)
{
ucol = SampleTextureUInt4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
texdisplay.SampleIdx, texdisplay.TextureResolutionPS);
}
else if(sintTex)
{
scol = SampleTextureSInt4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
texdisplay.SampleIdx, texdisplay.TextureResolutionPS);
}
else
{
col = SampleTextureFloat4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
texdisplay.SampleIdx, texdisplay.TextureResolutionPS,
texdisplay.YUVDownsampleRate, texdisplay.YUVAChannels);
}
if(texdisplay.RawOutput != 0)
{
if(uintTex)
{
ucol = SampleTextureUInt4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
texdisplay.SampleIdx, texdisplay.TextureResolutionPS);
}
else if(sintTex)
{
scol = SampleTextureSInt4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
texdisplay.SampleIdx, texdisplay.TextureResolutionPS);
}
else
{
col = SampleTextureFloat4(texType, scr, texdisplay.Slice, texdisplay.MipLevel,
texdisplay.SampleIdx, texdisplay.TextureResolutionPS,
texdisplay.YUVDownsampleRate, texdisplay.YUVAChannels);
}
if(texdisplay.RawOutput != 0)
{
#ifdef GL_ARB_gpu_shader5
if (uintTex)
color_out = uintBitsToFloat(ucol);
else if (sintTex)
color_out = intBitsToFloat(scol);
else
color_out = col;
if(uintTex)
color_out = uintBitsToFloat(ucol);
else if(sintTex)
color_out = intBitsToFloat(scol);
else
color_out = col;
#else
// without being able to alias bits, we won't get accurate results.
// a cast is better than nothing though
if (uintTex)
color_out = vec4(ucol);
else if (sintTex)
color_out = vec4(scol);
else
color_out = col;
// without being able to alias bits, we won't get accurate results.
// a cast is better than nothing though
if(uintTex)
color_out = vec4(ucol);
else if(sintTex)
color_out = vec4(scol);
else
color_out = col;
#endif
return;
}
if(heatmap.HeatmapMode != HEATMAP_DISABLED)
{
if(heatmap.HeatmapMode == HEATMAP_LINEAR)
{
// cast the float value to an integer with safe rounding, then return the
int bucket = int(floor(col.x + 0.25f));
return;
}
bucket = max(bucket, 0);
bucket = min(bucket, HEATMAP_RAMPSIZE - 1);
if(heatmap.HeatmapMode != HEATMAP_DISABLED)
{
if(heatmap.HeatmapMode == HEATMAP_LINEAR)
{
// cast the float value to an integer with safe rounding, then return the
int bucket = int(floor(col.x + 0.25f));
if(bucket == 0)
discard;
bucket = max(bucket, 0);
bucket = min(bucket, HEATMAP_RAMPSIZE - 1);
color_out = heatmap.ColorRamp[bucket];
return;
}
else if(heatmap.HeatmapMode == HEATMAP_TRISIZE)
{
// uninitialised regions have alpha=0
if(col.w < 0.5f)
discard;
if(bucket == 0)
discard;
float area = max(col.x, 0.001f);
color_out = heatmap.ColorRamp[bucket];
return;
}
else if(heatmap.HeatmapMode == HEATMAP_TRISIZE)
{
// uninitialised regions have alpha=0
if(col.w < 0.5f)
discard;
int bucket = 2 + int( floor(20.0f - 20.1f * (1.0f - exp(-0.4f * area) ) ) );
float area = max(col.x, 0.001f);
bucket = max(bucket, 0);
bucket = min(bucket, HEATMAP_RAMPSIZE - 1);
int bucket = 2 + int(floor(20.0f - 20.1f * (1.0f - exp(-0.4f * area))));
color_out = heatmap.ColorRamp[bucket];
bucket = max(bucket, 0);
bucket = min(bucket, HEATMAP_RAMPSIZE - 1);
return;
}
else
{
// error! invalid heatmap mode
}
}
color_out = heatmap.ColorRamp[bucket];
return;
}
else
{
// error! invalid heatmap mode
}
}
#ifdef VULKAN
// YUV decoding
if(texdisplay.DecodeYUV != 0)
{
// assume col is now YUVA, perform a default conversion to RGBA
const float Kr = 0.2126f;
const float Kb = 0.0722f;
// YUV decoding
if(texdisplay.DecodeYUV != 0)
{
// assume col is now YUVA, perform a default conversion to RGBA
const float Kr = 0.2126f;
const float Kb = 0.0722f;
float L = col.g;
float Pb = col.b - 0.5f;
float Pr = col.r - 0.5f;
float L = col.g;
float Pb = col.b - 0.5f;
float Pr = col.r - 0.5f;
col.b = L + (Pb / 0.5f) * (1 - Kb);
col.r = L + (Pr / 0.5f) * (1 - Kr);
col.g = (L - Kr * col.r - Kb * col.b) / (1.0f - Kr - Kb);
}
col.b = L + (Pb / 0.5f) * (1 - Kb);
col.r = L + (Pr / 0.5f) * (1 - Kr);
col.g = (L - Kr * col.r - Kb * col.b) / (1.0f - Kr - Kb);
}
#endif
// RGBM encoding
if(texdisplay.HDRMul > 0.0f)
{
if (uintTex)
col = vec4(ucol.rgb * ucol.a * uint(texdisplay.HDRMul), 1.0);
else if (sintTex)
col = vec4(scol.rgb * scol.a * int(texdisplay.HDRMul), 1.0);
else
col = vec4(col.rgb * col.a * texdisplay.HDRMul, 1.0);
}
if (uintTex)
col = vec4(ucol);
else if (sintTex)
col = vec4(scol);
// RGBM encoding
if(texdisplay.HDRMul > 0.0f)
{
if(uintTex)
col = vec4(ucol.rgb * ucol.a * uint(texdisplay.HDRMul), 1.0);
else if(sintTex)
col = vec4(scol.rgb * scol.a * int(texdisplay.HDRMul), 1.0);
else
col = vec4(col.rgb * col.a * texdisplay.HDRMul, 1.0);
}
vec4 pre_range_col = col;
if(uintTex)
col = vec4(ucol);
else if(sintTex)
col = vec4(scol);
col = ((col - texdisplay.RangeMinimum)*texdisplay.InverseRangeSize);
if(texdisplay.Channels.x < 0.5f) col.x = pre_range_col.x = 0.0f;
if(texdisplay.Channels.y < 0.5f) col.y = pre_range_col.y = 0.0f;
if(texdisplay.Channels.z < 0.5f) col.z = pre_range_col.z = 0.0f;
if(texdisplay.Channels.w < 0.5f) col.w = pre_range_col.w = 1.0f;
if((texdisplay.OutputDisplayFormat & TEXDISPLAY_NANS) > 0)
{
if(isnan(pre_range_col.r) || isnan(pre_range_col.g) || isnan(pre_range_col.b) || isnan(pre_range_col.a))
{
color_out = vec4(1, 0, 0, 1);
return;
}
if(isinf(pre_range_col.r) || isinf(pre_range_col.g) || isinf(pre_range_col.b) || isinf(pre_range_col.a))
{
color_out = vec4(0, 1, 0, 1);
return;
}
vec4 pre_range_col = col;
if(pre_range_col.r < 0.0f || pre_range_col.g < 0.0f || pre_range_col.b < 0.0f || pre_range_col.a < 0.0f)
{
color_out = vec4(0, 0, 1, 1);
return;
}
col = vec4(vec3(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722))), 1);
}
else if((texdisplay.OutputDisplayFormat & TEXDISPLAY_CLIPPING) > 0)
{
if(col.r < 0.0f || col.g < 0.0f || col.b < 0.0f || col.a < 0.0f)
{
color_out = vec4(1, 0, 0, 1);
return;
}
col = ((col - texdisplay.RangeMinimum) * texdisplay.InverseRangeSize);
if(col.r > (1.0f+FLT_EPSILON) || col.g > (1.0f+FLT_EPSILON) || col.b > (1.0f+FLT_EPSILON) || col.a > (1.0f+FLT_EPSILON))
{
color_out = vec4(0, 1, 0, 1);
return;
}
col = vec4(vec3(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722))), 1);
}
else
{
// if only one channel is selected
if(dot(texdisplay.Channels, vec4(1.0f)) == 1.0f)
{
// if it's alpha, just move it into rgb
// otherwise, select the channel that's on and replicate it across all channels
if(texdisplay.Channels.a == 1.0f)
col = vec4(col.aaa, 1);
else
//this is a splat because col has already gone through the if(texdisplay.Channels.x < 0.5f) statements
col = vec4(vec3(dot(col.rgb, vec3(1.0f))), 1.0f);
}
}
if((texdisplay.OutputDisplayFormat & TEXDISPLAY_GAMMA_CURVE) > 0)
{
col.rgb = vec3(ConvertSRGBToLinear(col.r), ConvertSRGBToLinear(col.g), ConvertSRGBToLinear(col.b));
}
if(texdisplay.Channels.x < 0.5f)
col.x = pre_range_col.x = 0.0f;
if(texdisplay.Channels.y < 0.5f)
col.y = pre_range_col.y = 0.0f;
if(texdisplay.Channels.z < 0.5f)
col.z = pre_range_col.z = 0.0f;
if(texdisplay.Channels.w < 0.5f)
col.w = pre_range_col.w = 1.0f;
color_out = col;
if((texdisplay.OutputDisplayFormat & TEXDISPLAY_NANS) > 0)
{
if(isnan(pre_range_col.r) || isnan(pre_range_col.g) || isnan(pre_range_col.b) ||
isnan(pre_range_col.a))
{
color_out = vec4(1, 0, 0, 1);
return;
}
if(isinf(pre_range_col.r) || isinf(pre_range_col.g) || isinf(pre_range_col.b) ||
isinf(pre_range_col.a))
{
color_out = vec4(0, 1, 0, 1);
return;
}
if(pre_range_col.r < 0.0f || pre_range_col.g < 0.0f || pre_range_col.b < 0.0f ||
pre_range_col.a < 0.0f)
{
color_out = vec4(0, 0, 1, 1);
return;
}
col = vec4(vec3(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722))), 1);
}
else if((texdisplay.OutputDisplayFormat & TEXDISPLAY_CLIPPING) > 0)
{
if(col.r < 0.0f || col.g < 0.0f || col.b < 0.0f || col.a < 0.0f)
{
color_out = vec4(1, 0, 0, 1);
return;
}
if(col.r > (1.0f + FLT_EPSILON) || col.g > (1.0f + FLT_EPSILON) ||
col.b > (1.0f + FLT_EPSILON) || col.a > (1.0f + FLT_EPSILON))
{
color_out = vec4(0, 1, 0, 1);
return;
}
col = vec4(vec3(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722))), 1);
}
else
{
// if only one channel is selected
if(dot(texdisplay.Channels, vec4(1.0f)) == 1.0f)
{
// if it's alpha, just move it into rgb
// otherwise, select the channel that's on and replicate it across all channels
if(texdisplay.Channels.a == 1.0f)
col = vec4(col.aaa, 1);
else
// this is a splat because col has already gone through the if(texdisplay.Channels.x < 0.5f)
// statements
col = vec4(vec3(dot(col.rgb, vec3(1.0f))), 1.0f);
}
}
if((texdisplay.OutputDisplayFormat & TEXDISPLAY_GAMMA_CURVE) > 0)
{
col.rgb =
vec3(ConvertSRGBToLinear(col.r), ConvertSRGBToLinear(col.g), ConvertSRGBToLinear(col.b));
}
color_out = col;
}
+9 -9
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -21,13 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
layout (location = 0) in float pixarea;
layout (location = 0) out vec4 color_out;
layout(location = 0) in float pixarea;
layout(location = 0) out vec4 color_out;
void main(void)
{
float area = max(pixarea, 0.001f);
color_out = vec4(area, area, area, 1.0f);
float area = max(pixarea, 0.001f);
color_out = vec4(area, area, area, 1.0f);
}
+32 -30
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -28,53 +28,55 @@
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
layout (location = 0) in vec4 IN_secondary[3];
layout (location = 1) in vec4 IN_norm[3];
layout(location = 0) in vec4 IN_secondary[3];
layout(location = 1) in vec4 IN_norm[3];
layout (location = 0) out float OUT_pixarea;
layout(location = 0) out float OUT_pixarea;
#ifndef OPENGL_ES
in gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
} gl_in[];
}
gl_in[];
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
vec4 gl_Position;
float gl_PointSize;
};
#endif
layout(binding = 2) uniform ViewportSizeUBO
{
vec4 size;
} viewport;
vec4 size;
}
viewport;
void main()
{
vec2 a = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w;
vec2 b = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;
vec2 c = gl_in[2].gl_Position.xy / gl_in[2].gl_Position.w;
vec2 a = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w;
vec2 b = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;
vec2 c = gl_in[2].gl_Position.xy / gl_in[2].gl_Position.w;
a = (a * 0.5f + 0.5f) * viewport.size.xy;
b = (b * 0.5f + 0.5f) * viewport.size.xy;
c = (c * 0.5f + 0.5f) * viewport.size.xy;
a = (a * 0.5f + 0.5f) * viewport.size.xy;
b = (b * 0.5f + 0.5f) * viewport.size.xy;
c = (c * 0.5f + 0.5f) * viewport.size.xy;
float ab = length(a - b);
float bc = length(b - c);
float ca = length(c - a);
float ab = length(a - b);
float bc = length(b - c);
float ca = length(c - a);
float s = (ab + bc + ca) / 2.0f;
float s = (ab + bc + ca) / 2.0f;
float area = sqrt( s * (s - ab) * (s - bc) * (s - ca) );
float area = sqrt(s * (s - ab) * (s - bc) * (s - ca));
for(int i=0; i < 3; i++)
{
gl_Position = gl_in[i].gl_Position;
OUT_pixarea = area;
EmitVertex();
}
EndPrimitive();
for(int i = 0; i < 3; i++)
{
gl_Position = gl_in[i].gl_Position;
OUT_pixarea = area;
EmitVertex();
}
EndPrimitive();
}
+17 -18
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -22,25 +22,24 @@
* THE SOFTWARE.
******************************************************************************/
layout (binding = 3) uniform sampler2D tex0;
layout(binding = 3) uniform sampler2D tex0;
layout (location = 0) out vec4 color_out;
layout(location = 0) out vec4 color_out;
layout (location = 0) in vec4 tex;
layout (location = 1) in vec2 glyphuv;
layout(location = 0) in vec4 tex;
layout(location = 1) in vec2 glyphuv;
void main(void)
{
float text = 0.0f;
float text = 0.0f;
if(glyphuv.x >= 0.0f && glyphuv.x <= 1.0f &&
glyphuv.y >= 0.0f && glyphuv.y <= 1.0f)
{
vec2 uv;
uv.x = mix(tex.x, tex.z, glyphuv.x);
uv.y = mix(tex.y, tex.w, glyphuv.y);
text = texture(tex0, uv.xy).x;
}
if(glyphuv.x >= 0.0f && glyphuv.x <= 1.0f && glyphuv.y >= 0.0f && glyphuv.y <= 1.0f)
{
vec2 uv;
uv.x = mix(tex.x, tex.z, glyphuv.x);
uv.y = mix(tex.y, tex.w, glyphuv.y);
text = texture(tex0, uv.xy).x;
}
color_out = vec4(vec3(text), clamp(text + 0.5f, 0.0f, 1.0f));
color_out = vec4(vec3(text), clamp(text + 0.5f, 0.0f, 1.0f));
}
+22 -24
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -24,33 +24,31 @@
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
vec4 gl_Position;
float gl_PointSize;
};
layout (location = 0) out vec4 tex;
layout (location = 1) out vec2 glyphuv;
layout(location = 0) out vec4 tex;
layout(location = 1) out vec2 glyphuv;
void main(void)
{
const vec3 verts[6] = vec3[6](vec3( 0.0, 0.0, 0.5),
vec3( 1.0, 0.0, 0.5),
vec3( 0.0, 1.0, 0.5),
const vec3 verts[6] = vec3[6](vec3(0.0, 0.0, 0.5), vec3(1.0, 0.0, 0.5), vec3(0.0, 1.0, 0.5),
vec3( 1.0, 0.0, 0.5),
vec3( 0.0, 1.0, 0.5),
vec3( 1.0, 1.0, 0.5));
vec3(1.0, 0.0, 0.5), vec3(0.0, 1.0, 0.5), vec3(1.0, 1.0, 0.5));
uint vert = uint(VERTEX_ID)%6u;
uint vert = uint(VERTEX_ID) % 6u;
vec3 pos = verts[vert];
uint strindex = uint(VERTEX_ID)/6u;
vec2 charPos = vec2(float(strindex) + pos.x + general.TextPosition.x, pos.y + general.TextPosition.y);
vec3 pos = verts[vert];
uint strindex = uint(VERTEX_ID) / 6u;
FontGlyphData G = glyphs.data[ str.chars[strindex].x ];
gl_Position = vec4(charPos.xy*2.0f*general.TextSize*general.FontScreenAspect.xy + vec2(-1, -1), 1, 1);
glyphuv.xy = (pos.xy - G.posdata.xy) * G.posdata.zw;
tex = G.uvdata * general.CharacterSize.xyxy;
vec2 charPos =
vec2(float(strindex) + pos.x + general.TextPosition.x, pos.y + general.TextPosition.y);
FontGlyphData G = glyphs.data[str.chars[strindex].x];
gl_Position =
vec4(charPos.xy * 2.0f * general.TextSize * general.FontScreenAspect.xy + vec2(-1, -1), 1, 1);
glyphuv.xy = (pos.xy - G.posdata.xy) * G.posdata.zw;
tex = G.uvdata * general.CharacterSize.xyxy;
}
+208 -203
View File
@@ -1,19 +1,19 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 Baldur Karlsson
* 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
@@ -28,8 +28,8 @@
struct v2f
{
float4 pos : SV_Position;
float4 tex : TEXCOORD0;
float4 pos : SV_Position;
float4 tex : TEXCOORD0;
};
SamplerState pointSampler : register(s0);
@@ -57,234 +57,239 @@ Texture2DMSArray<int4> texDisplayIntTex2DMSArray : register(t29);
uint4 SampleTextureUInt4(uint type, float2 uv, float slice, float mip, int sample, float3 texRes)
{
uint4 col = 0;
uint4 col = 0;
if(type == RESTYPE_TEX1D)
col = texDisplayUIntTex1DArray.Load(int3(uv.x*texRes.x, slice, mip));
else if(type == RESTYPE_TEX3D)
col = texDisplayUIntTex3D.Load(int4(uv.xy*texRes.xy, slice + 0.001f, mip));
else if(type == RESTYPE_TEX2D)
col = texDisplayUIntTex2DArray.Load(int4(uv.xy*texRes.xy, slice, mip));
else if(type == RESTYPE_TEX2D_MS)
{
if(sample < 0)
sample = 0;
col = texDisplayUIntTex2DMSArray.Load(int3(uv.xy*texRes.xy, slice), sample);
}
if(type == RESTYPE_TEX1D)
col = texDisplayUIntTex1DArray.Load(int3(uv.x * texRes.x, slice, mip));
else if(type == RESTYPE_TEX3D)
col = texDisplayUIntTex3D.Load(int4(uv.xy * texRes.xy, slice + 0.001f, mip));
else if(type == RESTYPE_TEX2D)
col = texDisplayUIntTex2DArray.Load(int4(uv.xy * texRes.xy, slice, mip));
else if(type == RESTYPE_TEX2D_MS)
{
if(sample < 0)
sample = 0;
col = texDisplayUIntTex2DMSArray.Load(int3(uv.xy * texRes.xy, slice), sample);
}
return col;
return col;
}
int4 SampleTextureInt4(uint type, float2 uv, float slice, float mip, int sample, float3 texRes)
{
int4 col = 0;
int4 col = 0;
if(type == RESTYPE_TEX1D)
col = texDisplayIntTex1DArray.Load(int3(uv.x*texRes.x, slice, mip));
else if(type == RESTYPE_TEX3D)
col = texDisplayIntTex3D.Load(int4(uv.xy*texRes.xy, slice + 0.001f, mip));
else if(type == RESTYPE_TEX2D)
col = texDisplayIntTex2DArray.Load(int4(uv.xy*texRes.xy, slice, mip));
else if(type == RESTYPE_TEX2D_MS)
{
if(sample < 0)
sample = 0;
col = texDisplayIntTex2DMSArray.Load(int3(uv.xy*texRes.xy, slice), sample);
}
if(type == RESTYPE_TEX1D)
col = texDisplayIntTex1DArray.Load(int3(uv.x * texRes.x, slice, mip));
else if(type == RESTYPE_TEX3D)
col = texDisplayIntTex3D.Load(int4(uv.xy * texRes.xy, slice + 0.001f, mip));
else if(type == RESTYPE_TEX2D)
col = texDisplayIntTex2DArray.Load(int4(uv.xy * texRes.xy, slice, mip));
else if(type == RESTYPE_TEX2D_MS)
{
if(sample < 0)
sample = 0;
col = texDisplayIntTex2DMSArray.Load(int3(uv.xy * texRes.xy, slice), sample);
}
return col;
return col;
}
float4 SampleTextureFloat4(uint type, bool linearSample, float2 uv, float slice, float mip, int sample,
float3 texRes, uint4 YUVRate, uint4 YUVASwizzle)
float4 SampleTextureFloat4(uint type, bool linearSample, float2 uv, float slice, float mip,
int sample, float3 texRes, uint4 YUVRate, uint4 YUVASwizzle)
{
float4 col = 0;
float4 col = 0;
bool interleaved_luma = false;
bool interleaved_luma = false;
// for interleaved 4:2:2, co-ords are in 2x1 blocks and need special processing
if(YUVRate.x == 2 && YUVRate.y == 1 && YUVRate.z == 1)
{
// set the flag so we can post-process the results of the lookup
interleaved_luma = true;
// for interleaved 4:2:2, co-ords are in 2x1 blocks and need special processing
if(YUVRate.x == 2 && YUVRate.y == 1 && YUVRate.z == 1)
{
// set the flag so we can post-process the results of the lookup
interleaved_luma = true;
// downsample texture resolution. uv is already normalised but we need to change the effective
// resolution when multiplying to do a Load()
texRes.xy /= YUVRate.xy;
}
// downsample texture resolution. uv is already normalised but we need to change the effective
// resolution when multiplying to do a Load()
texRes.xy /= YUVRate.xy;
}
if(type == RESTYPE_TEX1D)
{
if(linearSample)
col = texDisplayTex1DArray.SampleLevel(linearSampler, float2(uv.x, slice), mip);
else
col = texDisplayTex1DArray.Load(int3(uv.x*texRes.x, slice, mip));
}
else if(type == RESTYPE_TEX3D)
{
if(linearSample)
col = texDisplayTex3D.SampleLevel(linearSampler, float3(uv.xy, (slice + 0.001f) / texRes.z), mip);
else
col = texDisplayTex3D.Load(int4(uv.xy*texRes.xy, slice + 0.001f, mip));
}
else if(type == RESTYPE_DEPTH)
{
col.r = texDisplayTexDepthArray.Load(int4(uv.xy*texRes.xy, slice, mip)).r;
col.gba = float3(0, 0, 1);
}
else if(type == RESTYPE_DEPTH_STENCIL)
{
col.r = texDisplayTexDepthArray.Load(int4(uv.xy*texRes.xy, slice, mip)).r;
col.g = texDisplayTexStencilArray.Load(int4(uv.xy*texRes.xy, slice, mip)).g/255.0f;
col.ba = float2(0, 1);
}
else if(type == RESTYPE_DEPTH_MS)
{
if(sample < 0)
sample = 0;
if(type == RESTYPE_TEX1D)
{
if(linearSample)
col = texDisplayTex1DArray.SampleLevel(linearSampler, float2(uv.x, slice), mip);
else
col = texDisplayTex1DArray.Load(int3(uv.x * texRes.x, slice, mip));
}
else if(type == RESTYPE_TEX3D)
{
if(linearSample)
col = texDisplayTex3D.SampleLevel(linearSampler, float3(uv.xy, (slice + 0.001f) / texRes.z),
mip);
else
col = texDisplayTex3D.Load(int4(uv.xy * texRes.xy, slice + 0.001f, mip));
}
else if(type == RESTYPE_DEPTH)
{
col.r = texDisplayTexDepthArray.Load(int4(uv.xy * texRes.xy, slice, mip)).r;
col.gba = float3(0, 0, 1);
}
else if(type == RESTYPE_DEPTH_STENCIL)
{
col.r = texDisplayTexDepthArray.Load(int4(uv.xy * texRes.xy, slice, mip)).r;
col.g = texDisplayTexStencilArray.Load(int4(uv.xy * texRes.xy, slice, mip)).g / 255.0f;
col.ba = float2(0, 1);
}
else if(type == RESTYPE_DEPTH_MS)
{
if(sample < 0)
sample = 0;
col.r = texDisplayTexDepthMSArray.Load(int3(uv.xy*texRes.xy, slice), sample).r;
col.gba = float3(0, 0, 1);
}
else if(type == RESTYPE_DEPTH_STENCIL_MS)
{
if(sample < 0)
sample = 0;
col.r = texDisplayTexDepthMSArray.Load(int3(uv.xy * texRes.xy, slice), sample).r;
col.gba = float3(0, 0, 1);
}
else if(type == RESTYPE_DEPTH_STENCIL_MS)
{
if(sample < 0)
sample = 0;
col.r = texDisplayTexDepthMSArray.Load(int3(uv.xy*texRes.xy, slice), sample).r;
col.g = texDisplayTexStencilMSArray.Load(int3(uv.xy*texRes.xy, slice), sample).g/255.0f;
col.ba = float2(0, 1);
}
else if(type == RESTYPE_TEX2D_MS)
{
if(sample < 0)
{
int sampleCount = -sample;
col.r = texDisplayTexDepthMSArray.Load(int3(uv.xy * texRes.xy, slice), sample).r;
col.g = texDisplayTexStencilMSArray.Load(int3(uv.xy * texRes.xy, slice), sample).g / 255.0f;
col.ba = float2(0, 1);
}
else if(type == RESTYPE_TEX2D_MS)
{
if(sample < 0)
{
int sampleCount = -sample;
// worst resolve you've seen in your life
for(int i=0; i < sampleCount; i++)
col += texDisplayTex2DMSArray.Load(int3(uv.xy*texRes.xy, slice), i);
// worst resolve you've seen in your life
for(int i = 0; i < sampleCount; i++)
col += texDisplayTex2DMSArray.Load(int3(uv.xy * texRes.xy, slice), i);
col /= float(sampleCount);
}
else
{
col = texDisplayTex2DMSArray.Load(int3(uv.xy*texRes.xy, slice), sample);
}
}
else if(type == RESTYPE_TEX2D)
{
if(linearSample)
col = texDisplayTex2DArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip);
else
col = texDisplayTex2DArray.Load(int4(uv.xy*texRes.xy, slice, mip));
}
col /= float(sampleCount);
}
else
{
col = texDisplayTex2DMSArray.Load(int3(uv.xy * texRes.xy, slice), sample);
}
}
else if(type == RESTYPE_TEX2D)
{
if(linearSample)
col = texDisplayTex2DArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip);
else
col = texDisplayTex2DArray.Load(int4(uv.xy * texRes.xy, slice, mip));
}
if(YUVRate.w > 0)
{
float4 col2 = 0;
if(YUVRate.w > 0)
{
float4 col2 = 0;
// look up the second YUV plane, in case we need it
if(linearSample)
col2 = texDisplayYUVArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip);
else
col2 = texDisplayYUVArray.Load(int4(uv.xy*texRes.xy/YUVRate.xy, slice, mip));
// look up the second YUV plane, in case we need it
if(linearSample)
col2 = texDisplayYUVArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip);
else
col2 = texDisplayYUVArray.Load(int4(uv.xy * texRes.xy / YUVRate.xy, slice, mip));
// store the data from both planes for swizzling
float data[] = {
col.x, col.y, col.z, col.w,
col2.x, col2.y, col2.z, col2.w,
};
// store the data from both planes for swizzling
float data[] = {
col.x, col.y, col.z, col.w, col2.x, col2.y, col2.z, col2.w,
};
// use the specified channel swizzle to source the YUVA data
float Y = data[YUVASwizzle.x];
float U = data[YUVASwizzle.y];
float V = data[YUVASwizzle.z];
float A = 1.0f;
// use the specified channel swizzle to source the YUVA data
float Y = data[YUVASwizzle.x];
float U = data[YUVASwizzle.y];
float V = data[YUVASwizzle.z];
float A = 1.0f;
if(YUVASwizzle.w != 0xff)
A = data[YUVASwizzle.w];
// if we have 4:2:2 interleaved luma, this needs special processing
if(interleaved_luma)
{
// in interleaved 4:2:2 we have 2x1 blocks of texels within a single sample.
// Chroma 'just works' in 4:2:2 because the shared U and V for a block are stored in G and A,
// and for linear sampling the texture filtering does the right thing by interpolating G0 (U0)
// with G1 (U1) and A0 (V0) with A1 (V1) for two blocks 0 and 1 of 2x1 texels.
//
// However consider 2x1 blocks of luma like this:
//
// left current right
// v v v
// -----+--------+-------------------+--------+---
// . Y1 | Y0 Y1 | (a) Y0 (b) Y1 (c) | Y0 Y1 | ..
// -----+--------+-------------------+--------+---
//
// We define lumalerp = 0.0 to 1.0 across the block. The Y0 and Y1 centres are at 0.25 and 0.75
// respectively.
//
// For nearest sampling it's relatively simple, we just need to bisect by 0.5 and select either
// our Y0 or Y1. For linear sampling it's more complex:
//
// (a) between the left edge of the current block and the Y0 centre we need to do:
// Y = lerp(leftY1, currentY0)
// (b) between the Y0 and Y1 centres we need to do:
// Y = lerp(currentY0, currentY1)
// (c) between the Y1 centre and the right edge of the current block we need to do:
// Y = lerp(currentY1, rightY0)
if(YUVASwizzle.w != 0xff)
A = data[YUVASwizzle.w];
// calculate the actual X co-ordinate at luma rate (we halved the rate above for loading the
// texel)
float x = uv.x*texRes.x*YUVRate.x;
// if we have 4:2:2 interleaved luma, this needs special processing
if(interleaved_luma)
{
// in interleaved 4:2:2 we have 2x1 blocks of texels within a single sample.
// Chroma 'just works' in 4:2:2 because the shared U and V for a block are stored in G and A,
// and for linear sampling the texture filtering does the right thing by interpolating G0 (U0)
// with G1 (U1) and A0 (V0) with A1 (V1) for two blocks 0 and 1 of 2x1 texels.
//
// However consider 2x1 blocks of luma like this:
//
// left current right
// v v v
// -----+--------+-------------------+--------+---
// . Y1 | Y0 Y1 | (a) Y0 (b) Y1 (c) | Y0 Y1 | ..
// -----+--------+-------------------+--------+---
//
// We define lumalerp = 0.0 to 1.0 across the block. The Y0 and Y1 centres are at 0.25 and
// 0.75
// respectively.
//
// For nearest sampling it's relatively simple, we just need to bisect by 0.5 and select
// either
// our Y0 or Y1. For linear sampling it's more complex:
//
// (a) between the left edge of the current block and the Y0 centre we need to do:
// Y = lerp(leftY1, currentY0)
// (b) between the Y0 and Y1 centres we need to do:
// Y = lerp(currentY0, currentY1)
// (c) between the Y1 centre and the right edge of the current block we need to do:
// Y = lerp(currentY1, rightY0)
// calculate the lerp value to know where we are by rounding down to the nearest even X and
// subtracting that from our X, giving a [0, 2] range, then halving it.
float lumalerp = (x - (int(x) & ~1))/2.0f;
// calculate the actual X co-ordinate at luma rate (we halved the rate above for loading the
// texel)
float x = uv.x * texRes.x * YUVRate.x;
if(!linearSample)
{
// simple nearest - if we're on the left half we use Y0, on the right half we use Y1
if(lumalerp < 0.5f)
Y = col.r;
else
Y = col.b;
}
else
{
// round UV x to pixel centre so we get precisely the current 2x1 texel.
// We keep UV y the same so that we at least get vertical interpolation from the hardware.
uv.x = floor(uv.x*texRes.x)/texRes.x + 1.0f / (texRes.x*YUVRate.x);
// calculate the lerp value to know where we are by rounding down to the nearest even X and
// subtracting that from our X, giving a [0, 2] range, then halving it.
float lumalerp = (x - (int(x) & ~1)) / 2.0f;
// sample current texel, this gives us currentY0, currentY1 for our own texture.
// The previous sample that we did above was fine for chroma, but is nonsense for luma
col.xy = texDisplayTex2DArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip).rb;
if(!linearSample)
{
// simple nearest - if we're on the left half we use Y0, on the right half we use Y1
if(lumalerp < 0.5f)
Y = col.r;
else
Y = col.b;
}
else
{
// round UV x to pixel centre so we get precisely the current 2x1 texel.
// We keep UV y the same so that we at least get vertical interpolation from the hardware.
uv.x = floor(uv.x * texRes.x) / texRes.x + 1.0f / (texRes.x * YUVRate.x);
if(lumalerp < 0.25f)
{
// case (a). Fetch the left neighbour block's Y1 and interpolate up to it
float leftY1 = texDisplayTex2DArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip, int2(-1,0)).b;
// sample current texel, this gives us currentY0, currentY1 for our own texture.
// The previous sample that we did above was fine for chroma, but is nonsense for luma
col.xy = texDisplayTex2DArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip).rb;
Y = lerp(leftY1, col.x, lumalerp*2.0f + 0.5f);
}
else if(lumalerp < 0.75f)
{
// case (b). Interpolate between Y0 and Y1
Y = lerp(col.x, col.y, (lumalerp-0.25f)*2.0f);
}
else
{
// case (c). Fetch the right neighbour block's Y0 and interpolate up to it
float rightY0 = texDisplayTex2DArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip, int2(1,0)).r;
if(lumalerp < 0.25f)
{
// case (a). Fetch the left neighbour block's Y1 and interpolate up to it
float leftY1 = texDisplayTex2DArray
.SampleLevel(linearSampler, float3(uv.xy, slice), mip, int2(-1, 0))
.b;
Y = lerp(col.y, rightY0, (lumalerp-0.75f)*2.0f);
}
}
}
Y = lerp(leftY1, col.x, lumalerp * 2.0f + 0.5f);
}
else if(lumalerp < 0.75f)
{
// case (b). Interpolate between Y0 and Y1
Y = lerp(col.x, col.y, (lumalerp - 0.25f) * 2.0f);
}
else
{
// case (c). Fetch the right neighbour block's Y0 and interpolate up to it
float rightY0 =
texDisplayTex2DArray.SampleLevel(linearSampler, float3(uv.xy, slice), mip, int2(1, 0)).r;
// Y goes in green channel, U in blue, V in red
col = float4(V, Y, U, A);
}
Y = lerp(col.y, rightY0, (lumalerp - 0.75f) * 2.0f);
}
}
}
return col;
// Y goes in green channel, U in blue, V in red
col = float4(V, Y, U, A);
}
return col;
}
+290 -305
View File
@@ -1,19 +1,19 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 Baldur Karlsson
* 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
@@ -23,46 +23,39 @@
* THE SOFTWARE.
******************************************************************************/
v2f RENDERDOC_DebugVS(uint vertID : SV_VertexID)
{
v2f OUT = (v2f)0;
v2f OUT = (v2f)0;
float2 positions[] = {
float2(0.0f, 0.0f),
float2(0.0f, -1.0f),
float2(1.0f, 0.0f),
float2(1.0f, -1.0f),
float2(0.0f, 0.0f),
};
float2 positions[] = {
float2(0.0f, 0.0f), float2(0.0f, -1.0f), float2(1.0f, 0.0f),
float2(1.0f, -1.0f), float2(0.0f, 0.0f),
};
float2 pos = positions[vertID];
float2 pos = positions[vertID];
if(LineStrip)
{
float2 strippositions[] = {
float2(0.0f, -1.0f),
float2(1.0f, -1.0f),
float2(1.0f, 0.0f),
float2(0.0f, 0.0f),
float2(0.0f, -1.1f),
};
if(LineStrip)
{
float2 strippositions[] = {
float2(0.0f, -1.0f), float2(1.0f, -1.0f), float2(1.0f, 0.0f),
float2(0.0f, 0.0f), float2(0.0f, -1.1f),
};
pos = strippositions[vertID];
}
pos = strippositions[vertID];
}
OUT.pos = float4(Position.xy + pos.xy*TextureResolution.xy*Scale*ScreenAspect.xy, 0, 1)-float4(1.0,-1.0,0,0);
OUT.tex.xy = float2(pos.x, -pos.y);
return OUT;
OUT.pos = float4(Position.xy + pos.xy * TextureResolution.xy * Scale * ScreenAspect.xy, 0, 1) -
float4(1.0, -1.0, 0, 0);
OUT.tex.xy = float2(pos.x, -pos.y);
return OUT;
}
float ConvertSRGBToLinear(float srgb)
{
if (srgb <= 0.04045f)
return srgb / 12.92f;
else
return pow((saturate(srgb) + 0.055f) / 1.055f, 2.4f);
if(srgb <= 0.04045f)
return srgb / 12.92f;
else
return pow((saturate(srgb) + 0.055f) / 1.055f, 2.4f);
}
// main texture display shader, used for the texture viewer. It samples the right resource
@@ -71,64 +64,65 @@ float ConvertSRGBToLinear(float srgb)
// or range clipping
float4 RENDERDOC_TexDisplayPS(v2f IN) : SV_Target0
{
bool uintTex = OutputDisplayFormat & TEXDISPLAY_UINT_TEX;
bool sintTex = OutputDisplayFormat & TEXDISPLAY_SINT_TEX;
bool uintTex = OutputDisplayFormat & TEXDISPLAY_UINT_TEX;
bool sintTex = OutputDisplayFormat & TEXDISPLAY_SINT_TEX;
float4 col = 0;
uint4 ucol = 0;
int4 scol = 0;
float4 col = 0;
uint4 ucol = 0;
int4 scol = 0;
float2 uvTex = IN.tex.xy;
float2 uvTex = IN.tex.xy;
if(FlipY)
uvTex.y = 1.0f - uvTex.y;
if(FlipY)
uvTex.y = 1.0f - uvTex.y;
if(uintTex)
{
ucol = SampleTextureUInt4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK,
uvTex, Slice, MipLevel, SampleIdx, TextureResolutionPS);
}
else if(sintTex)
{
scol = SampleTextureInt4 (OutputDisplayFormat & TEXDISPLAY_TYPEMASK,
uvTex, Slice, MipLevel, SampleIdx, TextureResolutionPS);
}
else
{
col = SampleTextureFloat4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK, (ScalePS < 1 && MipLevel == 0),
uvTex, Slice, MipLevel, SampleIdx, TextureResolutionPS, YUVDownsampleRate, YUVAChannels);
}
if(RawOutput)
{
if(uintTex)
return asfloat(ucol);
else if(sintTex)
return asfloat(scol);
else
return col;
}
if(uintTex)
{
ucol = SampleTextureUInt4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK, uvTex, Slice, MipLevel,
SampleIdx, TextureResolutionPS);
}
else if(sintTex)
{
scol = SampleTextureInt4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK, uvTex, Slice, MipLevel,
SampleIdx, TextureResolutionPS);
}
else
{
col = SampleTextureFloat4(OutputDisplayFormat & TEXDISPLAY_TYPEMASK,
(ScalePS < 1 && MipLevel == 0), uvTex, Slice, MipLevel, SampleIdx,
TextureResolutionPS, YUVDownsampleRate, YUVAChannels);
}
if(WireframeColour.y > 0.0f)
{
// assume col is now YUVA, perform a default conversion to RGBA
const float Kr = 0.2126f;
const float Kb = 0.0722f;
if(RawOutput)
{
if(uintTex)
return asfloat(ucol);
else if(sintTex)
return asfloat(scol);
else
return col;
}
float L = col.g;
float Pb = col.b - 0.5f;
float Pr = col.r - 0.5f;
if(WireframeColour.y > 0.0f)
{
// assume col is now YUVA, perform a default conversion to RGBA
const float Kr = 0.2126f;
const float Kb = 0.0722f;
col.b = L + (Pb / 0.5f) * (1 - Kb);
col.r = L + (Pr / 0.5f) * (1 - Kr);
col.g = (L - Kr * col.r - Kb * col.b) / (1.0f - Kr - Kb);
}
float L = col.g;
float Pb = col.b - 0.5f;
float Pr = col.r - 0.5f;
col.b = L + (Pb / 0.5f) * (1 - Kb);
col.r = L + (Pr / 0.5f) * (1 - Kr);
col.g = (L - Kr * col.r - Kb * col.b) / (1.0f - Kr - Kb);
}
if(HeatmapMode)
{
if(HeatmapMode == HEATMAP_LINEAR)
{
// cast the float value to an integer with safe rounding, then return the
// cast the float value to an integer with safe rounding, then return the
int bucket = int(floor(col.x + 0.25f));
bucket = max(bucket, 0);
@@ -144,7 +138,7 @@ float4 RENDERDOC_TexDisplayPS(v2f IN) : SV_Target0
float area = max(col.x, 0.001f);
int bucket = 2 + int( floor(20.0f - 20.1f * (1.0f - exp(-0.4f * area) ) ) );
int bucket = 2 + int(floor(20.0f - 20.1f * (1.0f - exp(-0.4f * area))));
return ColorRamp[bucket];
}
@@ -154,194 +148,178 @@ float4 RENDERDOC_TexDisplayPS(v2f IN) : SV_Target0
}
}
// RGBM encoding
if(WireframeColour.x > 0.0f)
{
if(uintTex)
ucol = float4(ucol.rgb * ucol.a * (uint)(WireframeColour.x), 1.0f);
else if(sintTex)
scol = float4(scol.rgb * scol.a * (int)(WireframeColour.x), 1.0f);
else
col = float4(col.rgb * col.a * WireframeColour.x, 1.0f);
}
// RGBM encoding
if(WireframeColour.x > 0.0f)
{
if(uintTex)
ucol = float4(ucol.rgb * ucol.a * (uint)(WireframeColour.x), 1.0f);
else if(sintTex)
scol = float4(scol.rgb * scol.a * (int)(WireframeColour.x), 1.0f);
else
col = float4(col.rgb * col.a * WireframeColour.x, 1.0f);
}
if(uintTex)
col = (float4)(ucol);
else if(sintTex)
col = (float4)(scol);
if(uintTex)
col = (float4)(ucol);
else if(sintTex)
col = (float4)(scol);
float4 pre_range_col = col;
float4 pre_range_col = col;
col = ((col - RangeMinimum)*InverseRangeSize);
col = ((col - RangeMinimum) * InverseRangeSize);
// workaround for D3DCompiler bug. For some reason it assumes texture samples can
// never come back as NaN, so involving a cbuffer value like this here ensures
// the below isnan()s don't get optimised out.
if(Channels.x < 0.5f) col.x = pre_range_col.x = AlwaysZero;
if(Channels.y < 0.5f) col.y = pre_range_col.y = AlwaysZero;
if(Channels.z < 0.5f) col.z = pre_range_col.z = AlwaysZero;
if(Channels.w < 0.5f) col.w = pre_range_col.w = 1.0f-AlwaysZero;
// workaround for D3DCompiler bug. For some reason it assumes texture samples can
// never come back as NaN, so involving a cbuffer value like this here ensures
// the below isnan()s don't get optimised out.
if(Channels.x < 0.5f)
col.x = pre_range_col.x = AlwaysZero;
if(Channels.y < 0.5f)
col.y = pre_range_col.y = AlwaysZero;
if(Channels.z < 0.5f)
col.z = pre_range_col.z = AlwaysZero;
if(Channels.w < 0.5f)
col.w = pre_range_col.w = 1.0f - AlwaysZero;
// show nans, infs and negatives
if(OutputDisplayFormat & TEXDISPLAY_NANS)
{
if(isnan(pre_range_col.r) || isnan(pre_range_col.g) || isnan(pre_range_col.b) || isnan(pre_range_col.a))
return float4(1, 0, 0, 1);
if(isinf(pre_range_col.r) || isinf(pre_range_col.g) || isinf(pre_range_col.b) || isinf(pre_range_col.a))
return float4(0, 1, 0, 1);
// show nans, infs and negatives
if(OutputDisplayFormat & TEXDISPLAY_NANS)
{
if(isnan(pre_range_col.r) || isnan(pre_range_col.g) || isnan(pre_range_col.b) ||
isnan(pre_range_col.a))
return float4(1, 0, 0, 1);
if(pre_range_col.r < 0 || pre_range_col.g < 0 || pre_range_col.b < 0 || pre_range_col.a < 0)
return float4(0, 0, 1, 1);
col = float4(dot(col.xyz, float3(0.2126, 0.7152, 0.0722)).xxx, 1);
}
else if(OutputDisplayFormat & TEXDISPLAY_CLIPPING)
{
if(col.r < 0 || col.g < 0 || col.b < 0 || col.a < 0)
return float4(1, 0, 0, 1);
if(isinf(pre_range_col.r) || isinf(pre_range_col.g) || isinf(pre_range_col.b) ||
isinf(pre_range_col.a))
return float4(0, 1, 0, 1);
if(col.r > (1+FLT_EPSILON) || col.g > (1+FLT_EPSILON) || col.b > (1+FLT_EPSILON) || col.a > (1+FLT_EPSILON))
return float4(0, 1, 0, 1);
col = float4(dot(col.xyz, float3(0.2126, 0.7152, 0.0722)).xxx, 1);
}
else
{
// if only one channel is selected
if(dot(Channels, 1) == 1)
{
// if it's alpha, just move it into rgb
// otherwise, select the channel that's on and replicate it across all channels
if(Channels.a == 1)
col = float4(col.aaa, 1);
else
col = float4(dot(col.rgb, 1).xxx, 1);
}
}
if(pre_range_col.r < 0 || pre_range_col.g < 0 || pre_range_col.b < 0 || pre_range_col.a < 0)
return float4(0, 0, 1, 1);
if(OutputDisplayFormat & TEXDISPLAY_GAMMA_CURVE)
{
col.rgb = float3(ConvertSRGBToLinear(col.r), ConvertSRGBToLinear(col.g), ConvertSRGBToLinear(col.b));
}
return col;
col = float4(dot(col.xyz, float3(0.2126, 0.7152, 0.0722)).xxx, 1);
}
else if(OutputDisplayFormat & TEXDISPLAY_CLIPPING)
{
if(col.r < 0 || col.g < 0 || col.b < 0 || col.a < 0)
return float4(1, 0, 0, 1);
if(col.r > (1 + FLT_EPSILON) || col.g > (1 + FLT_EPSILON) || col.b > (1 + FLT_EPSILON) ||
col.a > (1 + FLT_EPSILON))
return float4(0, 1, 0, 1);
col = float4(dot(col.xyz, float3(0.2126, 0.7152, 0.0722)).xxx, 1);
}
else
{
// if only one channel is selected
if(dot(Channels, 1) == 1)
{
// if it's alpha, just move it into rgb
// otherwise, select the channel that's on and replicate it across all channels
if(Channels.a == 1)
col = float4(col.aaa, 1);
else
col = float4(dot(col.rgb, 1).xxx, 1);
}
}
if(OutputDisplayFormat & TEXDISPLAY_GAMMA_CURVE)
{
col.rgb =
float3(ConvertSRGBToLinear(col.r), ConvertSRGBToLinear(col.g), ConvertSRGBToLinear(col.b));
}
return col;
}
struct MultipleOutput
{
float4 col0 : SV_Target0;
float4 col1 : SV_Target1;
float4 col2 : SV_Target2;
float4 col3 : SV_Target3;
float4 col4 : SV_Target4;
float4 col5 : SV_Target5;
float4 col6 : SV_Target6;
float4 col7 : SV_Target7;
float4 col0 : SV_Target0;
float4 col1 : SV_Target1;
float4 col2 : SV_Target2;
float4 col3 : SV_Target3;
float4 col4 : SV_Target4;
float4 col5 : SV_Target5;
float4 col6 : SV_Target6;
float4 col7 : SV_Target7;
};
float4 RENDERDOC_FullscreenVS(uint id : SV_VertexID) : SV_Position
{
float4 pos[] = {
float4( -1.0f, 1.0f, 0.0f, 1.0f),
float4( 3.0f, 1.0f, 0.0f, 1.0f),
float4( -1.0f, -3.0f, 0.0f, 1.0f)
};
float4 pos[] = {float4(-1.0f, 1.0f, 0.0f, 1.0f), float4(3.0f, 1.0f, 0.0f, 1.0f),
float4(-1.0f, -3.0f, 0.0f, 1.0f)};
return pos[id];
return pos[id];
}
MultipleOutput RENDERDOC_WireframePS()
{
MultipleOutput OUT = (MultipleOutput)0;
MultipleOutput OUT = (MultipleOutput)0;
OUT.col0 =
OUT.col1 =
OUT.col2 =
OUT.col3 =
OUT.col4 =
OUT.col5 =
OUT.col6 =
OUT.col7 =
float4(WireframeColour.xyz, 1);
OUT.col0 = OUT.col1 = OUT.col2 = OUT.col3 = OUT.col4 = OUT.col5 = OUT.col6 = OUT.col7 =
float4(WireframeColour.xyz, 1);
return OUT;
return OUT;
}
cbuffer overlayconsts : register(b0)
{
float4 overlaycol;
float4 overlaycol;
};
MultipleOutput RENDERDOC_FixedColPS()
{
MultipleOutput OUT = (MultipleOutput)0;
MultipleOutput OUT = (MultipleOutput)0;
OUT.col0 =
OUT.col1 =
OUT.col2 =
OUT.col3 =
OUT.col4 =
OUT.col5 =
OUT.col6 =
OUT.col7 =
overlaycol;
OUT.col0 = OUT.col1 = OUT.col2 = OUT.col3 = OUT.col4 = OUT.col5 = OUT.col6 = OUT.col7 = overlaycol;
return OUT;
return OUT;
}
float4 RENDERDOC_OutlinePS(float4 pos : SV_Position) : SV_Target0
{
float4 ret = Channels;
float4 ret = Channels;
float2 rectPos = pos.xy - float2(RangeMinimum, InverseRangeSize);
float2 rectSize = TextureResolutionPS.xy;
float2 ab = fmod(rectPos.xy, 32.0.xx);
float2 rectPos = pos.xy - float2(RangeMinimum, InverseRangeSize);
float2 rectSize = TextureResolutionPS.xy;
bool checkerVariant = (
(ab.x < 16 && ab.y < 16) ||
(ab.x > 16 && ab.y > 16)
);
float2 ab = fmod(rectPos.xy, 32.0.xx);
if(OutputDisplayFormat == 0)
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f ||
rectPos.y < 3.0f || rectPos.y > rectSize.y - 3.0f)
{
ret.rgb = WireframeColour.rgb;
ret.a = 1.0f;
}
}
else
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f ||
rectPos.y < 3.0f || rectPos.y > rectSize.y - 3.0f)
{
ret = checkerVariant ? float4(1, 1, 1, 1) : float4(0, 0, 0, 1);
}
else
{
ret = float4(0, 0, 0, 0);
}
}
bool checkerVariant = ((ab.x < 16 && ab.y < 16) || (ab.x > 16 && ab.y > 16));
return ret;
if(OutputDisplayFormat == 0)
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f || rectPos.y < 3.0f ||
rectPos.y > rectSize.y - 3.0f)
{
ret.rgb = WireframeColour.rgb;
ret.a = 1.0f;
}
}
else
{
if(rectPos.x < 3.0f || rectPos.x > rectSize.x - 3.0f || rectPos.y < 3.0f ||
rectPos.y > rectSize.y - 3.0f)
{
ret = checkerVariant ? float4(1, 1, 1, 1) : float4(0, 0, 0, 1);
}
else
{
ret = float4(0, 0, 0, 0);
}
}
return ret;
}
float4 RENDERDOC_CheckerboardPS(float4 pos : SV_Position) : SV_Target0
{
float2 ab = fmod(pos.xy, 128.0.xx);
float2 ab = fmod(pos.xy, 128.0.xx);
if(
(ab.x < 64 && ab.y < 64) ||
(ab.x > 64 && ab.y > 64)
)
{
return float4(WireframeColour.rgb*WireframeColour.rgb, 1);
}
if((ab.x < 64 && ab.y < 64) || (ab.x > 64 && ab.y > 64))
{
return float4(WireframeColour.rgb * WireframeColour.rgb, 1);
}
return float4(Channels.rgb*Channels.rgb, 1);
return float4(Channels.rgb * Channels.rgb, 1);
}
////////////////////////////////////////////////////////////////////////////////////////////
@@ -351,37 +329,39 @@ float4 RENDERDOC_CheckerboardPS(float4 pos : SV_Position) : SV_Target0
// https://github.com/selfshadow/demos/blob/master/QuadShading/QuadShading.fx
////////////////////////////////////////////////////////////////////////////////////////////
RWTexture2DArray<uint> overdrawUAV : register(u0);
RWTexture2DArray<uint> overdrawUAV : register(u0);
Texture2DArray<uint> overdrawSRV : register(t0);
[earlydepthstencil]
void RENDERDOC_QuadOverdrawPS(float4 vpos : SV_Position, uint c0 : SV_Coverage)
{
// Obtain coverage for all pixels in the quad, via 'message passing'*.
// (* For more details, see:
// "Shader Amortization using Pixel Quad Message Passing", Eric Penner, GPU Pro 2.)
uint2 p = uint2(vpos.xy) & 1;
int2 sign = p ? -1 : 1;
uint c1 = c0 + sign.x*ddx_fine(c0);
uint c2 = c0 + sign.y*ddy_fine(c0);
uint c3 = c2 + sign.x*ddx_fine(c2);
[earlydepthstencil] void RENDERDOC_QuadOverdrawPS(float4 vpos
: SV_Position, uint c0
: SV_Coverage) {
// Obtain coverage for all pixels in the quad, via 'message passing'*.
// (* For more details, see:
// "Shader Amortization using Pixel Quad Message Passing", Eric Penner, GPU Pro 2.)
uint2 p = uint2(vpos.xy) & 1;
int2 sign = p ? -1 : 1;
uint c1 = c0 + sign.x * ddx_fine(c0);
uint c2 = c0 + sign.y * ddy_fine(c0);
uint c3 = c2 + sign.x * ddx_fine(c2);
// Count the live pixels, minus 1 (zero indexing)
uint pixelCount = c0 + c1 + c2 + c3 - 1;
// Count the live pixels, minus 1 (zero indexing)
uint pixelCount = c0 + c1 + c2 + c3 - 1;
uint3 quad = uint3(vpos.xy*0.5, pixelCount);
InterlockedAdd(overdrawUAV[quad], 1);
uint3 quad = uint3(vpos.xy * 0.5, pixelCount);
InterlockedAdd(overdrawUAV[quad], 1);
}
float4 RENDERDOC_QOResolvePS(float4 vpos : SV_POSITION) : SV_Target0
float4 RENDERDOC_QOResolvePS(float4 vpos
: SV_POSITION)
: SV_Target0
{
uint2 quad = vpos.xy*0.5;
uint2 quad = vpos.xy * 0.5;
uint overdraw = 0;
for(int i = 0; i < 4; i++)
overdraw += overdrawSRV[uint3(quad, i)]/(i + 1);
uint overdraw = 0;
for(int i = 0; i < 4; i++)
overdraw += overdrawSRV[uint3(quad, i)] / (i + 1);
return float(overdraw).xxxx;
return float(overdraw).xxxx;
}
////////////////////////////////////////////////////////////////////////////////////////////
@@ -393,19 +373,19 @@ float4 RENDERDOC_QOResolvePS(float4 vpos : SV_POSITION) : SV_Target0
cbuffer cb0 : register(b0)
{
uint4 src_coord; // x, y, mip/sample, slice
uint4 src_coord; // x, y, mip/sample, slice
bool multisampled;
bool is_float;
bool is_uint;
bool is_int;
bool multisampled;
bool is_float;
bool is_uint;
bool is_int;
};
cbuffer cb1 : register(b1)
{
uint2 dst_coord;
bool copy_depth;
bool copy_stencil;
uint2 dst_coord;
bool copy_depth;
bool copy_stencil;
};
Texture2DArray<float2> copyin_depth : register(t0);
@@ -428,70 +408,75 @@ RWTexture2D<float4> copyout_float : register(u1);
RWTexture2D<uint4> copyout_uint : register(u2);
RWTexture2D<int4> copyout_int : register(u3);
[numthreads(1, 1, 1)]
void RENDERDOC_PixelHistoryUnused()
[numthreads(1, 1, 1)] void RENDERDOC_PixelHistoryUnused()
{
copyout_depth[dst_coord.xy].rg = float2(-1.0f, -1.0f);
copyout_depth[dst_coord.xy].rg = float2(-1.0f, -1.0f);
}
[numthreads(1, 1, 1)]
void RENDERDOC_PixelHistoryCopyPixel()
[numthreads(1, 1, 1)] void RENDERDOC_PixelHistoryCopyPixel()
{
if(multisampled)
{
if(copy_depth || copy_stencil)
{
float2 val = float2(copyin_depth_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)].r, -1.0f);
if(multisampled)
{
if(copy_depth || copy_stencil)
{
float2 val =
float2(copyin_depth_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)].r, -1.0f);
if(copy_stencil) val.g = (float)copyin_stencil_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)].g;
if(copy_stencil)
val.g = (float)copyin_stencil_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)].g;
copyout_depth[dst_coord.xy].rg = val;
}
else
{
if(is_float)
{
copyout_float[dst_coord.xy] = copyin_float_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_uint)
{
copyout_uint[dst_coord.xy] = copyin_uint_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_int)
{
copyout_int[dst_coord.xy] = copyin_int_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
}
}
else
{
if(copy_depth || copy_stencil)
{
float2 val = float2(copyin_depth.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)].r, -1.0f);
copyout_depth[dst_coord.xy].rg = val;
}
else
{
if(is_float)
{
copyout_float[dst_coord.xy] =
copyin_float_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_uint)
{
copyout_uint[dst_coord.xy] =
copyin_uint_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_int)
{
copyout_int[dst_coord.xy] =
copyin_int_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
}
}
else
{
if(copy_depth || copy_stencil)
{
float2 val = float2(copyin_depth.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)].r, -1.0f);
if(copy_stencil) val.g = (float)copyin_stencil.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)].g;
if(copy_stencil)
val.g = (float)copyin_stencil.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)].g;
copyout_depth[dst_coord.xy].rg = val;
}
else
{
if(is_float)
{
copyout_float[dst_coord.xy] = copyin_float.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_uint)
{
copyout_uint[dst_coord.xy] = copyin_uint.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_int)
{
copyout_int[dst_coord.xy] = copyin_int.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
}
}
copyout_depth[dst_coord.xy].rg = val;
}
else
{
if(is_float)
{
copyout_float[dst_coord.xy] =
copyin_float.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_uint)
{
copyout_uint[dst_coord.xy] = copyin_uint.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
else if(is_int)
{
copyout_int[dst_coord.xy] = copyin_int.mips[src_coord.z][uint3(src_coord.xy, src_coord.w)];
}
}
}
}
float4 RENDERDOC_PrimitiveIDPS(uint prim : SV_PrimitiveID) : SV_Target0
{
return asfloat(prim).xxxx;
return asfloat(prim).xxxx;
}
+31 -35
View File
@@ -1,19 +1,19 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 Baldur Karlsson
* 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
@@ -28,48 +28,45 @@
struct glyph
{
float4 posdata;
float4 uvdata;
float4 posdata;
float4 uvdata;
};
cbuffer glyphdata : register(b1)
{
glyph glyphs[127-32];
glyph glyphs[127 - 32];
};
cbuffer stringdata : register(b2)
{
uint4 chars[256];
uint4 chars[256];
};
struct v2f
{
float4 pos : SV_Position;
float4 tex : TEX;
float2 glyphuv : GLYPH;
float4 pos : SV_Position;
float4 tex : TEX;
float2 glyphuv : GLYPH;
};
v2f RENDERDOC_TextVS(uint vid : SV_VertexID, uint inst : SV_InstanceID)
{
v2f OUT = (v2f)0;
v2f OUT = (v2f)0;
float2 verts[] = {
float2( 0.0, 0.0),
float2( 1.0, 0.0),
float2( 0.0, 1.0),
float2( 1.0, 1.0),
};
float2 verts[] = {
float2(0.0, 0.0), float2(1.0, 0.0), float2(0.0, 1.0), float2(1.0, 1.0),
};
float2 pos = verts[vid];
float2 pos = verts[vid];
float2 charPos = float2(float(inst) + pos.x + TextPosition.x, -pos.y - TextPosition.y);
glyph G = glyphs[ chars[inst].x ];
float2 charPos = float2(float(inst) + pos.x + TextPosition.x, -pos.y - TextPosition.y);
glyph G = glyphs[chars[inst].x];
OUT.pos = float4(charPos.xy*2.0f*TextSize*FontScreenAspect.xy + float2(-1, 1), 1, 1);
OUT.glyphuv.xy = (pos.xy - G.posdata.xy) * G.posdata.zw;
OUT.tex = G.uvdata * CharacterSize.xyxy;
OUT.pos = float4(charPos.xy * 2.0f * TextSize * FontScreenAspect.xy + float2(-1, 1), 1, 1);
OUT.glyphuv.xy = (pos.xy - G.posdata.xy) * G.posdata.zw;
OUT.tex = G.uvdata * CharacterSize.xyxy;
return OUT;
return OUT;
}
SamplerState pointSample : register(s0);
@@ -79,16 +76,15 @@ Texture2D fontTexture : register(t0);
float4 RENDERDOC_TextPS(v2f IN) : SV_Target0
{
float text = 0;
float text = 0;
if(IN.glyphuv.x >= 0.0f && IN.glyphuv.x <= 1.0f &&
IN.glyphuv.y >= 0.0f && IN.glyphuv.y <= 1.0f)
{
float2 uv;
uv.x = lerp(IN.tex.x, IN.tex.z, IN.glyphuv.x);
uv.y = lerp(IN.tex.y, IN.tex.w, IN.glyphuv.y);
text = fontTexture.Sample(linearSample, uv.xy).x;
}
if(IN.glyphuv.x >= 0.0f && IN.glyphuv.x <= 1.0f && IN.glyphuv.y >= 0.0f && IN.glyphuv.y <= 1.0f)
{
float2 uv;
uv.x = lerp(IN.tex.x, IN.tex.z, IN.glyphuv.x);
uv.y = lerp(IN.tex.y, IN.tex.w, IN.glyphuv.y);
text = fontTexture.Sample(linearSample, uv.xy).x;
}
return float4(text.xxx, saturate(text + 0.5f));
return float4(text.xxx, saturate(text + 0.5f));
}
+253 -246
View File
@@ -1,19 +1,19 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 Baldur Karlsson
* 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
@@ -31,111 +31,115 @@ RWBuffer<float4> MinMaxDestFloat : register(u0);
RWBuffer<uint4> MinMaxDestUInt : register(u1);
RWBuffer<int4> MinMaxDestInt : register(u2);
[numthreads(HGRAM_TILES_PER_BLOCK, HGRAM_TILES_PER_BLOCK, 1)]
void RENDERDOC_TileMinMaxCS(uint3 tid : SV_GroupThreadID, uint3 gid : SV_GroupID)
[numthreads(HGRAM_TILES_PER_BLOCK, HGRAM_TILES_PER_BLOCK, 1)] void RENDERDOC_TileMinMaxCS(
uint3 tid
: SV_GroupThreadID, uint3 gid
: SV_GroupID)
{
uint texType = SHADER_RESTYPE;
uint texType = SHADER_RESTYPE;
uint3 texDim = uint3(HistogramTextureResolution);
uint3 texDim = uint3(HistogramTextureResolution);
uint blocksX = (int)ceil(float(texDim.x)/float(HGRAM_PIXELS_PER_TILE*HGRAM_TILES_PER_BLOCK));
uint blocksX = (int)ceil(float(texDim.x) / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK));
uint2 topleft = (gid.xy*HGRAM_TILES_PER_BLOCK + tid.xy)*HGRAM_PIXELS_PER_TILE;
uint2 topleft = (gid.xy * HGRAM_TILES_PER_BLOCK + tid.xy) * HGRAM_PIXELS_PER_TILE;
uint outIdx = (tid.y*HGRAM_TILES_PER_BLOCK + tid.x) + (gid.y*blocksX + gid.x)*(HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK);
uint outIdx = (tid.y * HGRAM_TILES_PER_BLOCK + tid.x) +
(gid.y * blocksX + gid.x) * (HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK);
int i=0;
int i = 0;
#if UINT_TEX
{
uint4 minval = 0;
uint4 maxval = 0;
{
uint4 minval = 0;
uint4 maxval = 0;
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uint4 data = SampleTextureUInt4(texType, float2(x, y)/float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim);
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uint4 data = SampleTextureUInt4(texType, float2(x, y) / float2(texDim.xy), HistogramSlice,
HistogramMip, HistogramSample, texDim);
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
i++;
}
}
i++;
}
}
MinMaxDestUInt[outIdx*2+0] = minval;
MinMaxDestUInt[outIdx*2+1] = maxval;
return;
}
MinMaxDestUInt[outIdx * 2 + 0] = minval;
MinMaxDestUInt[outIdx * 2 + 1] = maxval;
return;
}
#elif SINT_TEX
{
int4 minval = 0;
int4 maxval = 0;
{
int4 minval = 0;
int4 maxval = 0;
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
int4 data = SampleTextureInt4(texType, float2(x, y)/float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim);
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
int4 data = SampleTextureInt4(texType, float2(x, y) / float2(texDim.xy), HistogramSlice,
HistogramMip, HistogramSample, texDim);
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
i++;
}
}
i++;
}
}
MinMaxDestInt[outIdx*2+0] = minval;
MinMaxDestInt[outIdx*2+1] = maxval;
return;
}
MinMaxDestInt[outIdx * 2 + 0] = minval;
MinMaxDestInt[outIdx * 2 + 1] = maxval;
return;
}
#else
{
float4 minval = 0;
float4 maxval = 0;
{
float4 minval = 0;
float4 maxval = 0;
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
float4 data = SampleTextureFloat4(texType, false, float2(x, y)/float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim, HistogramYUVDownsampleRate, HistogramYUVAChannels);
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
float4 data = SampleTextureFloat4(texType, false, float2(x, y) / float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim,
HistogramYUVDownsampleRate, HistogramYUVAChannels);
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
if(i == 0)
{
minval = maxval = data;
}
else
{
minval = min(minval, data);
maxval = max(maxval, data);
}
i++;
}
}
i++;
}
}
MinMaxDestFloat[outIdx*2+0] = minval;
MinMaxDestFloat[outIdx*2+1] = maxval;
return;
}
MinMaxDestFloat[outIdx * 2 + 0] = minval;
MinMaxDestFloat[outIdx * 2 + 1] = maxval;
return;
}
#endif
}
@@ -147,210 +151,213 @@ RWBuffer<float4> MinMaxResultDestFloat : register(u0);
RWBuffer<uint4> MinMaxResultDestUInt : register(u1);
RWBuffer<int4> MinMaxResultDestInt : register(u2);
[numthreads(1,1,1)]
void RENDERDOC_ResultMinMaxCS()
[numthreads(1, 1, 1)] void RENDERDOC_ResultMinMaxCS()
{
uint3 texDim = uint3(HistogramTextureResolution);
uint3 texDim = uint3(HistogramTextureResolution);
uint blocksX = (int)ceil(float(texDim.x)/float(HGRAM_PIXELS_PER_TILE*HGRAM_TILES_PER_BLOCK));
uint blocksY = (int)ceil(float(texDim.y)/float(HGRAM_PIXELS_PER_TILE*HGRAM_TILES_PER_BLOCK));
uint blocksX = (int)ceil(float(texDim.x) / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK));
uint blocksY = (int)ceil(float(texDim.y) / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK));
#if UINT_TEX
uint4 minvalU = MinMaxResultSourceUInt[0];
uint4 maxvalU = MinMaxResultSourceUInt[1];
uint4 minvalU = MinMaxResultSourceUInt[0];
uint4 maxvalU = MinMaxResultSourceUInt[1];
#elif SINT_TEX
int4 minvalI = MinMaxResultSourceInt[0];
int4 maxvalI = MinMaxResultSourceInt[1];
int4 minvalI = MinMaxResultSourceInt[0];
int4 maxvalI = MinMaxResultSourceInt[1];
#else
float4 minvalF = MinMaxResultSourceFloat[0];
float4 maxvalF = MinMaxResultSourceFloat[1];
float4 minvalF = MinMaxResultSourceFloat[0];
float4 maxvalF = MinMaxResultSourceFloat[1];
#endif
// i is the tile we're looking at
for(uint i=1; i < blocksX*blocksY*HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK; i++)
{
uint blockIdx = i/(HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK);
uint tileIdx = i%(HGRAM_TILES_PER_BLOCK*HGRAM_TILES_PER_BLOCK);
// which block and tile is this in
uint2 blockXY = uint2(blockIdx % blocksX, blockIdx / blocksX);
uint2 tileXY = uint2(tileIdx % HGRAM_TILES_PER_BLOCK, tileIdx / HGRAM_TILES_PER_BLOCK);
// i is the tile we're looking at
for(uint i = 1; i < blocksX * blocksY * HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK; i++)
{
uint blockIdx = i / (HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK);
uint tileIdx = i % (HGRAM_TILES_PER_BLOCK * HGRAM_TILES_PER_BLOCK);
// if this is at least partially within the texture, include it.
if(blockXY.x*(HGRAM_TILES_PER_BLOCK*HGRAM_PIXELS_PER_TILE) + tileXY.x*HGRAM_PIXELS_PER_TILE < texDim.x &&
blockXY.y*(HGRAM_TILES_PER_BLOCK*HGRAM_PIXELS_PER_TILE) + tileXY.y*HGRAM_PIXELS_PER_TILE < texDim.y)
{
// which block and tile is this in
uint2 blockXY = uint2(blockIdx % blocksX, blockIdx / blocksX);
uint2 tileXY = uint2(tileIdx % HGRAM_TILES_PER_BLOCK, tileIdx / HGRAM_TILES_PER_BLOCK);
// if this is at least partially within the texture, include it.
if(blockXY.x * (HGRAM_TILES_PER_BLOCK * HGRAM_PIXELS_PER_TILE) + tileXY.x * HGRAM_PIXELS_PER_TILE <
texDim.x &&
blockXY.y * (HGRAM_TILES_PER_BLOCK * HGRAM_PIXELS_PER_TILE) + tileXY.y * HGRAM_PIXELS_PER_TILE <
texDim.y)
{
#if UINT_TEX
minvalU = min(minvalU, MinMaxResultSourceUInt[i*2 + 0]);
maxvalU = max(maxvalU, MinMaxResultSourceUInt[i*2 + 1]);
minvalU = min(minvalU, MinMaxResultSourceUInt[i * 2 + 0]);
maxvalU = max(maxvalU, MinMaxResultSourceUInt[i * 2 + 1]);
#elif SINT_TEX
minvalI = min(minvalI, MinMaxResultSourceInt[i*2 + 0]);
maxvalI = max(maxvalI, MinMaxResultSourceInt[i*2 + 1]);
minvalI = min(minvalI, MinMaxResultSourceInt[i * 2 + 0]);
maxvalI = max(maxvalI, MinMaxResultSourceInt[i * 2 + 1]);
#else
minvalF = min(minvalF, MinMaxResultSourceFloat[i*2 + 0]);
maxvalF = max(maxvalF, MinMaxResultSourceFloat[i*2 + 1]);
minvalF = min(minvalF, MinMaxResultSourceFloat[i * 2 + 0]);
maxvalF = max(maxvalF, MinMaxResultSourceFloat[i * 2 + 1]);
#endif
}
}
}
}
#if UINT_TEX
MinMaxResultDestUInt[0] = minvalU;
MinMaxResultDestUInt[1] = maxvalU;
MinMaxResultDestUInt[0] = minvalU;
MinMaxResultDestUInt[1] = maxvalU;
#elif SINT_TEX
MinMaxResultDestInt[0] = minvalI;
MinMaxResultDestInt[1] = maxvalI;
MinMaxResultDestInt[0] = minvalI;
MinMaxResultDestInt[1] = maxvalI;
#else
MinMaxResultDestFloat[0] = minvalF;
MinMaxResultDestFloat[1] = maxvalF;
MinMaxResultDestFloat[0] = minvalF;
MinMaxResultDestFloat[1] = maxvalF;
#endif
}
RWBuffer<uint> HistogramDest : register(u0);
[numthreads(HGRAM_TILES_PER_BLOCK, HGRAM_TILES_PER_BLOCK, 1)]
void RENDERDOC_HistogramCS(uint3 tid : SV_GroupThreadID, uint3 gid : SV_GroupID)
[numthreads(HGRAM_TILES_PER_BLOCK, HGRAM_TILES_PER_BLOCK, 1)] void RENDERDOC_HistogramCS(
uint3 tid
: SV_GroupThreadID, uint3 gid
: SV_GroupID)
{
uint texType = SHADER_RESTYPE;
uint texType = SHADER_RESTYPE;
uint3 texDim = uint3(HistogramTextureResolution);
uint3 texDim = uint3(HistogramTextureResolution);
uint blocksX = (int)ceil(float(texDim.x)/float(HGRAM_PIXELS_PER_TILE*HGRAM_PIXELS_PER_TILE));
uint blocksX = (int)ceil(float(texDim.x) / float(HGRAM_PIXELS_PER_TILE * HGRAM_PIXELS_PER_TILE));
uint2 topleft = (gid.xy*HGRAM_TILES_PER_BLOCK + tid.xy)*HGRAM_PIXELS_PER_TILE;
uint2 topleft = (gid.xy * HGRAM_TILES_PER_BLOCK + tid.xy) * HGRAM_PIXELS_PER_TILE;
int i=0;
int i = 0;
for(uint y = topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x = topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uint bucketIdx = HGRAM_NUM_BUCKETS + 1;
for(uint y=topleft.y; y < min(texDim.y, topleft.y + HGRAM_PIXELS_PER_TILE); y++)
{
for(uint x=topleft.x; x < min(texDim.x, topleft.x + HGRAM_PIXELS_PER_TILE); x++)
{
uint bucketIdx = HGRAM_NUM_BUCKETS+1;
#if UINT_TEX
{
uint4 data = SampleTextureUInt4(texType, float2(x, y)/float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim);
{
uint4 data = SampleTextureUInt4(texType, float2(x, y) / float2(texDim.xy), HistogramSlice,
HistogramMip, HistogramSample, texDim);
float divisor = 0.0f;
uint sum = 0;
if(HistogramChannels & 0x1)
{
sum += data.x;
divisor += 1.0f;
}
if(HistogramChannels & 0x2)
{
sum += data.y;
divisor += 1.0f;
}
if(HistogramChannels & 0x4)
{
sum += data.z;
divisor += 1.0f;
}
if(HistogramChannels & 0x8)
{
sum += data.w;
divisor += 1.0f;
}
float divisor = 0.0f;
uint sum = 0;
if(HistogramChannels & 0x1)
{
sum += data.x;
divisor += 1.0f;
}
if(HistogramChannels & 0x2)
{
sum += data.y;
divisor += 1.0f;
}
if(HistogramChannels & 0x4)
{
sum += data.z;
divisor += 1.0f;
}
if(HistogramChannels & 0x8)
{
sum += data.w;
divisor += 1.0f;
}
if(divisor > 0.0f)
{
float val = float(sum)/divisor;
if(divisor > 0.0f)
{
float val = float(sum) / divisor;
float normalisedVal = (val - HistogramMin)/(HistogramMax - HistogramMin);
float normalisedVal = (val - HistogramMin) / (HistogramMax - HistogramMin);
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
bucketIdx = (uint)floor(normalisedVal*HGRAM_NUM_BUCKETS);
}
}
bucketIdx = (uint)floor(normalisedVal * HGRAM_NUM_BUCKETS);
}
}
#elif SINT_TEX
{
int4 data = SampleTextureInt4(texType, float2(x, y)/float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim);
{
int4 data = SampleTextureInt4(texType, float2(x, y) / float2(texDim.xy), HistogramSlice,
HistogramMip, HistogramSample, texDim);
float divisor = 0.0f;
int sum = 0;
if(HistogramChannels & 0x1)
{
sum += data.x;
divisor += 1.0f;
}
if(HistogramChannels & 0x2)
{
sum += data.y;
divisor += 1.0f;
}
if(HistogramChannels & 0x4)
{
sum += data.z;
divisor += 1.0f;
}
if(HistogramChannels & 0x8)
{
sum += data.w;
divisor += 1.0f;
}
float divisor = 0.0f;
int sum = 0;
if(HistogramChannels & 0x1)
{
sum += data.x;
divisor += 1.0f;
}
if(HistogramChannels & 0x2)
{
sum += data.y;
divisor += 1.0f;
}
if(HistogramChannels & 0x4)
{
sum += data.z;
divisor += 1.0f;
}
if(HistogramChannels & 0x8)
{
sum += data.w;
divisor += 1.0f;
}
if(divisor > 0.0f)
{
float val = float(sum)/divisor;
if(divisor > 0.0f)
{
float val = float(sum) / divisor;
float normalisedVal = (val - HistogramMin)/(HistogramMax - HistogramMin);
float normalisedVal = (val - HistogramMin) / (HistogramMax - HistogramMin);
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
bucketIdx = (uint)floor(normalisedVal*HGRAM_NUM_BUCKETS);
}
}
bucketIdx = (uint)floor(normalisedVal * HGRAM_NUM_BUCKETS);
}
}
#else
{
float4 data = SampleTextureFloat4(texType, false, float2(x, y)/float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim, HistogramYUVDownsampleRate, HistogramYUVAChannels);
{
float4 data = SampleTextureFloat4(texType, false, float2(x, y) / float2(texDim.xy),
HistogramSlice, HistogramMip, HistogramSample, texDim,
HistogramYUVDownsampleRate, HistogramYUVAChannels);
float divisor = 0.0f;
float sum = 0.0f;
if(HistogramChannels & 0x1)
{
sum += data.x;
divisor += 1.0f;
}
if(HistogramChannels & 0x2)
{
sum += data.y;
divisor += 1.0f;
}
if(HistogramChannels & 0x4)
{
sum += data.z;
divisor += 1.0f;
}
if(HistogramChannels & 0x8)
{
sum += data.w;
divisor += 1.0f;
}
float divisor = 0.0f;
float sum = 0.0f;
if(HistogramChannels & 0x1)
{
sum += data.x;
divisor += 1.0f;
}
if(HistogramChannels & 0x2)
{
sum += data.y;
divisor += 1.0f;
}
if(HistogramChannels & 0x4)
{
sum += data.z;
divisor += 1.0f;
}
if(HistogramChannels & 0x8)
{
sum += data.w;
divisor += 1.0f;
}
if(divisor > 0.0f)
{
float val = sum/divisor;
if(divisor > 0.0f)
{
float val = sum / divisor;
float normalisedVal = (val - HistogramMin)/(HistogramMax - HistogramMin);
float normalisedVal = (val - HistogramMin) / (HistogramMax - HistogramMin);
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
if(normalisedVal < 0.0f)
normalisedVal = 2.0f;
bucketIdx = (uint)floor(normalisedVal*HGRAM_NUM_BUCKETS);
}
}
bucketIdx = (uint)floor(normalisedVal * HGRAM_NUM_BUCKETS);
}
}
#endif
if(bucketIdx >= 0 && bucketIdx < HGRAM_NUM_BUCKETS)
InterlockedAdd(HistogramDest[bucketIdx], 1);
}
}
if(bucketIdx >= 0 && bucketIdx < HGRAM_NUM_BUCKETS)
InterlockedAdd(HistogramDest[bucketIdx], 1);
}
}
}
+206 -219
View File
@@ -1,18 +1,18 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 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
@@ -24,100 +24,95 @@
struct meshV2F
{
float4 pos : SV_Position;
float3 norm : Normal;
float4 secondary : Secondary;
float4 pos : SV_Position;
float3 norm : Normal;
float4 secondary : Secondary;
};
struct meshA2V
{
float4 pos : pos;
float4 secondary : sec;
float4 pos : pos;
float4 secondary : sec;
};
meshV2F RENDERDOC_MeshVS(meshA2V IN, uint vid : SV_VertexID)
{
meshV2F OUT = (meshV2F)0;
float2 psprite[4] =
{
float2(-1.0f, -1.0f),
float2(-1.0f, 1.0f),
float2( 1.0f, -1.0f),
float2( 1.0f, 1.0f)
};
meshV2F OUT = (meshV2F)0;
OUT.pos = mul(IN.pos, ModelViewProj);
OUT.pos.xy += SpriteSize.xy*0.01f*psprite[vid%4]*OUT.pos.w;
OUT.norm = float3(0, 0, 1);
OUT.secondary = IN.secondary;
float2 psprite[4] = {float2(-1.0f, -1.0f), float2(-1.0f, 1.0f), float2(1.0f, -1.0f),
float2(1.0f, 1.0f)};
return OUT;
OUT.pos = mul(IN.pos, ModelViewProj);
OUT.pos.xy += SpriteSize.xy * 0.01f * psprite[vid % 4] * OUT.pos.w;
OUT.norm = float3(0, 0, 1);
OUT.secondary = IN.secondary;
return OUT;
}
struct triSizeV2F
{
float4 pos : SV_Position;
float pixarea : PixArea;
float4 pos : SV_Position;
float pixarea : PixArea;
};
cbuffer viewportCBuf : register(b0)
{
float4 viewport;
float4 viewport;
};
[maxvertexcount(3)]
void RENDERDOC_TriangleSizeGS(triangle meshV2F input[3], inout TriangleStream<triSizeV2F> TriStream)
[maxvertexcount(3)] void RENDERDOC_TriangleSizeGS(triangle meshV2F input[3],
inout TriangleStream<triSizeV2F> TriStream)
{
triSizeV2F output;
triSizeV2F output;
float2 a = input[0].pos.xy / input[0].pos.w;
float2 b = input[1].pos.xy / input[1].pos.w;
float2 c = input[2].pos.xy / input[2].pos.w;
float2 a = input[0].pos.xy / input[0].pos.w;
float2 b = input[1].pos.xy / input[1].pos.w;
float2 c = input[2].pos.xy / input[2].pos.w;
a = (a * 0.5f + 0.5f) * viewport.xy;
b = (b * 0.5f + 0.5f) * viewport.xy;
c = (c * 0.5f + 0.5f) * viewport.xy;
a = (a * 0.5f + 0.5f) * viewport.xy;
b = (b * 0.5f + 0.5f) * viewport.xy;
c = (c * 0.5f + 0.5f) * viewport.xy;
float ab = length(a - b);
float bc = length(b - c);
float ca = length(c - a);
float ab = length(a - b);
float bc = length(b - c);
float ca = length(c - a);
float s = (ab + bc + ca) / 2.0f;
float s = (ab + bc + ca) / 2.0f;
float area = sqrt( s * (s - ab) * (s - bc) * (s - ca) );
float area = sqrt(s * (s - ab) * (s - bc) * (s - ca));
for(int i=0; i<3; i++)
{
output.pos = input[i].pos;
output.pixarea = area;
TriStream.Append(output);
}
TriStream.RestartStrip();
for(int i = 0; i < 3; i++)
{
output.pos = input[i].pos;
output.pixarea = area;
TriStream.Append(output);
}
TriStream.RestartStrip();
}
float4 RENDERDOC_TriangleSizePS(triSizeV2F IN) : SV_Target0
{
return float4(max(IN.pixarea, 0.001f).xxx, 1.0f);
return float4(max(IN.pixarea, 0.001f).xxx, 1.0f);
}
[maxvertexcount(3)]
void RENDERDOC_MeshGS(triangle meshV2F input[3], inout TriangleStream<meshV2F> TriStream)
[maxvertexcount(3)] void RENDERDOC_MeshGS(triangle meshV2F input[3],
inout TriangleStream<meshV2F> TriStream)
{
meshV2F output;
meshV2F output;
float4 faceEdgeA = mul(input[1].pos, InvProj) - mul(input[0].pos, InvProj);
float4 faceEdgeB = mul(input[2].pos, InvProj) - mul(input[0].pos, InvProj);
float3 faceNormal = normalize( cross(faceEdgeA.xyz, faceEdgeB.xyz) );
float4 faceEdgeA = mul(input[1].pos, InvProj) - mul(input[0].pos, InvProj);
float4 faceEdgeB = mul(input[2].pos, InvProj) - mul(input[0].pos, InvProj);
float3 faceNormal = normalize(cross(faceEdgeA.xyz, faceEdgeB.xyz));
for(int i=0; i<3; i++)
{
output.pos = input[i].pos;
output.norm = faceNormal;
output.secondary = input[i].secondary;
TriStream.Append(output);
}
TriStream.RestartStrip();
for(int i = 0; i < 3; i++)
{
output.pos = input[i].pos;
output.norm = faceNormal;
output.secondary = input[i].secondary;
TriStream.Append(output);
}
TriStream.RestartStrip();
}
cbuffer MeshColourPush : register(b2)
@@ -127,20 +122,20 @@ cbuffer MeshColourPush : register(b2)
float4 RENDERDOC_MeshPS(meshV2F IN) : SV_Target0
{
uint type = OutputDisplayFormat;
uint type = OutputDisplayFormat;
if(type == MESHDISPLAY_SECONDARY)
return float4(IN.secondary.xyz, 1);
else if(type == MESHDISPLAY_SECONDARY_ALPHA)
return float4(IN.secondary.www, 1);
else if(type == MESHDISPLAY_FACELIT)
{
float3 lightDir = normalize(float3(0, -0.3f, -1));
if(type == MESHDISPLAY_SECONDARY)
return float4(IN.secondary.xyz, 1);
else if(type == MESHDISPLAY_SECONDARY_ALPHA)
return float4(IN.secondary.www, 1);
else if(type == MESHDISPLAY_FACELIT)
{
float3 lightDir = normalize(float3(0, -0.3f, -1));
return float4(MeshColour.xyz*abs(dot(lightDir, IN.norm)), 1);
}
else //if(type == MESHDISPLAY_SOLID)
return float4(MeshColour.xyz, 1);
return float4(MeshColour.xyz * abs(dot(lightDir, IN.norm)), 1);
}
else // if(type == MESHDISPLAY_SOLID)
return float4(MeshColour.xyz, 1);
}
Buffer<uint> index : register(t0);
@@ -149,183 +144,175 @@ AppendStructuredBuffer<uint4> pickresult : register(u0);
cbuffer MeshPickData : register(b0)
{
float3 PickRayPos;
uint PickIdx;
float3 PickRayPos;
uint PickIdx;
float3 PickRayDir;
uint PickNumVerts;
float3 PickRayDir;
uint PickNumVerts;
float2 PickCoords;
float2 PickViewport;
float2 PickCoords;
float2 PickViewport;
uint PickMeshMode;
uint PickUnproject;
float2 Padding;
uint PickMeshMode;
uint PickUnproject;
float2 Padding;
row_major float4x4 PickMVP;
row_major float4x4 PickMVP;
};
bool TriangleRayIntersect(float3 A, float3 B, float3 C,
float3 RayPosition, float3 RayDirection, out float3 HitPosition)
bool TriangleRayIntersect(float3 A, float3 B, float3 C, float3 RayPosition, float3 RayDirection,
out float3 HitPosition)
{
bool Result = false;
bool Result = false;
float3 v0v1 = B - A;
float3 v0v2 = C - A;
float3 pvec = cross(RayDirection, v0v2);
float det = dot(v0v1, pvec);
float3 v0v1 = B - A;
float3 v0v2 = C - A;
float3 pvec = cross(RayDirection, v0v2);
float det = dot(v0v1, pvec);
// if the determinant is negative the triangle is backfacing, but we still take those!
// if the determinant is close to 0, the ray misses the triangle
if (abs(det) > 0)
{
float invDet = 1 / det;
// if the determinant is negative the triangle is backfacing, but we still take those!
// if the determinant is close to 0, the ray misses the triangle
if(abs(det) > 0)
{
float invDet = 1 / det;
float3 tvec = RayPosition - A;
float3 qvec = cross(tvec, v0v1);
float u = dot(tvec, pvec) * invDet;
float v = dot(RayDirection, qvec) * invDet;
float3 tvec = RayPosition - A;
float3 qvec = cross(tvec, v0v1);
float u = dot(tvec, pvec) * invDet;
float v = dot(RayDirection, qvec) * invDet;
if (u >= 0 && u <= 1 &&
v >= 0 && u + v <= 1)
{
float t = dot(v0v2, qvec) * invDet;
if (t > 0)
{
HitPosition = RayPosition + (RayDirection * t);
Result = true;
}
if(u >= 0 && u <= 1 && v >= 0 && u + v <= 1)
{
float t = dot(v0v2, qvec) * invDet;
if(t > 0)
{
HitPosition = RayPosition + (RayDirection * t);
Result = true;
}
}
}
}
}
return Result;
return Result;
}
void trianglePath(uint threadID)
{
uint vertid = uint(fmod(float(threadID), float(PickNumVerts)));
uint vertid0 = 0;
uint vertid1 = 0;
uint vertid2 = 0;
switch (PickMeshMode)
{
case MESH_TRIANGLE_LIST:
{
vertid *= 3;
vertid0 = vertid;
vertid1 = vertid+1;
vertid2 = vertid+2;
break;
}
case MESH_TRIANGLE_STRIP:
{
vertid0 = vertid;
vertid1 = vertid+1;
vertid2 = vertid+2;
break;
}
case MESH_TRIANGLE_LIST_ADJ:
{
vertid *= 6;
vertid0 = vertid;
vertid1 = vertid+2;
vertid2 = vertid+4;
break;
}
case MESH_TRIANGLE_STRIP_ADJ:
{
vertid *= 2;
vertid0 = vertid;
vertid1 = vertid+2;
vertid2 = vertid+4;
break;
}
}
uint vertid = uint(fmod(float(threadID), float(PickNumVerts)));
float4 pos0 = PickIdx ? vertex[index[vertid0]] : vertex[vertid0];
float4 pos1 = PickIdx ? vertex[index[vertid1]] : vertex[vertid1];
float4 pos2 = PickIdx ? vertex[index[vertid2]] : vertex[vertid2];
uint vertid0 = 0;
uint vertid1 = 0;
uint vertid2 = 0;
switch(PickMeshMode)
{
case MESH_TRIANGLE_LIST:
{
vertid *= 3;
vertid0 = vertid;
vertid1 = vertid + 1;
vertid2 = vertid + 2;
break;
}
case MESH_TRIANGLE_STRIP:
{
vertid0 = vertid;
vertid1 = vertid + 1;
vertid2 = vertid + 2;
break;
}
case MESH_TRIANGLE_LIST_ADJ:
{
vertid *= 6;
vertid0 = vertid;
vertid1 = vertid + 2;
vertid2 = vertid + 4;
break;
}
case MESH_TRIANGLE_STRIP_ADJ:
{
vertid *= 2;
vertid0 = vertid;
vertid1 = vertid + 2;
vertid2 = vertid + 4;
break;
}
}
float3 hitPosition;
bool hit;
if (PickUnproject == 1)
{
hit = TriangleRayIntersect(pos0.xyz / pos0.w, pos1.xyz / pos1.w, pos2.xyz / pos2.w,
PickRayPos, PickRayDir,
/*out*/ hitPosition);
}
else
{
hit = TriangleRayIntersect(pos0.xyz, pos1.xyz, pos2.xyz,
PickRayPos, PickRayDir,
/*out*/ hitPosition);
}
// ray hit a triangle, so return the vertex that was closest
// to the triangle/ray intersection point
if (hit)
{
float dist0 = distance(pos0.xyz/pos0.w, hitPosition);
float dist1 = distance(pos1.xyz/pos1.w, hitPosition);
float dist2 = distance(pos2.xyz/pos2.w, hitPosition);
float4 pos0 = PickIdx ? vertex[index[vertid0]] : vertex[vertid0];
float4 pos1 = PickIdx ? vertex[index[vertid1]] : vertex[vertid1];
float4 pos2 = PickIdx ? vertex[index[vertid2]] : vertex[vertid2];
uint meshVert = vertid0;
if (dist1 < dist0 && dist1 < dist2)
{
meshVert = vertid1;
}
else if (dist2 < dist0 && dist2 < dist1)
{
meshVert = vertid2;
}
pickresult.Append(uint4(meshVert,
asuint(hitPosition.x), asuint(hitPosition.y), asuint(hitPosition.z)));
}
float3 hitPosition;
bool hit;
if(PickUnproject == 1)
{
hit = TriangleRayIntersect(pos0.xyz / pos0.w, pos1.xyz / pos1.w, pos2.xyz / pos2.w, PickRayPos,
PickRayDir,
/*out*/ hitPosition);
}
else
{
hit = TriangleRayIntersect(pos0.xyz, pos1.xyz, pos2.xyz, PickRayPos, PickRayDir,
/*out*/ hitPosition);
}
// ray hit a triangle, so return the vertex that was closest
// to the triangle/ray intersection point
if(hit)
{
float dist0 = distance(pos0.xyz / pos0.w, hitPosition);
float dist1 = distance(pos1.xyz / pos1.w, hitPosition);
float dist2 = distance(pos2.xyz / pos2.w, hitPosition);
uint meshVert = vertid0;
if(dist1 < dist0 && dist1 < dist2)
{
meshVert = vertid1;
}
else if(dist2 < dist0 && dist2 < dist1)
{
meshVert = vertid2;
}
pickresult.Append(
uint4(meshVert, asuint(hitPosition.x), asuint(hitPosition.y), asuint(hitPosition.z)));
}
}
void defaultPath(uint threadID)
{
uint vertid = threadID;
uint vertid = threadID;
if(vertid >= PickNumVerts)
return;
if(vertid >= PickNumVerts)
return;
uint idx = PickIdx ? index[vertid] : vertid;
uint idx = PickIdx ? index[vertid] : vertid;
float4 pos = vertex[idx];
float4 pos = vertex[idx];
float4 wpos = mul(pos, PickMVP);
float4 wpos = mul(pos, PickMVP);
if (PickUnproject == 1)
wpos.xyz /= wpos.www;
wpos.xy *= float2(1.0f, -1.0f);
if(PickUnproject == 1)
wpos.xyz /= wpos.www;
float2 scr = (wpos.xy + 1.0f) * 0.5f * PickViewport;
wpos.xy *= float2(1.0f, -1.0f);
// close to target co-ords? add to list
float len = length(scr - PickCoords);
if(len < 35.0f)
{
pickresult.Append(uint4(vertid, idx, asuint(len), asuint(wpos.z)));
}
float2 scr = (wpos.xy + 1.0f) * 0.5f * PickViewport;
// close to target co-ords? add to list
float len = length(scr - PickCoords);
if(len < 35.0f)
{
pickresult.Append(uint4(vertid, idx, asuint(len), asuint(wpos.z)));
}
}
[numthreads(1024, 1, 1)]
void RENDERDOC_MeshPickCS(uint3 tid : SV_DispatchThreadID)
[numthreads(1024, 1, 1)] void RENDERDOC_MeshPickCS(uint3 tid : SV_DispatchThreadID)
{
if (PickMeshMode == MESH_OTHER)
{
defaultPath(tid.x);
}
else
{
trianglePath(tid.x);
}
if(PickMeshMode == MESH_OTHER)
{
defaultPath(tid.x);
}
else
{
trianglePath(tid.x);
}
}
+127 -118
View File
@@ -1,19 +1,19 @@
/******************************************************************************
* The MIT License (MIT)
*
*
* Copyright (c) 2015-2018 Baldur Karlsson
* 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
@@ -29,10 +29,10 @@
cbuffer msarraycopyconsts : register(b0)
{
uint sampleCount;
uint currentStencil;
uint currentSample;
uint currentSlice;
uint sampleCount;
uint currentStencil;
uint currentSample;
uint currentSlice;
};
Texture2DMSArray<uint4, 2> sourceMS2 : register(t1);
@@ -43,30 +43,30 @@ Texture2DMSArray<uint4, 32> sourceMS32 : register(t5);
uint4 RENDERDOC_CopyMSToArray(float4 pos : SV_Position) : SV_Target0
{
uint3 srcCoord = uint3(pos.x, pos.y, currentSlice);
uint3 srcCoord = uint3(pos.x, pos.y, currentSlice);
if(sampleCount == 2)
{
return sourceMS2.Load(srcCoord, currentSample);
}
else if(sampleCount == 4)
{
return sourceMS4.Load(srcCoord, currentSample);
}
else if(sampleCount == 8)
{
return sourceMS8.Load(srcCoord, currentSample);
}
else if(sampleCount == 16)
{
return sourceMS16.Load(srcCoord, currentSample);
}
else if(sampleCount == 32)
{
return sourceMS32.Load(srcCoord, currentSample);
}
if(sampleCount == 2)
{
return sourceMS2.Load(srcCoord, currentSample);
}
else if(sampleCount == 4)
{
return sourceMS4.Load(srcCoord, currentSample);
}
else if(sampleCount == 8)
{
return sourceMS8.Load(srcCoord, currentSample);
}
else if(sampleCount == 16)
{
return sourceMS16.Load(srcCoord, currentSample);
}
else if(sampleCount == 32)
{
return sourceMS32.Load(srcCoord, currentSample);
}
return 0;
return 0;
}
Texture2DMSArray<float4, 2> sourceFloatMS2 : register(t1);
@@ -77,30 +77,30 @@ Texture2DMSArray<float4, 32> sourceFloatMS32 : register(t5);
float4 RENDERDOC_FloatCopyMSToArray(float4 pos : SV_Position) : SV_Target0
{
uint3 srcCoord = uint3(pos.x, pos.y, currentSlice);
uint3 srcCoord = uint3(pos.x, pos.y, currentSlice);
if(sampleCount == 2)
{
return sourceFloatMS2.Load(srcCoord, currentSample);
}
else if(sampleCount == 4)
{
return sourceFloatMS4.Load(srcCoord, currentSample);
}
else if(sampleCount == 8)
{
return sourceFloatMS8.Load(srcCoord, currentSample);
}
else if(sampleCount == 16)
{
return sourceFloatMS16.Load(srcCoord, currentSample);
}
else if(sampleCount == 32)
{
return sourceFloatMS32.Load(srcCoord, currentSample);
}
if(sampleCount == 2)
{
return sourceFloatMS2.Load(srcCoord, currentSample);
}
else if(sampleCount == 4)
{
return sourceFloatMS4.Load(srcCoord, currentSample);
}
else if(sampleCount == 8)
{
return sourceFloatMS8.Load(srcCoord, currentSample);
}
else if(sampleCount == 16)
{
return sourceFloatMS16.Load(srcCoord, currentSample);
}
else if(sampleCount == 32)
{
return sourceFloatMS32.Load(srcCoord, currentSample);
}
return 0;
return 0;
}
Texture2DMSArray<float2, 2> sourceDepthMS2 : register(t1);
@@ -117,91 +117,100 @@ Texture2DMSArray<uint2, 32> sourceStencilMS32 : register(t15);
float RENDERDOC_DepthCopyMSToArray(float4 pos : SV_Position) : SV_Depth
{
uint3 srcCoord = uint3(pos.x, pos.y, currentSlice);
if(currentStencil < 256)
{
if(sampleCount == 2)
{
if(sourceStencilMS2.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 4)
{
if(sourceStencilMS4.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 8)
{
if(sourceStencilMS8.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 16)
{
if(sourceStencilMS16.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 32)
{
if(sourceStencilMS32.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
}
uint3 srcCoord = uint3(pos.x, pos.y, currentSlice);
if(sampleCount == 2)
{
return sourceDepthMS2.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 4)
{
return sourceDepthMS4.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 8)
{
return sourceDepthMS8.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 16)
{
return sourceDepthMS16.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 32)
{
return sourceDepthMS32.Load(srcCoord, currentSample).x;
}
if(currentStencil < 256)
{
if(sampleCount == 2)
{
if(sourceStencilMS2.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 4)
{
if(sourceStencilMS4.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 8)
{
if(sourceStencilMS8.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 16)
{
if(sourceStencilMS16.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
else if(sampleCount == 32)
{
if(sourceStencilMS32.Load(srcCoord, currentSample).y != currentStencil)
discard;
}
}
return 0;
if(sampleCount == 2)
{
return sourceDepthMS2.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 4)
{
return sourceDepthMS4.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 8)
{
return sourceDepthMS8.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 16)
{
return sourceDepthMS16.Load(srcCoord, currentSample).x;
}
else if(sampleCount == 32)
{
return sourceDepthMS32.Load(srcCoord, currentSample).x;
}
return 0;
}
Texture2DArray<uint4> sourceArray : register(t1);
uint4 RENDERDOC_CopyArrayToMS(float4 pos : SV_Position, uint curSample : SV_SampleIndex) : SV_Target0
uint4 RENDERDOC_CopyArrayToMS(float4 pos
: SV_Position, uint curSample
: SV_SampleIndex)
: SV_Target0
{
uint4 srcCoord = uint4(pos.x, pos.y, currentSlice*sampleCount + curSample, 0);
uint4 srcCoord = uint4(pos.x, pos.y, currentSlice * sampleCount + curSample, 0);
return sourceArray.Load(srcCoord);
return sourceArray.Load(srcCoord);
}
Texture2DArray<float4> sourceFloatArray : register(t1);
float4 RENDERDOC_FloatCopyArrayToMS(float4 pos : SV_Position, uint curSample : SV_SampleIndex) : SV_Target0
float4 RENDERDOC_FloatCopyArrayToMS(float4 pos
: SV_Position, uint curSample
: SV_SampleIndex)
: SV_Target0
{
uint4 srcCoord = uint4(pos.x, pos.y, currentSlice*sampleCount + curSample, 0);
uint4 srcCoord = uint4(pos.x, pos.y, currentSlice * sampleCount + curSample, 0);
return sourceFloatArray.Load(srcCoord);
return sourceFloatArray.Load(srcCoord);
}
Texture2DArray<float2> sourceDepthArray : register(t1);
Texture2DArray<uint2> sourceStencilArray : register(t11);
float RENDERDOC_DepthCopyArrayToMS(float4 pos : SV_Position, uint curSample : SV_SampleIndex) : SV_Depth
float RENDERDOC_DepthCopyArrayToMS(float4 pos
: SV_Position, uint curSample
: SV_SampleIndex)
: SV_Depth
{
uint4 srcCoord = uint4(pos.x, pos.y, currentSlice*sampleCount + curSample, 0);
if(currentStencil < 1000)
{
if(sourceStencilArray.Load(srcCoord).y != currentStencil)
discard;
}
uint4 srcCoord = uint4(pos.x, pos.y, currentSlice * sampleCount + curSample, 0);
return sourceDepthArray.Load(srcCoord).x;
if(currentStencil < 1000)
{
if(sourceStencilArray.Load(srcCoord).y != currentStencil)
discard;
}
return sourceDepthArray.Load(srcCoord).x;
}
+1 -1
View File
@@ -57,6 +57,6 @@ if ! valid_clang_format; then
fi;
# Search through the code that should be formatted, exclude any non-renderdoc code.
FILES=$(find qrenderdoc/ renderdoc/ renderdoccmd/ renderdocshim/ -type f -regex '.*\(/3rdparty/\|/official/\|resource.h\).*' -prune -o -regex '.*\.\(c\|cpp\|h\)$' -print)
FILES=$(find qrenderdoc/ renderdoc/ renderdoccmd/ renderdocshim/ -type f -regex '.*\(/3rdparty/\|/official/\|resource.h\).*' -prune -o -regex '.*\.\(c\|cpp\|h\|vert\|frag\|geom\|comp\|hlsl\)$' -print)
$CLANG_FORMAT -i -style=file $FILES