GL: Implement EXT_clip_control

The extension is trivially exposed
if the current context supports it.

* Added packed clip control enums
* Removed unused state query code
* Aligned symbol names with the specs

Bug: angleproject:8066
Change-Id: I9d106f39800658ecc75f4525ee93cb534dc49f9e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4306770
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Alexey Knyazev 2023-03-06 00:00:00 +00:00 коммит произвёл Angle LUCI CQ
Родитель 56259f3010
Коммит 1174582a3d
31 изменённых файлов: 323 добавлений и 110 удалений

Просмотреть файл

@ -4,7 +4,7 @@
"scripts/entry_point_packed_egl_enums.json":
"a72ae855c6b403912103b519139951a1",
"scripts/entry_point_packed_gl_enums.json":
"0b13d76828835cc00f0e5dcbb5e79d72",
"97f26215e343436faaa33345e9ce897b",
"scripts/generate_entry_points.py":
"9938b48a9bbf813dd245e453ff2fc0cc",
"scripts/gl_angle_ext.xml":
@ -16,9 +16,9 @@
"src/common/entry_points_enum_autogen.h":
"62b96cc116f41ab95f09f7db4724b717",
"src/common/frame_capture_utils_autogen.cpp":
"a8c3baf622f23b16100915979ef6fc03",
"abfea27ee4c458bcd0de8c79e17fb70c",
"src/common/frame_capture_utils_autogen.h":
"6b0dbfa52d8c28d674ca0da138697c73",
"20811b817848ba6e23a55f86989c54c6",
"src/libANGLE/Context_gl_1_autogen.h":
"115d224fd28b0bc2b2800354bb57fcf3",
"src/libANGLE/Context_gl_2_autogen.h":
@ -38,7 +38,7 @@
"src/libANGLE/Context_gles_3_2_autogen.h":
"48567dca16fd881dfe6d61fee0e3106f",
"src/libANGLE/Context_gles_ext_autogen.h":
"91e6f5f66952bed889bb970d3fe2686e",
"dc2d16634d655db85f7a5320cb709cfb",
"src/libANGLE/capture/capture_egl_autogen.cpp":
"a5b8f710309de8deab29f2e9d6414cd5",
"src/libANGLE/capture/capture_egl_autogen.h":
@ -56,9 +56,9 @@
"src/libANGLE/capture/capture_gl_3_autogen.h":
"32e061964a2bccfc27dc95eb1a69558e",
"src/libANGLE/capture/capture_gl_4_autogen.cpp":
"8b631331ce316c6d5893f32f4297703e",
"91733fd9c3e87cd7a7867cf006b9ed8d",
"src/libANGLE/capture/capture_gl_4_autogen.h":
"985366fe10b1e96e557a84d26769a042",
"82443f9fe7783ae63128e6785b466f61",
"src/libANGLE/capture/capture_gles_1_0_autogen.cpp":
"d203de86be595ac05578ef01b362380a",
"src/libANGLE/capture/capture_gles_1_0_autogen.h":
@ -80,9 +80,9 @@
"src/libANGLE/capture/capture_gles_3_2_autogen.h":
"74ed7366af3a46c0661397cfa29ec6fc",
"src/libANGLE/capture/capture_gles_ext_autogen.cpp":
"9faf9e5fdf2364d22ce5e76c9548dcfa",
"455f323fedcaf57eb025bb41a58fad45",
"src/libANGLE/capture/capture_gles_ext_autogen.h":
"2068d18598966d72a5c42bc392c26a25",
"7c5cf679ac9b781a7badd027c454f129",
"src/libANGLE/validationCL_autogen.h":
"0022d0cdb6a9e2ef4a59b71164f62333",
"src/libANGLE/validationEGL_autogen.h":
@ -98,7 +98,7 @@
"src/libANGLE/validationES3_autogen.h":
"ffffaca63434b2b419614ddb25a57149",
"src/libANGLE/validationESEXT_autogen.h":
"29b640761e12a2c175d8021609bfacd1",
"2193057f9c887e53e4fb691715ff700d",
"src/libANGLE/validationGL1_autogen.h":
"a247dddc40418180d4b2dbefeb75f233",
"src/libANGLE/validationGL2_autogen.h":
@ -106,7 +106,7 @@
"src/libANGLE/validationGL3_autogen.h":
"d44457c3b3bc40fc7db904a4bb433966",
"src/libANGLE/validationGL4_autogen.h":
"cd7ad03880470cae2fe26fc9b7902ce9",
"bf8566233cb2da63fbc2afbb4ffc4834",
"src/libEGL/libEGL_autogen.cpp":
"3bf53ca292b19b0e21b9201740d52b69",
"src/libEGL/libEGL_autogen.def":
@ -144,7 +144,7 @@
"src/libGLESv2/entry_points_gl_3_autogen.h":
"88fcf08e2c1aa73819067f28c0fd1eba",
"src/libGLESv2/entry_points_gl_4_autogen.cpp":
"43a3bce4610a489e8c9c2fa9f62f1a65",
"b3b13240cfb265a71d73897b580a03c6",
"src/libGLESv2/entry_points_gl_4_autogen.h":
"ec1171de9a494598d53bce149ba7b26d",
"src/libGLESv2/entry_points_gles_1_0_autogen.cpp":
@ -168,7 +168,7 @@
"src/libGLESv2/entry_points_gles_3_2_autogen.h":
"647f932a299cdb4726b60bbba059f0d2",
"src/libGLESv2/entry_points_gles_ext_autogen.cpp":
"b98f287d00380e83d867a34785719711",
"57893d3bdf57c9f2b8545abeaf766b3e",
"src/libGLESv2/entry_points_gles_ext_autogen.h":
"43349ba32ad0c5ff56375aa4c200552d",
"src/libGLESv2/libGLESv2_autogen.cpp":

Просмотреть файл

@ -8,9 +8,9 @@
"src/common/PackedEGLEnums_autogen.h":
"7d87e160a0c8ea26cb0c835729f7b586",
"src/common/PackedGLEnums_autogen.cpp":
"be6ac84898dd9b89722143d4f49fac35",
"b09276a0be48ae3b852fd485e5149b2c",
"src/common/PackedGLEnums_autogen.h":
"81e65899f1a783d0be372b54fadb07be",
"9c3d6e6b02b6bf93bf71f1fb66c6c7e1",
"src/common/gen_packed_gl_enums.py":
"3334498103ee8b13fe721519dd8e0742",
"src/common/packed_cl_enums.json":
@ -18,5 +18,5 @@
"src/common/packed_egl_enums.json":
"5797db941e95e418d69527eb4e4af900",
"src/common/packed_gl_enums.json":
"e7e61b5e524b25017e4b0d0a6357941a"
"3cd23d1f6cf68be1f88aab56402699c4"
}

Просмотреть файл

@ -151,6 +151,10 @@
"glClientWaitSync": {
"sync": "SyncID"
},
"glClipControl": {
"origin": "ClipOrigin",
"depth": "ClipDepthMode"
},
"glColorPointer": {
"type": "VertexAttribType"
},

Просмотреть файл

@ -384,6 +384,96 @@ std::ostream &operator<<(std::ostream &os, ClientVertexArrayType value)
return os;
}
template <>
ClipDepthMode FromGLenum<ClipDepthMode>(GLenum from)
{
switch (from)
{
case GL_NEGATIVE_ONE_TO_ONE_EXT:
return ClipDepthMode::NegativeOneToOne;
case GL_ZERO_TO_ONE_EXT:
return ClipDepthMode::ZeroToOne;
default:
return ClipDepthMode::InvalidEnum;
}
}
GLenum ToGLenum(ClipDepthMode from)
{
switch (from)
{
case ClipDepthMode::NegativeOneToOne:
return GL_NEGATIVE_ONE_TO_ONE_EXT;
case ClipDepthMode::ZeroToOne:
return GL_ZERO_TO_ONE_EXT;
default:
UNREACHABLE();
return 0;
}
}
std::ostream &operator<<(std::ostream &os, ClipDepthMode value)
{
switch (value)
{
case ClipDepthMode::NegativeOneToOne:
os << "GL_NEGATIVE_ONE_TO_ONE_EXT";
break;
case ClipDepthMode::ZeroToOne:
os << "GL_ZERO_TO_ONE_EXT";
break;
default:
os << "GL_INVALID_ENUM";
break;
}
return os;
}
template <>
ClipOrigin FromGLenum<ClipOrigin>(GLenum from)
{
switch (from)
{
case GL_LOWER_LEFT_EXT:
return ClipOrigin::LowerLeft;
case GL_UPPER_LEFT_EXT:
return ClipOrigin::UpperLeft;
default:
return ClipOrigin::InvalidEnum;
}
}
GLenum ToGLenum(ClipOrigin from)
{
switch (from)
{
case ClipOrigin::LowerLeft:
return GL_LOWER_LEFT_EXT;
case ClipOrigin::UpperLeft:
return GL_UPPER_LEFT_EXT;
default:
UNREACHABLE();
return 0;
}
}
std::ostream &operator<<(std::ostream &os, ClipOrigin value)
{
switch (value)
{
case ClipOrigin::LowerLeft:
os << "GL_LOWER_LEFT_EXT";
break;
case ClipOrigin::UpperLeft:
os << "GL_UPPER_LEFT_EXT";
break;
default:
os << "GL_INVALID_ENUM";
break;
}
return os;
}
template <>
CullFaceMode FromGLenum<CullFaceMode>(GLenum from)
{

Просмотреть файл

@ -106,6 +106,34 @@ ClientVertexArrayType FromGLenum<ClientVertexArrayType>(GLenum from);
GLenum ToGLenum(ClientVertexArrayType from);
std::ostream &operator<<(std::ostream &os, ClientVertexArrayType value);
enum class ClipDepthMode : uint8_t
{
NegativeOneToOne = 0,
ZeroToOne = 1,
InvalidEnum = 2,
EnumCount = 2,
};
template <>
ClipDepthMode FromGLenum<ClipDepthMode>(GLenum from);
GLenum ToGLenum(ClipDepthMode from);
std::ostream &operator<<(std::ostream &os, ClipDepthMode value);
enum class ClipOrigin : uint8_t
{
LowerLeft = 0,
UpperLeft = 1,
InvalidEnum = 2,
EnumCount = 2,
};
template <>
ClipOrigin FromGLenum<ClipOrigin>(GLenum from);
GLenum ToGLenum(ClipOrigin from);
std::ostream &operator<<(std::ostream &os, ClipOrigin value);
enum class CullFaceMode : uint8_t
{
Back = 0,

Просмотреть файл

@ -48,6 +48,13 @@ void WriteParamCaptureReplay(std::ostream &os, const CallCapture &call, const Pa
WriteParamValueReplay<ParamType::TClientVertexArrayType>(
os, call, param.value.ClientVertexArrayTypeVal);
break;
case ParamType::TClipDepthMode:
WriteParamValueReplay<ParamType::TClipDepthMode>(os, call,
param.value.ClipDepthModeVal);
break;
case ParamType::TClipOrigin:
WriteParamValueReplay<ParamType::TClipOrigin>(os, call, param.value.ClipOriginVal);
break;
case ParamType::TCompositorTiming:
WriteParamValueReplay<ParamType::TCompositorTiming>(os, call,
param.value.CompositorTimingVal);
@ -668,6 +675,10 @@ const char *ParamTypeToString(ParamType paramType)
return "GLenum";
case ParamType::TClientVertexArrayType:
return "GLenum";
case ParamType::TClipDepthMode:
return "GLenum";
case ParamType::TClipOrigin:
return "GLenum";
case ParamType::TCompositorTiming:
return "GLenum";
case ParamType::TContextID:

Просмотреть файл

@ -25,6 +25,8 @@ enum class ParamType
TBufferIDPointer,
TBufferUsage,
TClientVertexArrayType,
TClipDepthMode,
TClipOrigin,
TCompositorTiming,
TContextID,
TCullFaceMode,
@ -190,7 +192,7 @@ enum class ParamType
TvoidPointerPointer,
};
constexpr uint32_t kParamTypeCount = 171;
constexpr uint32_t kParamTypeCount = 173;
union ParamValue
{
@ -202,6 +204,8 @@ union ParamValue
gl::BufferID *BufferIDPointerVal;
gl::BufferUsage BufferUsageVal;
gl::ClientVertexArrayType ClientVertexArrayTypeVal;
gl::ClipDepthMode ClipDepthModeVal;
gl::ClipOrigin ClipOriginVal;
egl::CompositorTiming CompositorTimingVal;
gl::ContextID ContextIDVal;
gl::CullFaceMode CullFaceModeVal;
@ -425,6 +429,19 @@ GetParamVal<ParamType::TClientVertexArrayType, gl::ClientVertexArrayType>(const
return value.ClientVertexArrayTypeVal;
}
template <>
inline gl::ClipDepthMode GetParamVal<ParamType::TClipDepthMode, gl::ClipDepthMode>(
const ParamValue &value)
{
return value.ClipDepthModeVal;
}
template <>
inline gl::ClipOrigin GetParamVal<ParamType::TClipOrigin, gl::ClipOrigin>(const ParamValue &value)
{
return value.ClipOriginVal;
}
template <>
inline egl::CompositorTiming GetParamVal<ParamType::TCompositorTiming, egl::CompositorTiming>(
const ParamValue &value)
@ -1523,6 +1540,10 @@ T AccessParamValue(ParamType paramType, const ParamValue &value)
return GetParamVal<ParamType::TBufferUsage, T>(value);
case ParamType::TClientVertexArrayType:
return GetParamVal<ParamType::TClientVertexArrayType, T>(value);
case ParamType::TClipDepthMode:
return GetParamVal<ParamType::TClipDepthMode, T>(value);
case ParamType::TClipOrigin:
return GetParamVal<ParamType::TClipOrigin, T>(value);
case ParamType::TCompositorTiming:
return GetParamVal<ParamType::TCompositorTiming, T>(value);
case ParamType::TContextID:
@ -1908,6 +1929,18 @@ inline void SetParamVal<ParamType::TClientVertexArrayType>(gl::ClientVertexArray
valueOut->ClientVertexArrayTypeVal = valueIn;
}
template <>
inline void SetParamVal<ParamType::TClipDepthMode>(gl::ClipDepthMode valueIn, ParamValue *valueOut)
{
valueOut->ClipDepthModeVal = valueIn;
}
template <>
inline void SetParamVal<ParamType::TClipOrigin>(gl::ClipOrigin valueIn, ParamValue *valueOut)
{
valueOut->ClipOriginVal = valueIn;
}
template <>
inline void SetParamVal<ParamType::TCompositorTiming>(egl::CompositorTiming valueIn,
ParamValue *valueOut)
@ -2987,6 +3020,12 @@ void InitParamValue(ParamType paramType, T valueIn, ParamValue *valueOut)
case ParamType::TClientVertexArrayType:
SetParamVal<ParamType::TClientVertexArrayType>(valueIn, valueOut);
break;
case ParamType::TClipDepthMode:
SetParamVal<ParamType::TClipDepthMode>(valueIn, valueOut);
break;
case ParamType::TClipOrigin:
SetParamVal<ParamType::TClipOrigin>(valueIn, valueOut);
break;
case ParamType::TCompositorTiming:
SetParamVal<ParamType::TCompositorTiming>(valueIn, valueOut);
break;

Просмотреть файл

@ -46,6 +46,16 @@
"TextureCoord": "GL_TEXTURE_COORD_ARRAY",
"Vertex": "GL_VERTEX_ARRAY"
},
"ClipOrigin":
{
"LowerLeft": "GL_LOWER_LEFT_EXT",
"UpperLeft": "GL_UPPER_LEFT_EXT"
},
"ClipDepthMode":
{
"NegativeOneToOne": "GL_NEGATIVE_ONE_TO_ONE_EXT",
"ZeroToOne": "GL_ZERO_TO_ONE_EXT"
},
"CullFaceMode":
{
"Back": "GL_BACK",

Просмотреть файл

@ -2256,14 +2256,6 @@ void Context::getIntegervImpl(GLenum pname, GLint *params) const
*params = mState.mCaps.textureBufferOffsetAlignment;
break;
// GL_EXT_clip_control
case GL_CLIP_ORIGIN_EXT:
*params = mState.mClipControlOrigin;
break;
case GL_CLIP_DEPTH_MODE_EXT:
*params = mState.mClipControlDepth;
break;
// ANGLE_shader_pixel_local_storage
case GL_MAX_PIXEL_LOCAL_STORAGE_PLANES_ANGLE:
*params = mState.mCaps.maxPixelLocalStoragePlanes;
@ -5926,9 +5918,9 @@ void Context::depthRangef(GLfloat zNear, GLfloat zFar)
mState.setDepthRange(clamp01(zNear), clamp01(zFar));
}
void Context::clipControl(GLenum origin, GLenum depth)
void Context::clipControl(ClipOrigin originPacked, ClipDepthMode depthPacked)
{
mState.setClipControl(origin, depth);
mState.setClipControl(originPacked, depthPacked);
}
void Context::disable(GLenum cap)

Просмотреть файл

@ -105,7 +105,7 @@
void bufferStorage(BufferBinding targetPacked, GLsizeiptr size, const void *data, \
GLbitfield flags); \
/* GL_EXT_clip_control */ \
void clipControl(GLenum origin, GLenum depth); \
void clipControl(ClipOrigin originPacked, ClipDepthMode depthPacked); \
/* GL_EXT_clip_cull_distance */ \
/* GL_EXT_color_buffer_float */ \
/* GL_EXT_color_buffer_half_float */ \

Просмотреть файл

@ -481,8 +481,8 @@ void State::initialize(Context *context)
mNearZ = 0.0f;
mFarZ = 1.0f;
mClipControlOrigin = GL_LOWER_LEFT_EXT;
mClipControlDepth = GL_NEGATIVE_ONE_TO_ONE_EXT;
mClipOrigin = ClipOrigin::LowerLeft;
mClipDepthMode = ClipDepthMode::NegativeOneToOne;
mActiveSampler = 0;
@ -895,19 +895,19 @@ void State::setDepthRange(float zNear, float zFar)
}
}
void State::setClipControl(GLenum origin, GLenum depth)
void State::setClipControl(ClipOrigin origin, ClipDepthMode depth)
{
bool updated = false;
if (mClipControlOrigin != origin)
if (mClipOrigin != origin)
{
mClipControlOrigin = origin;
updated = true;
mClipOrigin = origin;
updated = true;
}
if (mClipControlDepth != depth)
if (mClipDepthMode != depth)
{
mClipControlDepth = depth;
updated = true;
mClipDepthMode = depth;
updated = true;
}
if (updated)
@ -2535,16 +2535,6 @@ void State::getBooleanv(GLenum pname, GLboolean *params) const
case GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED:
*params = isPrimitiveRestartEnabled() && getExtensions().tessellationShaderEXT;
break;
// 2.2.2 Data Conversions For State Query Commands, in GLES 3.2 spec.
// If a command returning boolean data is called, such as GetBooleanv, a floating-point or
// integer value converts to FALSE if and only if it is zero. Otherwise it converts to TRUE.
// GL_EXT_clip_control
case GL_CLIP_ORIGIN_EXT:
*params = GL_TRUE;
break;
case GL_CLIP_DEPTH_MODE_EXT:
*params = GL_TRUE;
break;
case GL_ROBUST_FRAGMENT_SHADER_OUTPUT_ANGLE:
*params = mExtensions.robustFragmentShaderOutputANGLE ? GL_TRUE : GL_FALSE;
break;
@ -2691,15 +2681,6 @@ void State::getFloatv(GLenum pname, GLfloat *params) const
case GL_MIN_SAMPLE_SHADING_VALUE:
*params = mMinSampleShading;
break;
// 2.2.2 Data Conversions For State Query Commands, in GLES 3.2 spec.
// If a command returning floating-point data is called, such as GetFloatv, ... An integer
// value is coerced to floating-point.
case GL_CLIP_ORIGIN_EXT:
*params = static_cast<float>(mClipControlOrigin);
break;
case GL_CLIP_DEPTH_MODE_EXT:
*params = static_cast<float>(mClipControlDepth);
break;
// GL_ARM_shader_framebuffer_fetch
case GL_FETCH_PER_SAMPLE_ARM:
*params = mFetchPerSample ? 1.0f : 0.0f;
@ -3176,10 +3157,10 @@ angle::Result State::getIntegerv(const Context *context, GLenum pname, GLint *pa
// GL_EXT_clip_control
case GL_CLIP_ORIGIN_EXT:
*params = mClipControlOrigin;
*params = ToGLenum(mClipOrigin);
break;
case GL_CLIP_DEPTH_MODE_EXT:
*params = mClipControlDepth;
*params = ToGLenum(mClipDepthMode);
break;
// GL_QCOM_shading_rate

Просмотреть файл

@ -181,14 +181,11 @@ class State : angle::NonCopyable
float getNearPlane() const { return mNearZ; }
float getFarPlane() const { return mFarZ; }
// Clip control extension
void setClipControl(GLenum origin, GLenum depth);
bool isClipControlDepthZeroToOne() const { return mClipControlDepth == GL_ZERO_TO_ONE_EXT; }
gl::ClipSpaceOrigin getClipSpaceOrigin() const
{
return mClipControlOrigin == GL_UPPER_LEFT_EXT ? ClipSpaceOrigin::UpperLeft
: ClipSpaceOrigin::LowerLeft;
}
// EXT_clip_control
void setClipControl(ClipOrigin origin, ClipDepthMode depth);
ClipOrigin getClipOrigin() const { return mClipOrigin; }
ClipDepthMode getClipDepthMode() const { return mClipDepthMode; }
bool isClipDepthModeZeroToOne() const { return mClipDepthMode == ClipDepthMode::ZeroToOne; }
// Blend state manipulation
bool isBlendEnabled() const { return mBlendStateExt.getEnabledMask().test(0); }
@ -1101,8 +1098,8 @@ class State : angle::NonCopyable
float mNearZ;
float mFarZ;
GLenum mClipControlOrigin;
GLenum mClipControlDepth;
ClipOrigin mClipOrigin;
ClipDepthMode mClipDepthMode;
Framebuffer *mReadFramebuffer;
Framebuffer *mDrawFramebuffer;

Просмотреть файл

@ -130,12 +130,6 @@ bool operator!=(const RectangleImpl<T> &a, const RectangleImpl<T> &b);
using Rectangle = RectangleImpl<int>;
enum class ClipSpaceOrigin
{
LowerLeft = 0,
UpperLeft = 1
};
// Calculate the intersection of two rectangles. Returns false if the intersection is empty.
[[nodiscard]] bool ClipRectangle(const Rectangle &source,
const Rectangle &clip,

Просмотреть файл

@ -3060,12 +3060,15 @@ CallCapture CaptureClearNamedFramebufferuiv(const State &glState,
return CallCapture(angle::EntryPoint::GLClearNamedFramebufferuiv, std::move(paramBuffer));
}
CallCapture CaptureClipControl(const State &glState, bool isCallValid, GLenum origin, GLenum depth)
CallCapture CaptureClipControl(const State &glState,
bool isCallValid,
ClipOrigin originPacked,
ClipDepthMode depthPacked)
{
ParamBuffer paramBuffer;
paramBuffer.addEnumParam("origin", BigGLEnum::ClipControlOrigin, ParamType::TGLenum, origin);
paramBuffer.addEnumParam("depth", BigGLEnum::ClipControlDepth, ParamType::TGLenum, depth);
paramBuffer.addValueParam("originPacked", ParamType::TClipOrigin, originPacked);
paramBuffer.addValueParam("depthPacked", ParamType::TClipDepthMode, depthPacked);
return CallCapture(angle::EntryPoint::GLClipControl, std::move(paramBuffer));
}

Просмотреть файл

@ -685,8 +685,8 @@ angle::CallCapture CaptureClearNamedFramebufferuiv(const State &glState,
const GLuint *value);
angle::CallCapture CaptureClipControl(const State &glState,
bool isCallValid,
GLenum origin,
GLenum depth);
ClipOrigin originPacked,
ClipDepthMode depthPacked);
angle::CallCapture CaptureCompressedTextureSubImage1D(const State &glState,
bool isCallValid,
TextureID texturePacked,

Просмотреть файл

@ -5591,13 +5591,13 @@ CallCapture CaptureBufferStorageEXT(const State &glState,
CallCapture CaptureClipControlEXT(const State &glState,
bool isCallValid,
GLenum origin,
GLenum depth)
ClipOrigin originPacked,
ClipDepthMode depthPacked)
{
ParamBuffer paramBuffer;
paramBuffer.addEnumParam("origin", GLESEnum::AllEnums, ParamType::TGLenum, origin);
paramBuffer.addEnumParam("depth", GLESEnum::AllEnums, ParamType::TGLenum, depth);
paramBuffer.addValueParam("originPacked", ParamType::TClipOrigin, originPacked);
paramBuffer.addValueParam("depthPacked", ParamType::TClipDepthMode, depthPacked);
return CallCapture(angle::EntryPoint::GLClipControlEXT, std::move(paramBuffer));
}

Просмотреть файл

@ -1099,8 +1099,8 @@ angle::CallCapture CaptureBufferStorageEXT(const State &glState,
// GL_EXT_clip_control
angle::CallCapture CaptureClipControlEXT(const State &glState,
bool isCallValid,
GLenum origin,
GLenum depth);
ClipOrigin originPacked,
ClipDepthMode depthPacked);
// GL_EXT_clip_cull_distance

Просмотреть файл

@ -841,7 +841,7 @@ void StateManager11::checkPresentPath(const gl::Context *context)
const auto *framebuffer = context->getState().getDrawFramebuffer();
const auto *firstColorAttachment = framebuffer->getFirstColorAttachment();
const bool clipSpaceOriginUpperLeft =
context->getState().getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft;
context->getState().getClipOrigin() == gl::ClipOrigin::UpperLeft;
const bool presentPathFastActive =
UsePresentPathFast(mRenderer, firstColorAttachment) || clipSpaceOriginUpperLeft;
@ -1438,9 +1438,9 @@ void StateManager11::syncViewport(const gl::Context *context)
dxMinViewportBoundsY = 0;
}
bool clipSpaceOriginLowerLeft = glState.getClipSpaceOrigin() == gl::ClipSpaceOrigin::LowerLeft;
bool clipSpaceOriginLowerLeft = glState.getClipOrigin() == gl::ClipOrigin::LowerLeft;
mShaderConstants.onClipControlChange(clipSpaceOriginLowerLeft,
glState.isClipControlDepthZeroToOne());
glState.isClipDepthModeZeroToOne());
const auto &viewport = glState.getViewport();

Просмотреть файл

@ -85,6 +85,8 @@ class [[nodiscard]] ScopedGLState : angle::NonCopyable
}
stateManager->setViewport(viewport);
stateManager->setDepthRange(0.0f, 1.0f);
stateManager->setClipControl(gl::ClipOrigin::LowerLeft,
gl::ClipDepthMode::NegativeOneToOne);
stateManager->setBlendEnabled(false);
stateManager->setColorMask(true, true, true, true);
stateManager->setSampleAlphaToCoverageEnabled(false);

Просмотреть файл

@ -107,6 +107,8 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions,
mViewport(0, 0, 0, 0),
mNear(0.0f),
mFar(1.0f),
mClipOrigin(gl::ClipOrigin::LowerLeft),
mClipDepthMode(gl::ClipDepthMode::NegativeOneToOne),
mBlendColor(0, 0, 0, 0),
mBlendStateExt(rendererCaps.maxDrawBuffers),
mIndependentBlendStates(extensions.drawBuffersIndexedAny()),
@ -1151,6 +1153,23 @@ void StateManagerGL::setDepthRange(float near, float far)
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_RANGE);
}
void StateManagerGL::setClipControl(gl::ClipOrigin origin, gl::ClipDepthMode depth)
{
if (mClipOrigin == origin && mClipDepthMode == depth)
{
return;
}
mClipOrigin = origin;
mClipDepthMode = depth;
ASSERT(mFunctions->clipControl);
mFunctions->clipControl(ToGLenum(mClipOrigin), ToGLenum(mClipDepthMode));
mLocalDirtyBits.set(gl::State::DIRTY_BIT_EXTENDED);
mLocalExtendedDirtyBits.set(gl::State::EXTENDED_DIRTY_BIT_CLIP_CONTROL);
}
void StateManagerGL::setBlendEnabled(bool enabled)
{
const gl::DrawBufferMask mask =
@ -2207,6 +2226,9 @@ angle::Result StateManagerGL::syncState(const gl::Context *context,
{
switch (extendedDirtyBit)
{
case gl::State::EXTENDED_DIRTY_BIT_CLIP_CONTROL:
setClipControl(state.getClipOrigin(), state.getClipDepthMode());
break;
case gl::State::EXTENDED_DIRTY_BIT_CLIP_DISTANCES:
setClipDistancesEnable(state.getEnabledClipDistances());
if (mFeatures.emulateClipDistanceState.enabled)
@ -2226,7 +2248,6 @@ angle::Result StateManagerGL::syncState(const gl::Context *context,
case gl::State::EXTENDED_DIRTY_BIT_SHADER_DERIVATIVE_HINT:
// These hints aren't forwarded to GL yet.
break;
case gl::State::EXTENDED_DIRTY_BIT_CLIP_CONTROL:
case gl::State::EXTENDED_DIRTY_BIT_SHADING_RATE:
// Unimplemented extensions.
break;
@ -2737,6 +2758,20 @@ void StateManagerGL::syncFromNativeContext(const gl::Extensions &extensions,
mLocalDirtyBits.set(gl::State::DIRTY_BIT_VIEWPORT);
}
if (extensions.clipControlEXT)
{
get(GL_CLIP_ORIGIN, &state->clipOrigin);
get(GL_CLIP_DEPTH_MODE, &state->clipDepthMode);
if (mClipOrigin != gl::FromGLenum<gl::ClipOrigin>(state->clipOrigin) ||
mClipDepthMode != gl::FromGLenum<gl::ClipDepthMode>(state->clipDepthMode))
{
mClipOrigin = gl::FromGLenum<gl::ClipOrigin>(state->clipOrigin);
mClipDepthMode = gl::FromGLenum<gl::ClipDepthMode>(state->clipDepthMode);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_EXTENDED);
mLocalExtendedDirtyBits.set(gl::State::EXTENDED_DIRTY_BIT_CLIP_CONTROL);
}
}
get(GL_SCISSOR_TEST, &state->scissorTest);
if (mScissorTestEnabled != static_cast<bool>(state->scissorTest))
{
@ -2923,6 +2958,11 @@ void StateManagerGL::restoreNativeContext(const gl::Extensions &extensions,
ASSERT(mFunctions->getError() == GL_NO_ERROR);
setViewport(state->viewport);
if (extensions.clipControlEXT)
{
setClipControl(gl::FromGLenum<gl::ClipOrigin>(state->clipOrigin),
gl::FromGLenum<gl::ClipDepthMode>(state->clipDepthMode));
}
setScissorTestEnabled(state->scissorTest);
setScissor(state->scissorBox);

Просмотреть файл

@ -78,6 +78,8 @@ struct ExternalContextState
GLenum blendDestAlpha;
GLenum activeTexture;
gl::Rectangle viewport;
GLenum clipOrigin;
GLenum clipDepthMode;
bool scissorTest;
gl::Rectangle scissorBox;
@ -199,6 +201,7 @@ class StateManagerGL final : angle::NonCopyable
void setViewport(const gl::Rectangle &viewport);
void setDepthRange(float near, float far);
void setClipControl(gl::ClipOrigin origin, gl::ClipDepthMode depth);
void setBlendEnabled(bool enabled);
void setBlendEnabledIndexed(const gl::DrawBufferMask blendEnabledMask);
@ -456,6 +459,9 @@ class StateManagerGL final : angle::NonCopyable
float mNear;
float mFar;
gl::ClipOrigin mClipOrigin;
gl::ClipDepthMode mClipDepthMode;
gl::ColorF mBlendColor;
gl::BlendStateExt mBlendStateExt;
const bool mIndependentBlendStates;

Просмотреть файл

@ -1957,6 +1957,10 @@ void GenerateCaps(const FunctionsGL *functions,
functions->isAtLeastGLES(gl::Version(3, 0)) ||
functions->hasGLESExtension("GL_EXT_shadow_samplers");
extensions->clipControlEXT = functions->isAtLeastGL(gl::Version(4, 5)) ||
functions->hasGLExtension("GL_ARB_clip_control") ||
functions->hasGLESExtension("GL_EXT_clip_control");
// GL_APPLE_clip_distance cannot be implemented on top of GL_EXT_clip_cull_distance,
// so require either native support or desktop GL.
extensions->clipDistanceAPPLE = functions->isAtLeastGL(gl::Version(3, 0)) ||

Просмотреть файл

@ -4698,7 +4698,7 @@ void ContextVk::updateViewport(FramebufferVk *framebufferVk,
rotatedRect, nearPlane, farPlane, invertViewport,
// If clip space origin is upper left, viewport origin's y value will be offset by the
// height of the viewport when clip space is mapped into screen space.
mState.getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft,
mState.getClipOrigin() == gl::ClipOrigin::UpperLeft,
// If the surface is rotated 90/270 degrees, use the framebuffer's width instead of the
// height for calculating the final viewport.
isRotatedAspectRatioForDrawFBO() ? fbDimensions.width : fbDimensions.height, &mViewport);
@ -5525,7 +5525,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
{
mGraphicsPipelineDesc->updateDepthClipControl(
&mGraphicsPipelineTransition,
!glState.isClipControlDepthZeroToOne());
!glState.isClipDepthModeZeroToOne());
}
else
{
@ -6623,7 +6623,7 @@ angle::Result ContextVk::handleDirtyGraphicsDriverUniforms(DirtyBits::Iterator *
const uint32_t swapXY = IsRotatedAspectRatio(mCurrentRotationDrawFramebuffer);
const uint32_t enabledClipDistances = mState.getEnabledClipDistances().bits();
const uint32_t transformDepth =
getFeatures().supportsDepthClipControl.enabled ? 0 : !mState.isClipControlDepthZeroToOne();
getFeatures().supportsDepthClipControl.enabled ? 0 : !mState.isClipDepthModeZeroToOne();
static_assert(angle::BitMask<uint32_t>(gl::IMPLEMENTATION_MAX_CLIP_DISTANCES) <=
sh::vk::kDriverUniformsMiscEnabledClipPlanesMask,

Просмотреть файл

@ -269,7 +269,7 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
// isYFlipEnabledForDrawFBO indicates the rendered image is upside-down.
ANGLE_INLINE bool isYFlipEnabledForDrawFBO() const
{
return mState.getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft
return mState.getClipOrigin() == gl::ClipOrigin::UpperLeft
? !isViewportFlipEnabledForDrawFBO()
: isViewportFlipEnabledForDrawFBO();
}

Просмотреть файл

@ -2274,7 +2274,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
bool clipSpaceOriginUpperLeft =
contextVk->getState().getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft;
contextVk->getState().getClipOrigin() == gl::ClipOrigin::UpperLeft;
// Set depth range to clear value. If clearing depth, the vertex shader depth output is clamped
// to this value, thus clearing the depth buffer to the desired clear value.
const float clearDepthValue = params.depthStencilClearValue.depth;
@ -3618,7 +3618,7 @@ angle::Result UtilsVk::unresolve(ContextVk *contextVk,
gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
bool clipSpaceOriginUpperLeft =
contextVk->getState().getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft;
contextVk->getState().getClipOrigin() == gl::ClipOrigin::UpperLeft;
gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, invertViewport, clipSpaceOriginUpperLeft,
completeRenderArea.height, &viewport);
commandBuffer->setViewport(0, 1, &viewport);

Просмотреть файл

@ -2385,16 +2385,22 @@ bool ValidateBufferStorageEXT(const Context *context,
// GL_EXT_clip_control
bool ValidateClipControlEXT(const Context *context,
angle::EntryPoint entryPoint,
GLenum origin,
GLenum depth)
ClipOrigin originPacked,
ClipDepthMode depthPacked)
{
if ((origin != GL_LOWER_LEFT_EXT) && (origin != GL_UPPER_LEFT_EXT))
if (!context->getExtensions().clipControlEXT)
{
context->validationError(entryPoint, GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (originPacked == ClipOrigin::InvalidEnum)
{
context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidOriginEnum);
return false;
}
if ((depth != GL_NEGATIVE_ONE_TO_ONE_EXT) && (depth != GL_ZERO_TO_ONE_EXT))
if (depthPacked == ClipDepthMode::InvalidEnum)
{
context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidDepthEnum);
return false;

Просмотреть файл

@ -1094,8 +1094,8 @@ bool ValidateBufferStorageEXT(const Context *context,
// GL_EXT_clip_control
bool ValidateClipControlEXT(const Context *context,
angle::EntryPoint entryPoint,
GLenum origin,
GLenum depth);
ClipOrigin originPacked,
ClipDepthMode depthPacked);
// GL_EXT_clip_cull_distance

Просмотреть файл

@ -1090,8 +1090,8 @@ bool ValidateClearNamedFramebufferuiv(const Context *context,
bool ValidateClipControl(const Context *context,
angle::EntryPoint entryPoint,
GLenum origin,
GLenum depth)
ClipOrigin originPacked,
ClipDepthMode depthPacked)
{
return true;
}

Просмотреть файл

@ -680,8 +680,8 @@ bool ValidateClearNamedFramebufferuiv(const Context *context,
const GLuint *value);
bool ValidateClipControl(const Context *context,
angle::EntryPoint entryPoint,
GLenum origin,
GLenum depth);
ClipOrigin originPacked,
ClipDepthMode depthPacked);
bool ValidateCompressedTextureSubImage1D(const Context *context,
angle::EntryPoint entryPoint,
TextureID texturePacked,

Просмотреть файл

@ -3380,16 +3380,19 @@ void GL_APIENTRY GL_ClipControl(GLenum origin, GLenum depth)
if (context)
{
ClipOrigin originPacked = PackParam<ClipOrigin>(origin);
ClipDepthMode depthPacked = PackParam<ClipDepthMode>(depth);
SCOPED_SHARE_CONTEXT_LOCK(context);
bool isCallValid =
(context->skipValidation() ||
(ValidatePixelLocalStorageInactive(context, angle::EntryPoint::GLClipControl) &&
ValidateClipControl(context, angle::EntryPoint::GLClipControl, origin, depth)));
ValidateClipControl(context, angle::EntryPoint::GLClipControl, originPacked,
depthPacked)));
if (isCallValid)
{
context->clipControl(origin, depth);
context->clipControl(originPacked, depthPacked);
}
ANGLE_CAPTURE_GL(ClipControl, isCallValid, context, origin, depth);
ANGLE_CAPTURE_GL(ClipControl, isCallValid, context, originPacked, depthPacked);
}
else
{

Просмотреть файл

@ -4970,16 +4970,19 @@ void GL_APIENTRY GL_ClipControlEXT(GLenum origin, GLenum depth)
if (context)
{
ClipOrigin originPacked = PackParam<ClipOrigin>(origin);
ClipDepthMode depthPacked = PackParam<ClipDepthMode>(depth);
SCOPED_SHARE_CONTEXT_LOCK(context);
bool isCallValid =
(context->skipValidation() ||
(ValidatePixelLocalStorageInactive(context, angle::EntryPoint::GLClipControlEXT) &&
ValidateClipControlEXT(context, angle::EntryPoint::GLClipControlEXT, origin, depth)));
ValidateClipControlEXT(context, angle::EntryPoint::GLClipControlEXT, originPacked,
depthPacked)));
if (isCallValid)
{
context->clipControl(origin, depth);
context->clipControl(originPacked, depthPacked);
}
ANGLE_CAPTURE_GL(ClipControlEXT, isCallValid, context, origin, depth);
ANGLE_CAPTURE_GL(ClipControlEXT, isCallValid, context, originPacked, depthPacked);
}
else
{