[Feat] (RenderState): implement glMinSampleShading and the GL_SAMPLE_SHADING enable on both backends

This commit is contained in:
2026-08-27 03:35:55 -04:00
parent 07a0408a28
commit acf86d1fb6
16 changed files with 533 additions and 2 deletions
+8
View File
@@ -1025,6 +1025,14 @@ namespace MobileGL::MG_State {
return m_renderState.GetSampleMaskValue();
}
void GLContext::SetMinSampleShadingValue(Float value) {
m_renderState.SetMinSampleShadingValue(value);
}
Float GLContext::GetMinSampleShadingValue() const {
return m_renderState.GetMinSampleShadingValue();
}
void GLContext::SetPixelStoreParam(PixelStoreParam param, Int value) {
m_renderState.SetPixelStoreParam(param, value);
}
+2
View File
@@ -280,6 +280,8 @@ namespace MobileGL {
Bool GetSampleCoverageInvert() const;
void SetSampleMaskValue(Uint32 mask);
Uint32 GetSampleMaskValue() const;
void SetMinSampleShadingValue(Float value);
Float GetMinSampleShadingValue() const;
void SetPixelStoreParam(PixelStoreParam param, Int value);
Int GetPixelStoreParam(PixelStoreParam param) const;
PixelStoreParameters GetPixelStoreParameters(Bool isUnpack) const;
@@ -300,6 +300,7 @@ namespace MobileGL {
SET_CAPABILITY(SampleAlphaToOne, enabled);
SET_CAPABILITY(SampleCoverage, enabled);
SET_CAPABILITY(SampleMask, enabled);
SET_CAPABILITY(SampleShading, enabled);
SET_CAPABILITY(StencilTest, enabled);
SET_CAPABILITY(ProgramPointSize, enabled);
case CapabilityInput::Blend: {
@@ -374,6 +375,7 @@ namespace MobileGL {
RETURN_CAPABILITY(SampleAlphaToOne);
RETURN_CAPABILITY(SampleCoverage);
RETURN_CAPABILITY(SampleMask);
RETURN_CAPABILITY(SampleShading);
RETURN_CAPABILITY(StencilTest);
RETURN_CAPABILITY(ProgramPointSize);
case CapabilityInput::Blend:
@@ -767,6 +769,20 @@ namespace MobileGL {
return m_parameters.SampleMaskValue;
}
void RenderState::SetMinSampleShadingValue(Float value) {
if (m_parameters.MinSampleShadingValue == value) return;
m_parameters.MinSampleShadingValue = value;
// BumpVersions, not just ++m_version: DirectVulkan bakes the fraction into
// VkPipelineMultisampleStateCreateInfo::minSampleShading, so a cached pipeline
// built with the old value must not be reused.
BumpVersions();
}
Float RenderState::GetMinSampleShadingValue() const {
return m_parameters.MinSampleShadingValue;
}
// -------------------- Pixel Store --------------------
void RenderState::SetPixelStoreParam(PixelStoreParam param, Int value) {
#define SET_PIXEL_STORE_PARAM(paramNameHead, paramNameTail, val) \
@@ -278,6 +278,10 @@ namespace MobileGL {
Float SampleCoverageValue = 1.0f;
Bool SampleCoverageInvert = false;
Uint32 SampleMaskValue = 0xffffffffu;
// glMinSampleShading (ARB_sample_shading / GL 4.0 core 14.3.1). The fraction of samples
// that get their own independent shading when GL_SAMPLE_SHADING is enabled; the initial
// value is 0, and the value is clamped to [0, 1] on the way in.
Float MinSampleShadingValue = 0.0f;
Array<StencilFaceState, 2> StencilStates{};
// Cull Face
@@ -326,6 +330,7 @@ namespace MobileGL {
Bool SampleAlphaToOneEnabled = false;
Bool SampleCoverageEnabled = false;
Bool SampleMaskEnabled = false;
Bool SampleShadingEnabled = false;
Bool StencilTestEnabled = false;
Bool ProgramPointSizeEnabled = false;
// glEnable(GL_SCISSOR_TEST) enables the test for EVERY viewport, glEnablei for one
@@ -465,6 +470,9 @@ namespace MobileGL {
Bool GetSampleCoverageInvert() const;
void SetSampleMaskValue(Uint32 mask);
Uint32 GetSampleMaskValue() const;
// glMinSampleShading. `value` is stored as given; the entry point clamps.
void SetMinSampleShadingValue(Float value);
Float GetMinSampleShadingValue() const;
// Pixel Store
void SetPixelStoreParam(PixelStoreParam param, Int value);