mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 12:18:30 +09:00
[Fix] (MG_Backend/DirectVulkan+DirectGLES, MG_State): cap per-stage GL_MAX_TEXTURE_IMAGE_UNITS to 32
Adreno/Qualcomm report a huge maxPerStageDescriptorSampledImages, and the per-stage texture-unit limits were clamped only to the combined array capacity (TextureState::MAX_TEXTURE_IMAGE_UNITS = 192). glGetIntegerv thus advertised 192 for GL_MAX_TEXTURE_IMAGE_UNITS, but host code treats it as an array bound: Minecraft's Blaze3D GlStateManager.TEXTURES[] holds 128 entries and Iris iterates [0, GL_MAX_TEXTURE_IMAGE_UNITS) over it in CompositeRenderer.renderAll, throwing ArrayIndexOutOfBoundsException: Index 128 out of bounds for length 128. Introduce MAX_PER_STAGE_TEXTURE_IMAGE_UNITS = 32 (desktop-driver value) and clamp the per-stage sampler limits to it in both backends (DirectGLES previously did not clamp at all), keeping the combined limit at the array capacity. Update SanityTest.
This commit is contained in:
@@ -311,9 +311,13 @@ TEST(DirectVulkanSanity, ClampsAdvertisedTextureAndDrawBufferLimitsToFrontendSta
|
||||
backend.ApplyVulkanCapabilitiesForTesting(highCaps);
|
||||
|
||||
const auto& highParams = backend.GetDynamicParameters();
|
||||
EXPECT_EQ(highParams.MaxTextureImageUnits, MG_State::GLState::TextureState::MAX_TEXTURE_IMAGE_UNITS);
|
||||
EXPECT_EQ(highParams.MaxVertexTextureImageUnits, MG_State::GLState::TextureState::MAX_TEXTURE_IMAGE_UNITS);
|
||||
EXPECT_EQ(highParams.MaxComputeTextureImageUnits, MG_State::GLState::TextureState::MAX_TEXTURE_IMAGE_UNITS);
|
||||
// Per-stage sampler limits clamp to the desktop-conventional per-stage cap (kept well under
|
||||
// Blaze3D's 128-entry TEXTURES[] so Iris' unbind loop cannot index out of bounds); the combined
|
||||
// limit clamps to the full texture-unit array capacity.
|
||||
EXPECT_EQ(highParams.MaxTextureImageUnits, MG_State::GLState::TextureState::MAX_PER_STAGE_TEXTURE_IMAGE_UNITS);
|
||||
EXPECT_EQ(highParams.MaxVertexTextureImageUnits, MG_State::GLState::TextureState::MAX_PER_STAGE_TEXTURE_IMAGE_UNITS);
|
||||
EXPECT_EQ(highParams.MaxComputeTextureImageUnits, MG_State::GLState::TextureState::MAX_PER_STAGE_TEXTURE_IMAGE_UNITS);
|
||||
EXPECT_LE(highParams.MaxTextureImageUnits, 128);
|
||||
EXPECT_EQ(highParams.MaxCombinedTextureImageUnits, MG_State::GLState::TextureState::MAX_TEXTURE_IMAGE_UNITS);
|
||||
EXPECT_EQ(highParams.MaxDrawBuffers, MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS);
|
||||
EXPECT_EQ(highParams.MaxColorAttachments, MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS);
|
||||
|
||||
Reference in New Issue
Block a user