Skip to content

Commit

Permalink
Rename USING_DEPTH_STENCIL to RENDERING_MODE_MSAA
Browse files Browse the repository at this point in the history
Renamed the define to RENDERING_MODE_MSAA as we talked about yesterday.

Diffs=
e10bb4aafd Rename USING_DEPTH_STENCIL to RENDERING_MODE_MSAA (#8584)

Co-authored-by: klingerj <16977116+klingerj@users.noreply.github.com>
  • Loading branch information
klingerj and klingerj committed Nov 18, 2024
1 parent ec9e105 commit 4697d23
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
869816556f2c8cb29023c4c9a021e205f5f9af74
e10bb4aafde7da7455c21ccc4a56e353c6d7537b
2 changes: 1 addition & 1 deletion renderer/src/gl/render_context_gl_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ RenderContextGLImpl::DrawShader::DrawShader(
}
if (interlockMode == gpu::InterlockMode::msaa)
{
defines.push_back(GLSL_USING_DEPTH_STENCIL);
defines.push_back(GLSL_RENDER_MODE_MSAA);
}

std::vector<const char*> sources;
Expand Down
8 changes: 4 additions & 4 deletions renderer/src/shaders/common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Common functions shared by multiple shaders.
#define PI float(3.141592653589793238)

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
#define AA_RADIUS float(.5)
#else
#define AA_RADIUS float(.0)
Expand Down Expand Up @@ -188,7 +188,7 @@ UNIFORM_BLOCK_END(uniforms)
.0, \
1.)

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
// Calculates the Manhattan distance in pixels from the given pixelPosition, to
// the point at each edge of the clipRect where coverage = 0.
//
Expand Down Expand Up @@ -220,7 +220,7 @@ INLINE float4 find_clip_rect_coverage_distances(float2x2 clipRectInverseMatrix,
}
}

#else // USING_DEPTH_STENCIL
#else // RENDER_MODE_MSAA

INLINE float normalize_z_index(uint zIndex)
{
Expand Down Expand Up @@ -251,7 +251,7 @@ INLINE void set_clip_rect_plane_distances(float2x2 clipRectInverseMatrix,
}
}
#endif // ENABLE_CLIP_RECT
#endif // USING_DEPTH_STENCIL
#endif // RENDER_MODE_MSAA
#endif // VERTEX

#ifdef @DRAW_IMAGE
Expand Down
16 changes: 8 additions & 8 deletions renderer/src/shaders/draw_image_mesh.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ IMAGE_MESH_VERTEX_MAIN(@drawVertexMain,
#ifdef @ENABLE_CLIP_RECT
if (@ENABLE_CLIP_RECT)
{
#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
v_clipRect = find_clip_rect_coverage_distances(
make_float2x2(imageDrawUniforms.clipRectInverseMatrix),
imageDrawUniforms.clipRectInverseTranslate,
vertexPosition);
#else // USING_DEPTH_STENCIL
#else // RENDER_MODE_MSAA
set_clip_rect_plane_distances(
make_float2x2(imageDrawUniforms.clipRectInverseMatrix),
imageDrawUniforms.clipRectInverseTranslate,
vertexPosition);
#endif // USING_DEPTH_STENCIL
#endif // RENDER_MODE_MSAA
}
#endif // ENABLE_CLIP_RECT
float4 pos = RENDER_TARGET_COORD_TO_CLIP_COORD(vertexPosition);
#ifdef @USING_DEPTH_STENCIL
#ifdef @RENDER_MODE_MSAA
pos.z = normalize_z_index(imageDrawUniforms.zIndex);
#endif

Expand All @@ -90,7 +90,7 @@ IMAGE_MESH_VERTEX_MAIN(@drawVertexMain,
#ifdef @FRAGMENT
FRAG_TEXTURE_BLOCK_BEGIN
TEXTURE_RGBA8(PER_DRAW_BINDINGS_SET, IMAGE_TEXTURE_IDX, @imageTexture);
#ifdef @USING_DEPTH_STENCIL
#ifdef @RENDER_MODE_MSAA
#ifdef @ENABLE_ADVANCED_BLEND
TEXTURE_RGBA8(PER_FLUSH_BINDINGS_SET, DST_COLOR_TEXTURE_IDX, @dstColorTexture);
#endif
Expand All @@ -102,7 +102,7 @@ SAMPLER_MIPMAP(IMAGE_TEXTURE_IDX, imageSampler)
FRAG_STORAGE_BUFFER_BLOCK_BEGIN
FRAG_STORAGE_BUFFER_BLOCK_END

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA

PLS_BLOCK_BEGIN
PLS_DECL4F(COLOR_PLANE_IDX, colorBuffer);
Expand Down Expand Up @@ -175,7 +175,7 @@ PLS_MAIN_WITH_IMAGE_UNIFORMS(@drawFragmentMain)
EMIT_PLS;
}

#else // USING_DEPTH_STENCIL
#else // RENDER_MODE_MSAA

FRAG_DATA_MAIN(half4, @drawFragmentMain)
{
Expand All @@ -202,5 +202,5 @@ FRAG_DATA_MAIN(half4, @drawFragmentMain)
EMIT_FRAG_DATA(color);
}

#endif // USING_DEPTH_STENCIL
#endif // RENDER_MODE_MSAA
#endif // FRAGMENT
36 changes: 18 additions & 18 deletions renderer/src/shaders/draw_path.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ATTR_BLOCK_END

VARYING_BLOCK_BEGIN
NO_PERSPECTIVE VARYING(0, float4, v_paint);
#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
#ifdef @DRAW_INTERIOR_TRIANGLES
@OPTIONALLY_FLAT VARYING(1, half, v_windingWeight);
#else
Expand All @@ -30,7 +30,7 @@ NO_PERSPECTIVE VARYING(2, half2, v_edgeDistance);
#ifdef @ENABLE_CLIP_RECT
NO_PERSPECTIVE VARYING(5, float4, v_clipRect);
#endif
#endif // !USING_DEPTH_STENCIL
#endif // !RENDER_MODE_MSAA
#ifdef @ENABLE_ADVANCED_BLEND
@OPTIONALLY_FLAT VARYING(6, half, v_blendMode);
#endif
Expand All @@ -47,7 +47,7 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
#endif

VARYING_INIT(v_paint, float4);
#ifndef USING_DEPTH_STENCIL
#ifndef RENDER_MODE_MSAA
#ifdef @DRAW_INTERIOR_TRIANGLES
VARYING_INIT(v_windingWeight, half);
#else
Expand All @@ -60,15 +60,15 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
#ifdef @ENABLE_CLIP_RECT
VARYING_INIT(v_clipRect, float4);
#endif
#endif // !USING_DEPTH_STENCIL
#endif // !RENDER_MODE_MSAA
#ifdef @ENABLE_ADVANCED_BLEND
VARYING_INIT(v_blendMode, half);
#endif

bool shouldDiscardVertex = false;
ushort pathID;
float2 vertexPosition;
#ifdef @USING_DEPTH_STENCIL
#ifdef @RENDER_MODE_MSAA
ushort pathZIndex;
#endif

Expand All @@ -84,7 +84,7 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
_instanceID,
pathID,
vertexPosition
#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
,
v_edgeDistance
#else
Expand All @@ -96,15 +96,15 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)

uint2 paintData = STORAGE_BUFFER_LOAD2(@paintBuffer, pathID);

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
// Encode the integral pathID as a "half" that we know the hardware will see
// as a unique value in the fragment shader.
v_pathID = id_bits_to_f16(pathID, uniforms.pathIDGranularity);

// Indicate even-odd fill rule by making pathID negative.
if ((paintData.x & PAINT_FLAG_EVEN_ODD) != 0u)
v_pathID = -v_pathID;
#endif // !USING_DEPTH_STENCIL
#endif // !RENDER_MODE_MSAA

uint paintType = paintData.x & 0xfu;
#ifdef @ENABLE_CLIPPING
Expand Down Expand Up @@ -143,16 +143,16 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
STORAGE_BUFFER_LOAD4(@paintAuxBuffer, pathID * 4u + 2u));
float4 clipRectInverseTranslate =
STORAGE_BUFFER_LOAD4(@paintAuxBuffer, pathID * 4u + 3u);
#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
v_clipRect =
find_clip_rect_coverage_distances(clipRectInverseMatrix,
clipRectInverseTranslate.xy,
fragCoord);
#else // USING_DEPTH_STENCIL
#else // RENDER_MODE_MSAA
set_clip_rect_plane_distances(clipRectInverseMatrix,
clipRectInverseTranslate.xy,
fragCoord);
#endif // USING_DEPTH_STENCIL
#endif // RENDER_MODE_MSAA
}
#endif // ENABLE_CLIP_RECT

Expand Down Expand Up @@ -231,7 +231,7 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
if (!shouldDiscardVertex)
{
pos = RENDER_TARGET_COORD_TO_CLIP_COORD(vertexPosition);
#ifdef @USING_DEPTH_STENCIL
#ifdef @RENDER_MODE_MSAA
pos.z = normalize_z_index(pathZIndex);
#endif
}
Expand All @@ -244,7 +244,7 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
}

VARYING_PACK(v_paint);
#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
#ifdef @DRAW_INTERIOR_TRIANGLES
VARYING_PACK(v_windingWeight);
#else
Expand All @@ -257,7 +257,7 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
#ifdef @ENABLE_CLIP_RECT
VARYING_PACK(v_clipRect);
#endif
#endif // !USING_DEPTH_STENCIL
#endif // !RENDER_MODE_MSAA
#ifdef @ENABLE_ADVANCED_BLEND
VARYING_PACK(v_blendMode);
#endif
Expand All @@ -269,7 +269,7 @@ VERTEX_MAIN(@drawVertexMain, Attrs, attrs, _vertexID, _instanceID)
FRAG_TEXTURE_BLOCK_BEGIN
TEXTURE_RGBA8(PER_FLUSH_BINDINGS_SET, GRAD_TEXTURE_IDX, @gradTexture);
TEXTURE_RGBA8(PER_DRAW_BINDINGS_SET, IMAGE_TEXTURE_IDX, @imageTexture);
#ifdef @USING_DEPTH_STENCIL
#ifdef @RENDER_MODE_MSAA
#ifdef @ENABLE_ADVANCED_BLEND
TEXTURE_RGBA8(PER_FLUSH_BINDINGS_SET, DST_COLOR_TEXTURE_IDX, @dstColorTexture);
#endif
Expand Down Expand Up @@ -318,7 +318,7 @@ INLINE half4 find_paint_color(float4 paint FRAGMENT_CONTEXT_DECL)
}
}

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA

PLS_BLOCK_BEGIN
PLS_DECL4F(COLOR_PLANE_IDX, colorBuffer);
Expand Down Expand Up @@ -518,7 +518,7 @@ PLS_MAIN(@drawFragmentMain)
EMIT_PLS;
}

#else // USING_DEPTH_STENCIL
#else // RENDER_MODE_MSAA

FRAG_DATA_MAIN(half4, @drawFragmentMain)
{
Expand Down Expand Up @@ -546,6 +546,6 @@ FRAG_DATA_MAIN(half4, @drawFragmentMain)
EMIT_FRAG_DATA(color);
}

#endif // !USING_DEPTH_STENCIL
#endif // !RENDER_MODE_MSAA

#endif // FRAGMENT
12 changes: 6 additions & 6 deletions renderer/src/shaders/draw_path_common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ INLINE bool unpack_tessellated_path_vertex(float4 patchVertexData,
int _instanceID,
OUT(ushort) o_pathID,
OUT(float2) o_vertexPosition
#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
,
OUT(half2) o_edgeDistance
#else
Expand Down Expand Up @@ -76,7 +76,7 @@ INLINE bool unpack_tessellated_path_vertex(float4 patchVertexData,
float2 translate = uintBitsToFloat(pathData.xy);

float strokeRadius = uintBitsToFloat(pathData.z);
#ifdef @USING_DEPTH_STENCIL
#ifdef @RENDER_MODE_MSAA
o_pathZIndex = cast_uint_to_ushort(pathData.w);
#endif

Expand Down Expand Up @@ -160,7 +160,7 @@ INLINE bool unpack_tessellated_path_vertex(float4 patchVertexData,
float2 vertexOffset =
MUL(norm, strokeRadius + aaRadius); // Bloat stroke width for AA.

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
// Calculate the AA distance to both the outset and inset edges of the
// stroke. The fragment shader will use whichever is lesser.
float x = outset * (strokeRadius + aaRadius);
Expand Down Expand Up @@ -266,15 +266,15 @@ INLINE bool unpack_tessellated_path_vertex(float4 patchVertexData,
float2 pt = abs(outset) * vertexOffset;
float clipDistance = (clipAARadius - dot(pt, bisector)) /
(bisectPixelWidth * (AA_RADIUS * 2.));
#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
if ((contourIDWithFlags & LEFT_JOIN_CONTOUR_FLAG) != 0u)
o_edgeDistance.y = cast_float_to_half(clipDistance);
else
o_edgeDistance.x = cast_float_to_half(clipDistance);
#endif
}

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
o_edgeDistance *= globalCoverage;

// Bias o_edgeDistance.y slightly upwards in order to guarantee
Expand Down Expand Up @@ -305,7 +305,7 @@ INLINE bool unpack_tessellated_path_vertex(float4 patchVertexData,
fillCoverage = -fillCoverage;
}

#ifndef @USING_DEPTH_STENCIL
#ifndef @RENDER_MODE_MSAA
// "o_edgeDistance.y < 0" indicates to the fragment shader that this is
// a fill.
o_edgeDistance = make_half2(fillCoverage, -1.);
Expand Down
6 changes: 3 additions & 3 deletions renderer/src/shaders/glsl.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
#endif

// clang-format off
#if defined(@USING_DEPTH_STENCIL) && defined(@ENABLE_CLIP_RECT) && defined(GL_ES)
#if defined(@RENDER_MODE_MSAA) && defined(@ENABLE_CLIP_RECT) && defined(GL_ES)
// clang-format on
#ifdef GL_EXT_clip_cull_distance
#extension GL_EXT_clip_cull_distance : require
#elif defined(GL_ANGLE_clip_cull_distance)
#extension GL_ANGLE_clip_cull_distance : require
#endif
#endif // USING_DEPTH_STENCIL && ENABLE_CLIP_RECT
#endif // RENDER_MODE_MSAA && ENABLE_CLIP_RECT

#if @GLSL_VERSION >= 310
#define UNIFORM_BLOCK_BEGIN(IDX, NAME) \
Expand Down Expand Up @@ -543,7 +543,7 @@ INLINE half4 unpackUnorm4x8(uint u)
#endif

// clang-format off
#if @GLSL_VERSION >= 310 && defined(@VERTEX) && defined(@USING_DEPTH_STENCIL) && defined(@ENABLE_CLIP_RECT)
#if @GLSL_VERSION >= 310 && defined(@VERTEX) && defined(@RENDER_MODE_MSAA) && defined(@ENABLE_CLIP_RECT)
out gl_PerVertex
{
// Redeclare gl_ClipDistance with exactly 4 clip planes.
Expand Down

0 comments on commit 4697d23

Please sign in to comment.