Skip to content

Commit

Permalink
[WebXR] Refactor WebXROpaqueFramebuffer attachment logic
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269683
rdar://123201364

Reviewed by Tim Horton.

Patches are from Dan and I added some small bug fixes.

Refactor WebXROpaqueFramebuffer handling of framebuffer attachments to support
Shared or Layered layout.

There are a few combinations of context attributes that WebXROpaqueFramebuffer
handles:

if `antialias`:
   Create internal MSAA color buffer
   if `depth/stencil`
      Create internal MSAA depth/stencil buffer
if `!antialias`:
   Draw to externally provided color texture
   if `depth/stencil`
       if `!externally provided depth/stencil`
           Create internal depth/stencil buffer

Prior to this change, the code handled these combinations in `StartFrame(...)` &
`SetupFramebuffer(...)` with a loose collection of state.

This change simplifies the old assumption, dropping support for external
Textures, standardizing on Renderbuffers, and introduces helpers for keeping
related state together via `WebXRExternalRenderbuffer` and
`WebXRAttachmentSet`.

WebXRExternalRenderbuffer represents an externally provided Renderbuffer through
the OpenGL renderbuffer object and EGLImage pointer.

WebXRAttachmentSet represents a group of related color, depth and stencil
buffers. These can be "internal" or "external" via `WebXRAttachments` &
`WebXRExternalAttachments`.

Object naming has been changed to consistently use `draw` for the target of
WebGL rendering commands and `display` for the target presented to the user via
a WebXR compositor system. To simplify the handling of attachments, the output
of WebGL commands are always "blitted" from the draw target to display target,
removing the optimal path in the previous code. This path will not be taken on
any compositors supported on Cocoa and will be redressed in a future patch.

Due to limitations of `glBlitFramebuffer`, blitting to `Layered` layout from an
MSAA enabled attachment set requires the use of an intermediate, resolved path
represented by the `resolve` prefixed `m_resolvedAttachments` & `m_resolveFBO`.

* Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:
(WebCore::ensure):
(WebCore::createAndBindCompositorBuffer):
(WebCore::WebXROpaqueFramebuffer::WebXROpaqueFramebuffer):
(WebCore::WebXROpaqueFramebuffer::~WebXROpaqueFramebuffer):
(WebCore::WebXROpaqueFramebuffer::startFrame):
(WebCore::WebXROpaqueFramebuffer::endFrame):
(WebCore::WebXROpaqueFramebuffer::resolveMSAAFramebuffer):
(WebCore::WebXROpaqueFramebuffer::blitShared):
(WebCore::WebXROpaqueFramebuffer::blitSharedToLayered):
(WebCore::WebXROpaqueFramebuffer::setupFramebuffer):
(WebCore::WebXROpaqueFramebuffer::allocateRenderbufferStorage):
(WebCore::WebXROpaqueFramebuffer::allocateAttachments):
(WebCore::WebXROpaqueFramebuffer::bindAttachments):
(WebCore::WebXRExternalRenderbuffer::destroyImage):
(WebCore::WebXRExternalRenderbuffer::release):
(WebCore::WebXRExternalRenderbuffer::leakObject):
(WebCore::createAndBindCompositorTexture): Deleted.
(WebCore::WebXROpaqueFramebuffer::allocateColorStorage): Deleted.
(WebCore::WebXROpaqueFramebuffer::allocateDepthStencilStorage): Deleted.
(WebCore::WebXROpaqueFramebuffer::bindColorBuffer): Deleted.
(WebCore::WebXROpaqueFramebuffer::bindDepthStencilBuffer): Deleted.
* Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.h:
(WebCore::WebXRAttachmentSet::release):
(WebCore::WebXRAttachmentSet::leakObject):
(WebCore::WebXROpaqueFramebuffer::framebuffer const):
* Source/WebCore/platform/graphics/GraphicsContextGL.h:
(WebCore::destroyFunc):
* Source/WebCore/platform/xr/PlatformXR.h:
* Source/WebKit/Shared/XR/PlatformXR.serialization.in:
* Source/WebKit/UIProcess/XR/ios/PlatformXRARKit.mm:
(WebKit::ARKitCoordinator::renderLoop):

Metal: Override internal format of images

Add support for overriding the internal format when binding Metal
textures to EGL images.

Fixed: angleproject:8552
Change-Id: I364a88a2e608e462c5216c92927679814ab91ca5

The following changes make blitting work.

* Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:
(WebCore::createAndBindCompositorBuffer):
(WebCore::WebXROpaqueFramebuffer::startFrame):
* Source/WebCore/platform/graphics/GraphicsContextGL.h:
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::createAndBindEGLImage):
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h:
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h:
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::GraphicsContextGLCocoa::createAndBindEGLImage):
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::createAndBindEGLImage):
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::createAndBindEGLImage):
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* Source/WebKit/WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm:

Helper utilites for creating, enabled and disabling the use of rasterization
rate maps in GPUP. Infrastructure inplace to support caching of map for Shared
and Layered layouts, but only Shared is currently supported.

* Source/WebCore/PAL/pal/spi/cocoa/MetalSPI.h:
* Source/WebCore/platform/graphics/GraphicsContextGL.h:
* Source/WebCore/platform/graphics/GraphicsTypesGL.h:
* Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.h:
* Source/WebCore/platform/graphics/cocoa/ANGLEUtilitiesCocoa.mm:
(WebCore::newRasterizationRateMap):
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h:
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::GraphicsContextGLCocoa::createFoveation):
(WebCore::GraphicsContextGLCocoa::enableFoveation):
(WebCore::GraphicsContextGLCocoa::disableFoveation):
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:
(createFoveation):
(enableFoveation):
(disableFoveation):
* Source/WebKit/Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
(headers_for_type):
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp:
(WebKit::RemoteGraphicsContextGLProxy::createFoveation):
(WebKit::RemoteGraphicsContextGLProxy::enableFoveation):
(WebKit::RemoteGraphicsContextGLProxy::disableFoveation):
* Tools/Scripts/generate-gpup-webgl:

Refactor setup logic to be passed once. WebXROpaqueFramebuffer::setupFramebuffer
should extract the necessary data to create framebuffers from the information
provided in PlatformXR::FrameData::LayerSetupData.

Changed WebXRWebGLLayer to query WebXROpaqueFramebuffer for the viewport, since
WebXRWebGLLayer has no knowledge of the structure of the layout, dimensions,
etc.

Canonical link: https://commits.webkit.org/276825@main
  • Loading branch information
djg authored and mwyrzykowski committed Mar 29, 2024
1 parent 8af90c0 commit 42e8269
Show file tree
Hide file tree
Showing 95 changed files with 1,227 additions and 225 deletions.
3 changes: 3 additions & 0 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -7445,3 +7445,6 @@ imported/w3c/web-platform-tests/svg/text/reftests/transform-dynamic-change.html

# re-import css/css-align WPT failure
webkit.org/b/271692 imported/w3c/web-platform-tests/css/css-align/blocks/align-content-block-break-overflow-020.html [ ImageOnlyFailure ]

# https://bugs.webkit.org/show_bug.cgi?id=271874
webkit.org/b/271874 webgl/2.0.0/conformance2/rendering/blitframebuffer-test.html [ Skip ]
3 changes: 2 additions & 1 deletion LayoutTests/platform/gtk/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-filter-sr
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-multisampled-readbuffer.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-outside-readbuffer.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-stencil-only.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-test.html [ Pass Failure ]
# https://bugs.webkit.org/show_bug.cgi?id=271874
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-test.html [ Skip ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/clear-srgb-color-buffer.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/draw-buffers.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/element-index-uint.html [ Pass Failure ]
Expand Down
2 changes: 1 addition & 1 deletion LayoutTests/platform/wpe/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ webkit.org/b/251107 webgl/2.0.0/conformance2/extensions/ext-color-buffer-float.h
webkit.org/b/251107 webgl/2.0.0/conformance2/extensions/ext-color-buffer-half-float.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/renderbuffers/invalidate-framebuffer.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/renderbuffers/multisample-with-full-sample-counts.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-test.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/blitframebuffer-test.html [ Skip ]
webkit.org/b/251107 webgl/2.0.0/conformance2/rendering/rgb-format-support.html [ Pass Failure ]
webkit.org/b/251107 webgl/2.0.0/conformance2/textures/canvas_sub_rectangle/tex-2d-r32f-red-float.html [ Pass Timeout ]
webkit.org/b/251107 webgl/2.0.0/conformance2/textures/canvas_sub_rectangle/tex-2d-rgb5_a1-rgba-unsigned_short_5_5_5_1.html [ Pass Timeout ]
Expand Down
1 change: 1 addition & 0 deletions Source/ThirdParty/ANGLE/doc/ExtensionSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ using data from registry_xml.py and gl.xml.
| [GL_ANGLE_texture_external_update](https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/ANGLE_texture_external_update.txt) | | | | | | | |
| [GL_ANGLE_texture_multisample](https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/ANGLE_texture_multisample.txt) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GL_ANGLE_texture_rectangle](https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/ANGLE_texture_rectangle.txt) | | | | | | | |
| [GL_ANGLE_variable_rasterization_rate_metal](https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/ANGLE_variable_rasterization_rate_metal.txt) | | | | | | | |
| [GL_ANGLE_vulkan_image](https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/ANGLE_vulkan_image.txt) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GL_ANGLE_webgl_compatibility](https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/ANGLE_webgl_compatibility.txt) | | | | | | | |
| [GL_ANGLE_yuv_internal_format](https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/ANGLE_yuv_internal_format.txt) | ✔ | | ✔ | ✔ | ✔ | ✔ | ✔ |
Expand Down
12 changes: 12 additions & 0 deletions Source/ThirdParty/ANGLE/include/GLES2/gl2ext_angle.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,4 +731,16 @@ GL_APICALL void GL_APIENTRY glLogicOpANGLE (GLenum);
#endif
#endif /* GL_ANGLE_logic_op */

#ifndef GL_ANGLE_variable_rasterization_rate_metal
#define GL_ANGLE_variable_rasterization_rate_metal 1

#define GL_VARIABLE_RASTERIZATION_RATE_ANGLE 0x96BC
#define GL_METAL_RASTERIZATION_RATE_MAP_BINDING_ANGLE 0x96BD
typedef void *GLMTLRasterizationRateMapANGLE;
typedef void (GL_APIENTRYP PFNGLBINDMETALRASTERIZATIONRATEMAPANGLEPROC) (GLuint, GLMTLRasterizationRateMapANGLE);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBindMetalRasterizationRateMapANGLE(GLuint framebuffer, GLMTLRasterizationRateMapANGLE map);
#endif
#endif /* GL_ANGLE_variable_rasterization_rate_metal */

#endif // INCLUDE_GLES2_GL2EXT_ANGLE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ struct FeaturesMtl : FeatureSetBase
&members,
};

FeatureInfo hasVariableRasterizationRate = {
"hasVariableRasterizationRate",
FeatureCategory::MetalFeatures,
"The renderer supports variable rasterization rate",
&members,
};

FeatureInfo allowInlineConstVertexData = {
"allowInlineConstVertexData",
FeatureCategory::MetalFeatures,
Expand Down
7 changes: 7 additions & 0 deletions Source/ThirdParty/ANGLE/include/platform/mtl_features.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
"The renderer supports MTL(Shared)Event"
]
},
{
"name": "has_variable_rasterization_rate",
"category": "Features",
"description": [
"The renderer supports variable rasterization rate"
]
},
{
"name": "allow_inline_const_vertex_data",
"category": "Features",
Expand Down
1 change: 1 addition & 0 deletions Source/ThirdParty/ANGLE/scripts/generate_entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ class ErrorSet;
"GLfloat": "%f",
"GLint": "%d",
"GLintptr": UNSIGNED_LONG_LONG_FORMAT,
"GLMTLRasterizationRateMapANGLE": POINTER_FORMAT,
"GLshort": "%d",
"GLsizei": "%d",
"GLsizeiptr": UNSIGNED_LONG_LONG_FORMAT,
Expand Down
20 changes: 20 additions & 0 deletions Source/ThirdParty/ANGLE/scripts/gl_angle_ext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
Includes data used to auto-generate ANGLE classes.
</comment>

<!-- SECTION: GL type definitions. -->
<types>
<type>typedef void *<name>GLMTLRasterizationRateMapANGLE</name>;</type>
</types>

<!-- SECTION: GL parameter class type definitions. -->
<groups>
<group name="CreateFlagMask">
Expand Down Expand Up @@ -1048,6 +1053,11 @@
<param group="LogicOp"><ptype>GLenum</ptype> <name>opcode</name></param>
<alias name="glLogicOp"/>
</command>
<command>
<proto>void <name>glBindMetalRasterizationRateMapANGLE</name></proto>
<param><ptype>GLuint</ptype> <name>framebuffer</name></param>
<param><ptype>GLMTLRasterizationRateMapANGLE</ptype> <name>map</name></param>
</command>
</commands>

<!-- SECTION: ANGLE extension interface definitions -->
Expand Down Expand Up @@ -1444,6 +1454,11 @@
<extension name="GL_ANGLE_shader_binary" supported='gles2'>
<require>
<enum name="GL_SHADER_BINARY_ANGLE"/>
<extension name="GL_ANGLE_variable_rasterization_rate_metal" supported="gles2">
<require>
<enum name="GL_VARIABLE_RASTERIZATION_RATE_ANGLE"/>
<enum name="GL_METAL_RASTERIZATION_RATE_MAP_BINDING_ANGLE"/>
<command name="glBindMetalRasterizationRateMapANGLE"/>
</require>
</extension>
</extensions>
Expand Down Expand Up @@ -1624,4 +1639,9 @@
<enums namespace="GL" start="0x0BF2" end="0x0BF2" vendor="ANGLE">
<enum value="0x0BF2" name="GL_COLOR_LOGIC_OP_ANGLE"/>
</enums>

<enums namespace="GL" start="0x96BC" end="0x96BD" vendor="ANGLE">
<enum value="0x96BC" name="GL_VARIABLE_RASTERIZATION_RATE_ANGLE"/>
<enum value="0x96BD" name="GL_METAL_RASTERIZATION_RATE_MAP_BINDING_ANGLE"/>
</enums>
</registry>
1 change: 1 addition & 0 deletions Source/ThirdParty/ANGLE/scripts/registry_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"GL_ANGLE_texture_compression_dxt5",
"GL_ANGLE_texture_external_update",
"GL_ANGLE_texture_multisample",
"GL_ANGLE_variable_rasterization_rate_metal",
"GL_ANGLE_vulkan_image",
"GL_ANGLE_yuv_internal_format",
"GL_CHROMIUM_color_buffer_float_rgb",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ const char *GetEntryPointName(EntryPoint ep)
return "glBindImageTexture";
case EntryPoint::GLBindImageTextures:
return "glBindImageTextures";
case EntryPoint::GLBindMetalRasterizationRateMapANGLE:
return "glBindMetalRasterizationRateMapANGLE";
case EntryPoint::GLBindProgramPipeline:
return "glBindProgramPipeline";
case EntryPoint::GLBindProgramPipelineEXT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ enum class EntryPoint
GLBindFramebufferOES,
GLBindImageTexture,
GLBindImageTextures,
GLBindMetalRasterizationRateMapANGLE,
GLBindProgramPipeline,
GLBindProgramPipelineEXT,
GLBindRenderbuffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ void WriteParamCaptureReplay(std::ostream &os, const CallCapture &call, const Pa
WriteParamValueReplay<ParamType::TGLDEBUGPROCKHR>(os, call,
param.value.GLDEBUGPROCKHRVal);
break;
case ParamType::TGLMTLRasterizationRateMapANGLE:
WriteParamValueReplay<ParamType::TGLMTLRasterizationRateMapANGLE>(
os, call, param.value.GLMTLRasterizationRateMapANGLEVal);
break;
case ParamType::TGLbitfield:
WriteParamValueReplay<ParamType::TGLbitfield>(os, call, param.value.GLbitfieldVal);
break;
Expand Down Expand Up @@ -768,6 +772,8 @@ const char *ParamTypeToString(ParamType paramType)
return "GLDEBUGPROC";
case ParamType::TGLDEBUGPROCKHR:
return "GLDEBUGPROCKHR";
case ParamType::TGLMTLRasterizationRateMapANGLE:
return "GLMTLRasterizationRateMapANGLE";
case ParamType::TGLbitfield:
return "GLbitfield";
case ParamType::TGLboolean:
Expand Down
25 changes: 24 additions & 1 deletion Source/ThirdParty/ANGLE/src/common/frame_capture_utils_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ enum class ParamType
TFramebufferIDPointer,
TGLDEBUGPROC,
TGLDEBUGPROCKHR,
TGLMTLRasterizationRateMapANGLE,
TGLbitfield,
TGLboolean,
TGLbooleanConstPointer,
Expand Down Expand Up @@ -191,7 +192,7 @@ enum class ParamType
TvoidPointerPointer,
};

constexpr uint32_t kParamTypeCount = 172;
constexpr uint32_t kParamTypeCount = 173;

union ParamValue
{
Expand Down Expand Up @@ -252,6 +253,7 @@ union ParamValue
gl::FramebufferID *FramebufferIDPointerVal;
GLDEBUGPROC GLDEBUGPROCVal;
GLDEBUGPROCKHR GLDEBUGPROCKHRVal;
GLMTLRasterizationRateMapANGLE GLMTLRasterizationRateMapANGLEVal;
GLbitfield GLbitfieldVal;
GLboolean GLbooleanVal;
const GLboolean *GLbooleanConstPointerVal;
Expand Down Expand Up @@ -745,6 +747,14 @@ inline GLDEBUGPROCKHR GetParamVal<ParamType::TGLDEBUGPROCKHR, GLDEBUGPROCKHR>(
return value.GLDEBUGPROCKHRVal;
}

template <>
inline GLMTLRasterizationRateMapANGLE
GetParamVal<ParamType::TGLMTLRasterizationRateMapANGLE, GLMTLRasterizationRateMapANGLE>(
const ParamValue &value)
{
return value.GLMTLRasterizationRateMapANGLEVal;
}

template <>
inline GLbitfield GetParamVal<ParamType::TGLbitfield, GLbitfield>(const ParamValue &value)
{
Expand Down Expand Up @@ -1629,6 +1639,8 @@ T AccessParamValue(ParamType paramType, const ParamValue &value)
return GetParamVal<ParamType::TGLDEBUGPROC, T>(value);
case ParamType::TGLDEBUGPROCKHR:
return GetParamVal<ParamType::TGLDEBUGPROCKHR, T>(value);
case ParamType::TGLMTLRasterizationRateMapANGLE:
return GetParamVal<ParamType::TGLMTLRasterizationRateMapANGLE, T>(value);
case ParamType::TGLbitfield:
return GetParamVal<ParamType::TGLbitfield, T>(value);
case ParamType::TGLboolean:
Expand Down Expand Up @@ -2227,6 +2239,14 @@ inline void SetParamVal<ParamType::TGLDEBUGPROCKHR>(GLDEBUGPROCKHR valueIn, Para
valueOut->GLDEBUGPROCKHRVal = valueIn;
}

template <>
inline void SetParamVal<ParamType::TGLMTLRasterizationRateMapANGLE>(
GLMTLRasterizationRateMapANGLE valueIn,
ParamValue *valueOut)
{
valueOut->GLMTLRasterizationRateMapANGLEVal = valueIn;
}

template <>
inline void SetParamVal<ParamType::TGLbitfield>(GLbitfield valueIn, ParamValue *valueOut)
{
Expand Down Expand Up @@ -3149,6 +3169,9 @@ void InitParamValue(ParamType paramType, T valueIn, ParamValue *valueOut)
case ParamType::TGLDEBUGPROCKHR:
SetParamVal<ParamType::TGLDEBUGPROCKHR>(valueIn, valueOut);
break;
case ParamType::TGLMTLRasterizationRateMapANGLE:
SetParamVal<ParamType::TGLMTLRasterizationRateMapANGLE>(valueIn, valueOut);
break;
case ParamType::TGLbitfield:
SetParamVal<ParamType::TGLbitfield>(valueIn, valueOut);
break;
Expand Down
6 changes: 6 additions & 0 deletions Source/ThirdParty/ANGLE/src/common/gl_enum_utils_autogen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2810,6 +2810,10 @@ const char *GLenumToString(GLESEnum enumGroup, unsigned int value)
return "GL_RGBX8_ANGLE";
case 0x96BB:
return "GL_SHADER_BINARY_ANGLE";
case 0x96BC:
return "GL_VARIABLE_RASTERIZATION_RATE_ANGLE";
case 0x96BD:
return "GL_METAL_RASTERIZATION_RATE_MAP_BINDING_ANGLE";
case 0x96E0:
return "GL_MAX_PIXEL_LOCAL_STORAGE_PLANES_ANGLE";
case 0x96E1:
Expand Down Expand Up @@ -22077,6 +22081,7 @@ static StringEnumEntry g_stringEnumTable[] = {
{"GL_MESH_SUBROUTINE_UNIFORM_NV", 0x957E},
{"GL_MESH_VERTICES_OUT_NV", 0x9579},
{"GL_MESH_WORK_GROUP_SIZE_NV", 0x953E},
{"GL_METAL_RASTERIZATION_RATE_MAP_BINDING_ANGLE", 0x96BD},
{"GL_MIN", 0x8007},
{"GL_MINMAX", 0x802E},
{"GL_MINMAX_EXT", 0x802E},
Expand Down Expand Up @@ -24727,6 +24732,7 @@ static StringEnumEntry g_stringEnumTable[] = {
{"GL_VARIABLE_E_NV", 0x8527},
{"GL_VARIABLE_F_NV", 0x8528},
{"GL_VARIABLE_G_NV", 0x8529},
{"GL_VARIABLE_RASTERIZATION_RATE_ANGLE", 0x96BC},
{"GL_VARIANT_ARRAY_EXT", 0x87E8},
{"GL_VARIANT_ARRAY_POINTER_EXT", 0x87E9},
{"GL_VARIANT_ARRAY_STRIDE_EXT", 0x87E6},
Expand Down
8 changes: 8 additions & 0 deletions Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9899,6 +9899,14 @@ void Context::textureFoveationParameters(TextureID texturePacked,
texture->setFocalPoint(layer, focalPoint, focalX, focalY, gainX, gainY, foveaArea);
}

void Context::bindMetalRasterizationRateMap(GLuint renderbufferHandle, GLMTLRasterizationRateMapANGLE map)
{
Renderbuffer *renderbuffer = getRenderbuffer({renderbufferHandle});
rx::RenderbufferImpl *renderbufferImpl = renderbuffer ? renderbuffer->getImplementation() : nullptr;
ANGLE_CONTEXT_TRY(mImplementation->bindMetalRasterizationRateMap(this, renderbufferImpl, map));
getMutablePrivateState()->setVariableRasterizationRateMap(map);
}

// ErrorSet implementation.
ErrorSet::ErrorSet(Debug *debug,
const angle::FrontendFeatures &frontendFeatures,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@
void invalidateTexture(TextureType targetPacked); \
/* GL_ANGLE_texture_multisample */ \
/* GL_ANGLE_texture_rectangle */ \
/* GL_ANGLE_variable_rasterization_rate_metal */ \
void bindMetalRasterizationRateMap(GLuint renderbuffer, GLMTLRasterizationRateMapANGLE map); \
/* GL_ANGLE_vulkan_image */ \
void acquireTextures(GLuint numTextures, const TextureID *texturesPacked, \
const GLenum *layouts); \
Expand Down
30 changes: 30 additions & 0 deletions Source/ThirdParty/ANGLE/src/libANGLE/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ PrivateState::PrivateState(const EGLenum clientType,
mLogicOp(LogicalOperation::Copy),
mPatchVertices(3),
mPixelLocalStorageActivePlanes(0),
mVariableRasterizationRateEnabled(false),
mVariableRasterizationRateMap(nullptr),
mNoSimultaneousConstantColorAndAlphaBlendFunc(false),
mSetBlendIndexedInvoked(false),
mSetBlendFactorsIndexedInvoked(false),
Expand Down Expand Up @@ -1234,6 +1236,26 @@ void PrivateState::setLogicOp(LogicalOperation opcode)
}
}

void PrivateState::setVariableRasterizationRateEnabled(bool enabled)
{
if (mVariableRasterizationRateEnabled != enabled)
{
mVariableRasterizationRateEnabled = enabled;
mDirtyBits.set(state::DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(state::EXTENDED_DIRTY_BIT_VARIABLE_RASTERIZATION_RATE);
}
}

void PrivateState::setVariableRasterizationRateMap(GLMTLRasterizationRateMapANGLE map)
{
if (mVariableRasterizationRateMap != map)
{
mVariableRasterizationRateMap = map;
mDirtyBits.set(state::DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(state::EXTENDED_DIRTY_BIT_VARIABLE_RASTERIZATION_RATE);
}
}

void PrivateState::setVertexAttribf(GLuint index, const GLfloat values[4])
{
ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size());
Expand Down Expand Up @@ -1363,6 +1385,9 @@ void PrivateState::setEnableFeature(GLenum feature, bool enabled)
case GL_FETCH_PER_SAMPLE_ARM:
mFetchPerSample = enabled;
return;
case GL_VARIABLE_RASTERIZATION_RATE_ANGLE:
setVariableRasterizationRateEnabled(enabled);
return;
default:
break;
}
Expand Down Expand Up @@ -1527,6 +1552,8 @@ bool PrivateState::getEnableFeature(GLenum feature) const
return mShadingRatePreserveAspectRatio;
case GL_FETCH_PER_SAMPLE_ARM:
return mFetchPerSample;
case GL_VARIABLE_RASTERIZATION_RATE_ANGLE:
return mVariableRasterizationRateEnabled;
}

ASSERT(mClientVersion.major == 1);
Expand Down Expand Up @@ -3404,6 +3431,9 @@ void State::getPointerv(const Context *context, GLenum pname, void **params) con
context->vertexArrayIndex(ParamToVertexArrayType(pname))),
GL_VERTEX_ATTRIB_ARRAY_POINTER, params);
return;
case GL_METAL_RASTERIZATION_RATE_MAP_BINDING_ANGLE:
*params = privateState().getVariableRasterizationRateMap();
break;
default:
UNREACHABLE();
break;
Expand Down
Loading

0 comments on commit 42e8269

Please sign in to comment.