Merge pull request #21717 from hrydgard/assorted-changes

Small refactor broken out of the viewport rework
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-05-21 17:00:10 +02:00
commit db604bfc04
13 files changed
+64 -34

No files matched your search

+4 -3
View File
@@ -316,14 +316,15 @@ D3D11DrawContext::D3D11DrawContext(ComPtr<ID3D11Device> device, ComPtr<ID3D11Dev
caps_.maxTextureSize = 2048;
break;
}
caps_.maxClipPlanes = 8;
// Seems like a fair approximation...
caps_.dualSourceBlend = featureLevel_ >= D3D_FEATURE_LEVEL_10_0;
caps_.depthClampSupported = featureLevel_ >= D3D_FEATURE_LEVEL_10_0;
// SV_ClipDistance# seems to be 10+.
caps_.clipDistanceSupported = featureLevel_ >= D3D_FEATURE_LEVEL_10_0;
caps_.cullDistanceSupported = featureLevel_ >= D3D_FEATURE_LEVEL_10_0;
if (featureLevel_ >= D3D_FEATURE_LEVEL_10_0) {
caps_.maxClipDistances = 8;
caps_.maxCullDistances = 8;
}
caps_.depthRangeMinusOneToOne = false;
caps_.framebufferBlitSupported = false;
+29 -5
View File
@@ -208,9 +208,6 @@ bool CheckGLExtensions() {
gl_extensions.model[sizeof(gl_extensions.model) - 1] = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_extensions.maxTextureSize);
#ifndef USING_GLES2
glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_extensions.maxClipPlanes);
#endif
// Start by assuming we're at 2.0.
int parsed[2] = {2, 0};
@@ -239,7 +236,6 @@ bool CheckGLExtensions() {
}
}
if (!gl_extensions.IsGLES) { // For desktop GL
gl_extensions.ver[0] = parsed[0];
gl_extensions.ver[1] = parsed[1];
@@ -582,13 +578,41 @@ bool CheckGLExtensions() {
}
}
// Force off clip for a cmomon buggy Samsung version.
// Force off clip for a common buggy Samsung version.
if (!strcmp(versionStr, "OpenGL ES 3.2 ANGLE git hash: aa8f94c52952")) {
// Maybe could use bugs, but for now let's just force it back off.
// Seeing errors that gl_ClipDistance is undefined.
gl_extensions.EXT_clip_cull_distance = false;
}
bool clipDistanceSupported = false;
bool cullDistanceSupported = false;
if (gl_extensions.IsGLES) {
clipDistanceSupported = gl_extensions.EXT_clip_cull_distance || gl_extensions.APPLE_clip_distance;
cullDistanceSupported = gl_extensions.EXT_clip_cull_distance;
} else {
clipDistanceSupported = gl_extensions.VersionGEThan(3, 0);
cullDistanceSupported = gl_extensions.ARB_cull_distance;
}
gl_extensions.maxClipDistances = 0;
gl_extensions.maxCullDistances = 0;
#if PPSSPP_PLATFORM(IOS)
if (clipDistanceSupported) {
glGetIntegerv(GL_MAX_CLIP_DISTANCES_APPLE, &gl_extensions.maxClipDistances);
}
// Apple doesn't support cull distances.
#else
if (clipDistanceSupported) {
glGetIntegerv(GL_MAX_CLIP_DISTANCES_EXT, &gl_extensions.maxClipDistances);
}
if (cullDistanceSupported) {
glGetIntegerv(GL_MAX_CULL_DISTANCES_EXT, &gl_extensions.maxCullDistances);
}
#endif
// Check the old query API. It doesn't seem to be very reliable (can miss stuff).
GLint numCompressedFormats = 0;
glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCompressedFormats);
+3 -1
View File
@@ -45,7 +45,8 @@ struct GLExtensions {
bool GLES3; // true if the full OpenGL ES 3.0 is supported
int maxTextureSize;
int maxClipPlanes;
int maxClipDistances;
int maxCullDistances;
// OES
bool OES_depth24;
@@ -73,6 +74,7 @@ struct GLExtensions {
bool ARB_texture_float;
bool ARB_draw_instanced;
bool ARB_buffer_storage;
bool ARB_clip_distance;
bool ARB_cull_distance;
bool ARB_depth_clamp;
bool ARB_uniform_buffer_object;
+3 -8
View File
@@ -579,7 +579,6 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT
}
caps_.maxTextureSize = gl_extensions.maxTextureSize;
caps_.maxClipPlanes = gl_extensions.IsGLES ? 0 : gl_extensions.maxClipPlanes;
caps_.coordConvention = CoordConvention::OpenGL;
caps_.setMaxFrameLatencySupported = true;
caps_.dualSourceBlend = gl_extensions.ARB_blend_func_extended || gl_extensions.EXT_blend_func_extended;
@@ -592,13 +591,9 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT
caps_.blendMinMaxSupported = gl_extensions.EXT_blend_minmax;
caps_.multiSampleLevelsMask = 1; // More could be supported with some work.
if (gl_extensions.IsGLES) {
caps_.clipDistanceSupported = gl_extensions.EXT_clip_cull_distance || gl_extensions.APPLE_clip_distance;
caps_.cullDistanceSupported = gl_extensions.EXT_clip_cull_distance;
} else {
caps_.clipDistanceSupported = gl_extensions.VersionGEThan(3, 0);
caps_.cullDistanceSupported = gl_extensions.ARB_cull_distance;
}
caps_.maxClipDistances = gl_extensions.maxClipDistances;
caps_.maxCullDistances = gl_extensions.maxCullDistances;
caps_.textureNPOTFullySupported =
(!gl_extensions.IsGLES && gl_extensions.VersionGEThan(2, 0, 0)) ||
gl_extensions.IsCoreContext || gl_extensions.GLES3 ||
+6 -5
View File
@@ -924,11 +924,12 @@ VKContext::VKContext(VulkanContext *vulkan, bool useRenderThread)
caps_.depthClampSupported = vulkan->GetDeviceFeatures().enabled.standard.depthClamp != 0;
caps_.maxTextureSize = vulkan->GetPhysicalDeviceProperties().properties.limits.maxImageDimension2D;
caps_.maxClipPlanes = vulkan->GetPhysicalDeviceProperties().properties.limits.maxClipDistances;
// Comment out these two to test geometry shader culling on any geometry shader-supporting hardware.
caps_.clipDistanceSupported = vulkan->GetDeviceFeatures().enabled.standard.shaderClipDistance != 0;
caps_.cullDistanceSupported = vulkan->GetDeviceFeatures().enabled.standard.shaderCullDistance != 0;
if (vulkan->GetDeviceFeatures().enabled.standard.shaderClipDistance) {
caps_.maxClipDistances = vulkan->GetPhysicalDeviceProperties().properties.limits.maxClipDistances;
}
if (vulkan->GetDeviceFeatures().enabled.standard.shaderCullDistance) {
caps_.maxCullDistances = vulkan->GetPhysicalDeviceProperties().properties.limits.maxCullDistances;
}
caps_.framebufferBlitSupported = true;
caps_.framebufferCopySupported = true;
+5 -3
View File
@@ -595,12 +595,16 @@ struct DeviceCaps {
uint32_t deviceID; // use caution!
uint32_t maxTextureSize; // largest side.
uint32_t maxClipPlanes;
// You can check these for > 0 to see if they're supported.
uint32_t maxClipDistances;
uint32_t maxCullDistances;
CoordConvention coordConvention;
DataFormat preferredDepthBufferFormat;
DataFormat preferredShadowMapFormatLow;
DataFormat preferredShadowMapFormatHigh;
bool anisoSupported;
bool depthRangeMinusOneToOne; // OpenGL style depth
bool geometryShaderSupported;
@@ -608,8 +612,6 @@ struct DeviceCaps {
bool dualSourceBlend;
bool logicOpSupported;
bool depthClampSupported;
bool clipDistanceSupported;
bool cullDistanceSupported;
bool framebufferCopySupported;
bool framebufferBlitSupported;
bool framebufferDepthCopySupported;
+3
View File
@@ -558,6 +558,9 @@ InfoItem::InfoItem(std::string_view text, std::string_view rightText, LayoutPara
// We set the colors later once we have a UIContext.
}
InfoItem::InfoItem(std::string_view text, int rightValue, LayoutParams *layoutParams)
: InfoItem(text, std::to_string(rightValue), layoutParams) {}
void InfoItem::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const {
float w1, h1, w2, h2;
dc.MeasureText(dc.GetTheme().uiFont, 1.0f, 1.0f, text_, &w1, &h1, 0);
+1
View File
@@ -839,6 +839,7 @@ protected:
class InfoItem : public Item {
public:
InfoItem(std::string_view text, std::string_view rightText, LayoutParams *layoutParams = nullptr);
InfoItem(std::string_view text, int rightValue, LayoutParams *layoutParams = nullptr);
void Draw(UIContext &dc) override;
std::string DescribeText() const override;