Move solution and projects to src
This commit is contained in:
parent
cd124bda58
commit
cee7121058
3466 changed files with 55 additions and 55 deletions
|
@ -0,0 +1,64 @@
|
|||
#version 450 core
|
||||
|
||||
#extension GL_EXT_shader_8bit_storage : require
|
||||
|
||||
layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout (std140, set = 0, binding = 0) uniform stride_arguments
|
||||
{
|
||||
ivec4 stride_arguments_data;
|
||||
};
|
||||
|
||||
layout (std430, set = 1, binding = 1) buffer in_s
|
||||
{
|
||||
uint8_t[] in_data;
|
||||
};
|
||||
|
||||
layout (std430, set = 1, binding = 2) buffer out_s
|
||||
{
|
||||
uint8_t[] out_data;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
// Determine what slice of the stride copies this invocation will perform.
|
||||
|
||||
int sourceStride = stride_arguments_data.x;
|
||||
int targetStride = stride_arguments_data.y;
|
||||
int bufferSize = stride_arguments_data.z;
|
||||
int sourceOffset = stride_arguments_data.w;
|
||||
|
||||
int strideRemainder = targetStride - sourceStride;
|
||||
int invocations = int(gl_WorkGroupSize.x);
|
||||
|
||||
int copiesRequired = bufferSize / sourceStride;
|
||||
|
||||
// Find the copies that this invocation should perform.
|
||||
|
||||
// - Copies that all invocations perform.
|
||||
int allInvocationCopies = copiesRequired / invocations;
|
||||
|
||||
// - Extra remainder copy that this invocation performs.
|
||||
int index = int(gl_LocalInvocationID.x);
|
||||
int extra = (index < (copiesRequired % invocations)) ? 1 : 0;
|
||||
|
||||
int copyCount = allInvocationCopies + extra;
|
||||
|
||||
// Finally, get the starting offset. Make sure to count extra copies.
|
||||
|
||||
int startCopy = allInvocationCopies * index + min(copiesRequired % invocations, index);
|
||||
|
||||
int srcOffset = sourceOffset + startCopy * sourceStride;
|
||||
int dstOffset = startCopy * targetStride;
|
||||
|
||||
// Perform the copies for this region
|
||||
for (int i=0; i<copyCount; i++) {
|
||||
for (int j=0; j<sourceStride; j++) {
|
||||
out_data[dstOffset++] = in_data[srcOffset++];
|
||||
}
|
||||
|
||||
for (int j=0; j<strideRemainder; j++) {
|
||||
out_data[dstOffset++] = uint8_t(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#version 450 core
|
||||
|
||||
layout (binding = 0, set = 2) uniform sampler2D tex;
|
||||
|
||||
layout (location = 0) in vec2 tex_coord;
|
||||
layout (location = 0) out vec4 colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
colour = vec4(texture(tex, tex_coord).rgb, 1.0f);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#version 450 core
|
||||
|
||||
layout (binding = 0, set = 2) uniform sampler2D tex;
|
||||
|
||||
layout (location = 0) in vec2 tex_coord;
|
||||
layout (location = 0) out vec4 colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
colour = texture(tex, tex_coord);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#version 450 core
|
||||
|
||||
layout (binding = 0, set = 2) uniform sampler2DMS tex;
|
||||
|
||||
layout (location = 0) in vec2 tex_coord;
|
||||
layout (location = 0) out vec4 colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
colour = texelFetch(tex, ivec2(tex_coord * vec2(textureSize(tex).xy)), gl_SampleID);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 1) uniform tex_coord_in
|
||||
{
|
||||
vec4 tex_coord_in_data;
|
||||
};
|
||||
|
||||
layout (location = 0) out vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
int low = gl_VertexIndex & 1;
|
||||
int high = gl_VertexIndex >> 1;
|
||||
tex_coord.x = tex_coord_in_data[low];
|
||||
tex_coord.y = tex_coord_in_data[2 + high];
|
||||
gl_Position.x = (float(low) - 0.5f) * 2.0f;
|
||||
gl_Position.y = (float(high) - 0.5f) * 2.0f;
|
||||
gl_Position.z = 0.0f;
|
||||
gl_Position.w = 1.0f;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#version 450 core
|
||||
|
||||
layout (location = 0) in vec4 clear_colour;
|
||||
layout (location = 0) out vec4 colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
colour = clear_colour;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#version 450 core
|
||||
|
||||
layout (location = 0) in vec4 clear_colour;
|
||||
layout (location = 0) out ivec4 colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
colour = floatBitsToInt(clear_colour);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#version 450 core
|
||||
|
||||
layout (location = 0) in vec4 clear_colour;
|
||||
layout (location = 0) out uvec4 colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
colour = floatBitsToUint(clear_colour);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 1) uniform clear_colour_in
|
||||
{
|
||||
vec4 clear_colour_in_data;
|
||||
};
|
||||
|
||||
layout (location = 0) out vec4 clear_colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
int low = gl_VertexIndex & 1;
|
||||
int high = gl_VertexIndex >> 1;
|
||||
clear_colour = clear_colour_in_data;
|
||||
gl_Position.x = (float(low) - 0.5f) * 2.0f;
|
||||
gl_Position.y = (float(high) - 0.5f) * 2.0f;
|
||||
gl_Position.z = 0.0f;
|
||||
gl_Position.w = 1.0f;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 0) uniform ratio_in
|
||||
{
|
||||
int ratio;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform usampler2D src;
|
||||
layout (set = 3, binding = 0) writeonly uniform uimage2D dst;
|
||||
|
||||
layout (local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
uvec2 coords = gl_GlobalInvocationID.xy;
|
||||
ivec2 textureSz = textureSize(src, 0);
|
||||
|
||||
if (int(coords.x) >= textureSz.x || int(coords.y) >= textureSz.y)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint coordsShifted = coords.x << ratio;
|
||||
|
||||
uvec2 dstCoords0 = uvec2(coordsShifted, coords.y);
|
||||
uvec2 dstCoords1 = uvec2(coordsShifted + 1, coords.y);
|
||||
uvec2 dstCoords2 = uvec2(coordsShifted + 2, coords.y);
|
||||
uvec2 dstCoords3 = uvec2(coordsShifted + 3, coords.y);
|
||||
|
||||
uvec4 rgba = texelFetch(src, ivec2(coords), 0);
|
||||
|
||||
imageStore(dst, ivec2(dstCoords0), rgba.rrrr);
|
||||
imageStore(dst, ivec2(dstCoords1), rgba.gggg);
|
||||
imageStore(dst, ivec2(dstCoords2), rgba.bbbb);
|
||||
imageStore(dst, ivec2(dstCoords3), rgba.aaaa);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 0) uniform sample_counts_log2_in
|
||||
{
|
||||
ivec4 sample_counts_log2;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform usampler2DMS srcMS;
|
||||
layout (set = 3, binding = 0) writeonly uniform uimage2D dst;
|
||||
|
||||
layout (local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
uvec2 coords = gl_GlobalInvocationID.xy;
|
||||
ivec2 imageSz = imageSize(dst);
|
||||
|
||||
if (int(coords.x) >= imageSz.x || int(coords.y) >= imageSz.y)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int deltaX = sample_counts_log2.x - sample_counts_log2.z;
|
||||
int deltaY = sample_counts_log2.y - sample_counts_log2.w;
|
||||
int samplesInXLog2 = sample_counts_log2.z;
|
||||
int samplesInYLog2 = sample_counts_log2.w;
|
||||
int samplesInX = 1 << samplesInXLog2;
|
||||
int samplesInY = 1 << samplesInYLog2;
|
||||
int sampleIdx = ((int(coords.x) >> deltaX) & (samplesInX - 1)) | (((int(coords.y) >> deltaY) & (samplesInY - 1)) << samplesInXLog2);
|
||||
|
||||
samplesInXLog2 = sample_counts_log2.x;
|
||||
samplesInYLog2 = sample_counts_log2.y;
|
||||
|
||||
ivec2 shiftedCoords = ivec2(int(coords.x) >> samplesInXLog2, int(coords.y) >> samplesInYLog2);
|
||||
|
||||
imageStore(dst, ivec2(coords), texelFetch(srcMS, shiftedCoords, sampleIdx));
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 0) uniform ratio_in
|
||||
{
|
||||
int ratio;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform usampler2D src;
|
||||
layout (set = 3, binding = 0) writeonly uniform uimage2D dst;
|
||||
|
||||
layout (local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
uvec2 coords = gl_GlobalInvocationID.xy;
|
||||
ivec2 imageSz = imageSize(dst);
|
||||
|
||||
if (int(coords.x) >= imageSz.x || int(coords.y) >= imageSz.y)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uvec2 srcCoords = uvec2(coords.x << ratio, coords.y);
|
||||
|
||||
uint r = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(0, 0)).r;
|
||||
uint g = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(1, 0)).r;
|
||||
uint b = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(2, 0)).r;
|
||||
uint a = texelFetchOffset(src, ivec2(srcCoords), 0, ivec2(3, 0)).r;
|
||||
|
||||
imageStore(dst, ivec2(coords), uvec4(r, g, b, a));
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 0) uniform sample_counts_log2_in
|
||||
{
|
||||
ivec4 sample_counts_log2;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform usampler2D src;
|
||||
|
||||
layout (location = 0) out uvec4 colour;
|
||||
|
||||
void main()
|
||||
{
|
||||
int deltaX = sample_counts_log2.x - sample_counts_log2.z;
|
||||
int deltaY = sample_counts_log2.y - sample_counts_log2.w;
|
||||
int samplesInXLog2 = sample_counts_log2.z;
|
||||
int samplesInYLog2 = sample_counts_log2.w;
|
||||
int samplesInX = 1 << samplesInXLog2;
|
||||
int samplesInY = 1 << samplesInYLog2;
|
||||
|
||||
int sampleIndex = gl_SampleID;
|
||||
|
||||
int inX = (int(gl_FragCoord.x) << sample_counts_log2.x) | ((sampleIndex & (samplesInX - 1)) << deltaX);
|
||||
int inY = (int(gl_FragCoord.y) << sample_counts_log2.y) | ((sampleIndex >> samplesInXLog2) << deltaY);
|
||||
|
||||
colour = texelFetch(src, ivec2(inX, inY), 0);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#version 450 core
|
||||
|
||||
void main()
|
||||
{
|
||||
int low = gl_VertexIndex & 1;
|
||||
int high = gl_VertexIndex >> 1;
|
||||
gl_Position.x = (float(low) - 0.5f) * 2.0f;
|
||||
gl_Position.y = (float(high) - 0.5f) * 2.0f;
|
||||
gl_Position.z = 0.0f;
|
||||
gl_Position.w = 1.0f;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
#version 450 core
|
||||
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
#extension GL_EXT_shader_8bit_storage : require
|
||||
|
||||
layout (local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout (std430, set = 0, binding = 0) uniform index_buffer_pattern
|
||||
{
|
||||
int ibp_pattern[8];
|
||||
int ibp_primitive_vertices;
|
||||
int ibp_primitive_vertices_out;
|
||||
int ibp_index_size;
|
||||
int ibp_index_size_out;
|
||||
int ibp_base_index;
|
||||
int ibp_index_stride;
|
||||
int src_offset;
|
||||
int total_primitives;
|
||||
};
|
||||
|
||||
layout (std430, set = 1, binding = 1) buffer in_s
|
||||
{
|
||||
uint8_t[] in_data;
|
||||
};
|
||||
|
||||
layout (std430, set = 1, binding = 2) buffer out_s
|
||||
{
|
||||
uint8_t[] out_data;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
int primitiveIndex = int(gl_GlobalInvocationID.x);
|
||||
if (primitiveIndex >= total_primitives)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int inOffset = primitiveIndex * ibp_index_stride;
|
||||
int outOffset = primitiveIndex * ibp_primitive_vertices_out;
|
||||
|
||||
for (int i = 0; i < ibp_primitive_vertices_out; i++)
|
||||
{
|
||||
int j;
|
||||
int io = max(0, inOffset + ibp_base_index + ibp_pattern[i]) * ibp_index_size;
|
||||
int oo = (outOffset + i) * ibp_index_size_out;
|
||||
|
||||
for (j = 0; j < ibp_index_size; j++)
|
||||
{
|
||||
out_data[oo + j] = in_data[src_offset + io + j];
|
||||
}
|
||||
|
||||
for (; j < ibp_index_size_out; j++)
|
||||
{
|
||||
out_data[oo + j] = uint8_t(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
#version 450 core
|
||||
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
|
||||
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout (std430, set = 0, binding = 0) uniform draw_count_uniform
|
||||
{
|
||||
uint[64] draw_count_buffer;
|
||||
};
|
||||
|
||||
layout (std430, set = 1, binding = 1) buffer indirect_in
|
||||
{
|
||||
int[] indirect_data_in;
|
||||
};
|
||||
|
||||
layout (std430, set = 1, binding = 2) buffer indirect_out
|
||||
{
|
||||
int[] indirect_data_out;
|
||||
};
|
||||
|
||||
layout (std430, set = 1, binding = 3) buffer index_buffer_pattern
|
||||
{
|
||||
int ibp_pattern[8];
|
||||
int ibp_primitive_vertices;
|
||||
int ibp_primitive_vertices_out;
|
||||
int ibp_index_size;
|
||||
int ibp_index_size_out;
|
||||
int ibp_base_index;
|
||||
int ibp_index_stride;
|
||||
int src_offset;
|
||||
int total_primitives;
|
||||
int dispatch_x;
|
||||
int dispatch_y;
|
||||
int dispatch_z;
|
||||
int has_draw_count;
|
||||
uint max_draw_count;
|
||||
int draw_count_offset;
|
||||
int indirect_data_stride;
|
||||
int indirect_data_offset;
|
||||
};
|
||||
|
||||
int GetPrimitiveCount(int vertexCount)
|
||||
{
|
||||
return max(0, (vertexCount - ibp_base_index) / ibp_index_stride);
|
||||
}
|
||||
|
||||
int GetConvertedCount(int indexCount)
|
||||
{
|
||||
int primitiveCount = GetPrimitiveCount(indexCount);
|
||||
return primitiveCount * ibp_primitive_vertices_out;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
uint drawCount = has_draw_count != 0 ? min(draw_count_buffer[draw_count_offset], max_draw_count) : max_draw_count;
|
||||
uint i = 0;
|
||||
|
||||
if (drawCount != 0)
|
||||
{
|
||||
int firstIndex = indirect_data_in[indirect_data_offset + 2];
|
||||
int endIndex = firstIndex + indirect_data_in[indirect_data_offset];
|
||||
|
||||
for (i = 1; i < drawCount; i++)
|
||||
{
|
||||
int offset = int(i) * indirect_data_stride;
|
||||
int inOffset = indirect_data_offset + offset;
|
||||
|
||||
int currentFirstIndex = indirect_data_in[inOffset + 2];
|
||||
firstIndex = min(firstIndex, currentFirstIndex);
|
||||
endIndex = max(endIndex, currentFirstIndex + indirect_data_in[inOffset]);
|
||||
}
|
||||
|
||||
int indexCount = endIndex - firstIndex;
|
||||
|
||||
dispatch_x = (indexCount + 15) / 16;
|
||||
src_offset += firstIndex * ibp_index_size;
|
||||
total_primitives = GetPrimitiveCount(indexCount);
|
||||
|
||||
for (i = 0; i < drawCount; i++)
|
||||
{
|
||||
int offset = int(i) * indirect_data_stride;
|
||||
int inOffset = indirect_data_offset + offset;
|
||||
|
||||
indirect_data_out[offset] = GetConvertedCount(indirect_data_in[inOffset]); // Index count
|
||||
indirect_data_out[offset + 1] = indirect_data_in[inOffset + 1]; // Instance count
|
||||
indirect_data_out[offset + 2] = GetConvertedCount(indirect_data_in[inOffset + 2] - firstIndex); // First index
|
||||
indirect_data_out[offset + 3] = indirect_data_in[inOffset + 3]; // Vertex offset
|
||||
indirect_data_out[offset + 4] = indirect_data_in[inOffset + 4]; // First instance
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < max_draw_count; i++)
|
||||
{
|
||||
int offset = int(i) * indirect_data_stride;
|
||||
|
||||
indirect_data_out[offset] = 0;
|
||||
indirect_data_out[offset + 1] = 0;
|
||||
indirect_data_out[offset + 2] = 0;
|
||||
indirect_data_out[offset + 3] = 0;
|
||||
indirect_data_out[offset + 4] = 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#version 450 core
|
||||
|
||||
layout (binding = 0, set = 2) uniform sampler2D texDepth;
|
||||
|
||||
layout (location = 0) in vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragDepth = texture(texDepth, tex_coord).r;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#version 450 core
|
||||
|
||||
layout (binding = 0, set = 2) uniform sampler2DMS texDepth;
|
||||
|
||||
layout (location = 0) in vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragDepth = texelFetch(texDepth, ivec2(tex_coord * vec2(textureSize(texDepth).xy)), gl_SampleID).r;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 0) uniform sample_counts_log2_in
|
||||
{
|
||||
ivec4 sample_counts_log2;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform sampler2D src;
|
||||
|
||||
void main()
|
||||
{
|
||||
int deltaX = sample_counts_log2.x - sample_counts_log2.z;
|
||||
int deltaY = sample_counts_log2.y - sample_counts_log2.w;
|
||||
int samplesInXLog2 = sample_counts_log2.z;
|
||||
int samplesInYLog2 = sample_counts_log2.w;
|
||||
int samplesInX = 1 << samplesInXLog2;
|
||||
int samplesInY = 1 << samplesInYLog2;
|
||||
|
||||
int sampleIndex = gl_SampleID;
|
||||
|
||||
int inX = (int(gl_FragCoord.x) << sample_counts_log2.x) | ((sampleIndex & (samplesInX - 1)) << deltaX);
|
||||
int inY = (int(gl_FragCoord.y) << sample_counts_log2.y) | ((sampleIndex >> samplesInXLog2) << deltaY);
|
||||
|
||||
gl_FragDepth = texelFetch(src, ivec2(inX, inY), 0).r;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#version 450 core
|
||||
|
||||
layout (std140, binding = 0) uniform sample_counts_log2_in
|
||||
{
|
||||
ivec4 sample_counts_log2;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform sampler2DMS srcMS;
|
||||
|
||||
void main()
|
||||
{
|
||||
uvec2 coords = uvec2(gl_FragCoord.xy);
|
||||
|
||||
int deltaX = sample_counts_log2.x - sample_counts_log2.z;
|
||||
int deltaY = sample_counts_log2.y - sample_counts_log2.w;
|
||||
int samplesInXLog2 = sample_counts_log2.z;
|
||||
int samplesInYLog2 = sample_counts_log2.w;
|
||||
int samplesInX = 1 << samplesInXLog2;
|
||||
int samplesInY = 1 << samplesInYLog2;
|
||||
int sampleIdx = ((int(coords.x) >> deltaX) & (samplesInX - 1)) | (((int(coords.y) >> deltaY) & (samplesInY - 1)) << samplesInXLog2);
|
||||
|
||||
samplesInXLog2 = sample_counts_log2.x;
|
||||
samplesInYLog2 = sample_counts_log2.y;
|
||||
|
||||
ivec2 shiftedCoords = ivec2(int(coords.x) >> samplesInXLog2, int(coords.y) >> samplesInYLog2);
|
||||
|
||||
gl_FragDepth = texelFetch(srcMS, shiftedCoords, sampleIdx).r;
|
||||
}
|
2413
src/Ryujinx.Graphics.Vulkan/Shaders/ShaderBinaries.cs
Normal file
2413
src/Ryujinx.Graphics.Vulkan/Shaders/ShaderBinaries.cs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,12 @@
|
|||
#version 450 core
|
||||
|
||||
#extension GL_ARB_shader_stencil_export : require
|
||||
|
||||
layout (binding = 0, set = 2) uniform isampler2D texStencil;
|
||||
|
||||
layout (location = 0) in vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragStencilRefARB = texture(texStencil, tex_coord).r;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#version 450 core
|
||||
|
||||
#extension GL_ARB_shader_stencil_export : require
|
||||
|
||||
layout (binding = 0, set = 2) uniform isampler2DMS texStencil;
|
||||
|
||||
layout (location = 0) in vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragStencilRefARB = texelFetch(texStencil, ivec2(tex_coord * vec2(textureSize(texStencil).xy)), gl_SampleID).r;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#version 450 core
|
||||
|
||||
#extension GL_ARB_shader_stencil_export : require
|
||||
|
||||
layout (std140, binding = 0) uniform sample_counts_log2_in
|
||||
{
|
||||
ivec4 sample_counts_log2;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform isampler2D src;
|
||||
|
||||
void main()
|
||||
{
|
||||
int deltaX = sample_counts_log2.x - sample_counts_log2.z;
|
||||
int deltaY = sample_counts_log2.y - sample_counts_log2.w;
|
||||
int samplesInXLog2 = sample_counts_log2.z;
|
||||
int samplesInYLog2 = sample_counts_log2.w;
|
||||
int samplesInX = 1 << samplesInXLog2;
|
||||
int samplesInY = 1 << samplesInYLog2;
|
||||
|
||||
int sampleIndex = gl_SampleID;
|
||||
|
||||
int inX = (int(gl_FragCoord.x) << sample_counts_log2.x) | ((sampleIndex & (samplesInX - 1)) << deltaX);
|
||||
int inY = (int(gl_FragCoord.y) << sample_counts_log2.y) | ((sampleIndex >> samplesInXLog2) << deltaY);
|
||||
|
||||
gl_FragStencilRefARB = texelFetch(src, ivec2(inX, inY), 0).r;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#version 450 core
|
||||
|
||||
#extension GL_ARB_shader_stencil_export : require
|
||||
|
||||
layout (std140, binding = 0) uniform sample_counts_log2_in
|
||||
{
|
||||
ivec4 sample_counts_log2;
|
||||
};
|
||||
|
||||
layout (set = 2, binding = 0) uniform isampler2DMS srcMS;
|
||||
|
||||
void main()
|
||||
{
|
||||
uvec2 coords = uvec2(gl_FragCoord.xy);
|
||||
|
||||
int deltaX = sample_counts_log2.x - sample_counts_log2.z;
|
||||
int deltaY = sample_counts_log2.y - sample_counts_log2.w;
|
||||
int samplesInXLog2 = sample_counts_log2.z;
|
||||
int samplesInYLog2 = sample_counts_log2.w;
|
||||
int samplesInX = 1 << samplesInXLog2;
|
||||
int samplesInY = 1 << samplesInYLog2;
|
||||
int sampleIdx = ((int(coords.x) >> deltaX) & (samplesInX - 1)) | (((int(coords.y) >> deltaY) & (samplesInY - 1)) << samplesInXLog2);
|
||||
|
||||
samplesInXLog2 = sample_counts_log2.x;
|
||||
samplesInYLog2 = sample_counts_log2.y;
|
||||
|
||||
ivec2 shiftedCoords = ivec2(int(coords.x) >> samplesInXLog2, int(coords.y) >> samplesInYLog2);
|
||||
|
||||
gl_FragStencilRefARB = texelFetch(srcMS, shiftedCoords, sampleIdx).r;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue