Browse Source

[opengl] query GL_MAX_CLIP_DISTANCES instead of hardcoding 8 (#4095)

The GL shader profile hardcoded max_user_clip_distances to 8. Query the
device limit like the Vulkan path already does (it reads
maxClipDistances), so we use what the host actually reports.

Clamp to Maxwell's NumClipDistances (8) since the guest never produces
more than that and the SPIR-V output array is sized for at most 8. So a
host reporting fewer than 8 is respected, and one reporting more can't
overrun anything.

Fixes #3910
https://git.eden-emu.dev/eden-emu/eden/issues/3910

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4095
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: Lizzie <lizzie@eden-emu.dev>
pull/4099/head
BoiledElectricity 2 days ago
committed by crueter
parent
commit
5ebb5b8772
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 1
      src/video_core/renderer_opengl/gl_device.cpp
  2. 7
      src/video_core/renderer_opengl/gl_device.h
  3. 6
      src/video_core/renderer_opengl/gl_shader_cache.cpp

1
src/video_core/renderer_opengl/gl_device.cpp

@ -203,6 +203,7 @@ Device::Device(Core::Frontend::EmuWindow& emu_window) {
max_varyings = GetInteger<u32>(GL_MAX_VARYING_VECTORS); max_varyings = GetInteger<u32>(GL_MAX_VARYING_VECTORS);
max_compute_shared_memory_size = GetInteger<u32>(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE); max_compute_shared_memory_size = GetInteger<u32>(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE);
max_glasm_storage_buffer_blocks = GetInteger<u32>(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS); max_glasm_storage_buffer_blocks = GetInteger<u32>(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS);
max_user_clip_distances = GetInteger<u32>(GL_MAX_CLIP_DISTANCES);
has_warp_intrinsics = GLAD_GL_NV_gpu_shader5 && GLAD_GL_NV_shader_thread_group && has_warp_intrinsics = GLAD_GL_NV_gpu_shader5 && GLAD_GL_NV_shader_thread_group &&
GLAD_GL_NV_shader_thread_shuffle; GLAD_GL_NV_shader_thread_shuffle;
has_shader_ballot = GLAD_GL_ARB_shader_ballot; has_shader_ballot = GLAD_GL_ARB_shader_ballot;

7
src/video_core/renderer_opengl/gl_device.h

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
@ -47,6 +47,10 @@ public:
return max_compute_shared_memory_size; return max_compute_shared_memory_size;
} }
u32 GetMaxUserClipDistances() const {
return max_user_clip_distances;
}
u32 GetMaxGLASMStorageBufferBlocks() const { u32 GetMaxGLASMStorageBufferBlocks() const {
return max_glasm_storage_buffer_blocks; return max_glasm_storage_buffer_blocks;
} }
@ -202,6 +206,7 @@ private:
u32 max_varyings{}; u32 max_varyings{};
u32 max_compute_shared_memory_size{}; u32 max_compute_shared_memory_size{};
u32 max_glasm_storage_buffer_blocks{}; u32 max_glasm_storage_buffer_blocks{};
u32 max_user_clip_distances{};
bool has_warp_intrinsics{}; bool has_warp_intrinsics{};
bool has_shader_ballot{}; bool has_shader_ballot{};

6
src/video_core/renderer_opengl/gl_shader_cache.cpp

@ -238,7 +238,11 @@ ShaderCache::ShaderCache(Tegra::MaxwellDeviceMemoryManager& device_memory_,
.ignore_nan_fp_comparisons = true, .ignore_nan_fp_comparisons = true,
.gl_max_compute_smem_size = device.GetMaxComputeSharedMemorySize(), .gl_max_compute_smem_size = device.GetMaxComputeSharedMemorySize(),
.min_ssbo_alignment = device.GetShaderStorageBufferAlignment(), .min_ssbo_alignment = device.GetShaderStorageBufferAlignment(),
.max_user_clip_distances = 8,
// Use the host limit, but never more than the guest can produce. Maxwell exposes 8 clip
// distances and the SPIR-V output array is sized for at most 8, so clamping here keeps a
// host that reports a different count from under- or over-running that array.
.max_user_clip_distances =
std::min<u32>(device.GetMaxUserClipDistances(), Maxwell::Regs::NumClipDistances),
}, },
host_info{ host_info{
.support_float64 = true, .support_float64 = true,

Loading…
Cancel
Save