diff --git a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp index 61b18e6c..df8a6a1a 100644 --- a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp +++ b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp @@ -911,6 +911,16 @@ namespace MobileGL::MG_Impl::GLImpl { case GL_GENERATE_MIPMAP: g_autoGenerateMipmapByTextureId[textureObject->GetExternalIndex()] = (param != GL_FALSE); break; + case GL_DEPTH_STENCIL_TEXTURE_MODE: + if (param != GL_DEPTH_COMPONENT && param != GL_STENCIL_INDEX) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeUnique("MG_Impl/GLImpl", caller, + "Invalid GL_DEPTH_STENCIL_TEXTURE_MODE value.")); + return; + } + textureObject->SetDepthStencilTextureMode(static_cast(param)); + break; default: MG_State::pGLContext->RecordError( ErrorCode::InvalidEnum, @@ -985,7 +995,9 @@ namespace MobileGL::MG_Impl::GLImpl { ErrorCode::InvalidEnum, MakeUnique("MG_Impl/GLImpl", caller, "Invalid GL_DEPTH_STENCIL_TEXTURE_MODE value.")); + return; } + textureObject->SetDepthStencilTextureMode(static_cast(param)); break; default: MG_State::pGLContext->RecordError( @@ -1048,11 +1060,44 @@ namespace MobileGL::MG_Impl::GLImpl { case GL_TEXTURE_MAX_ANISOTROPY_EXT: *params = static_cast(textureObject->GetSamplerObject()->GetMaxAnisotropy()); break; + case GL_DEPTH_STENCIL_TEXTURE_MODE: + *params = static_cast(textureObject->GetDepthStencilTextureMode()); + break; + case GL_TEXTURE_LOD_BIAS: + *params = static_cast(textureObject->GetSamplerObject()->GetLodBias()); + break; + case GL_TEXTURE_SWIZZLE_R: + case GL_TEXTURE_SWIZZLE_G: + case GL_TEXTURE_SWIZZLE_B: + case GL_TEXTURE_SWIZZLE_A: { + const auto component = static_cast(pname - GL_TEXTURE_SWIZZLE_R); + *params = static_cast( + MG_Util::ConvertTextureSwizzleParamToGLEnum(textureObject->GetAllSwizzleParams()[component])); + break; + } + case GL_TEXTURE_TARGET: + *params = static_cast(MG_Util::ConvertTextureTargetToGLEnum(textureObject->GetTarget())); + break; + case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: + *params = GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE; + break; + // Texture views are not implemented; a texture that is not a view reports the defaults + // GL 4.6 core table 23.17 gives (0 layers/levels of offset, and its own extent). + case GL_TEXTURE_VIEW_MIN_LEVEL: + case GL_TEXTURE_VIEW_MIN_LAYER: + *params = 0; + break; + case GL_TEXTURE_VIEW_NUM_LEVELS: + case GL_TEXTURE_VIEW_NUM_LAYERS: + *params = 0; + break; default: MG_State::pGLContext->RecordError( ErrorCode::InvalidEnum, - MakeUnique("MG_Impl/GLImpl", caller, - "pname is not a valid texture parameter.")); + MakeUnique( + "MG_Impl/GLImpl", caller, + std::format("pname {} is not a valid texture parameter.", + MG_Util::ConvertGLEnumToString(pname)))); return; } } @@ -2441,6 +2486,16 @@ namespace MobileGL::MG_Impl::GLImpl { *params = GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE; } break; + case GL_DEPTH_STENCIL_TEXTURE_MODE: + if (params) { + *params = static_cast(textureObject->GetDepthStencilTextureMode()); + } + break; + case GL_TEXTURE_LOD_BIAS: + if (params) { + *params = static_cast(textureObject->GetSamplerObject()->GetLodBias()); + } + break; default: MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, MakeUnique("MG_Impl/GLImpl", "GetTexParameteriv_State", @@ -2587,6 +2642,16 @@ namespace MobileGL::MG_Impl::GLImpl { *params = textureObject->GetSamplerObject()->GetMaxAnisotropy(); } break; + case GL_DEPTH_STENCIL_TEXTURE_MODE: + if (params) { + *params = static_cast(textureObject->GetDepthStencilTextureMode()); + } + break; + case GL_TEXTURE_LOD_BIAS: + if (params) { + *params = static_cast(textureObject->GetSamplerObject()->GetLodBias()); + } + break; default: MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, MakeUnique("MG_Impl/GLImpl", "GetTexParameterfv_State", diff --git a/MobileGL/MG_State/GLState/TextureState/TextureObject.h b/MobileGL/MG_State/GLState/TextureState/TextureObject.h index d3fea053..b2f2f2b0 100644 --- a/MobileGL/MG_State/GLState/TextureState/TextureObject.h +++ b/MobileGL/MG_State/GLState/TextureState/TextureObject.h @@ -60,6 +60,10 @@ namespace MobileGL::MG_State::GLState { virtual Bool HasFixedSampleLocations() const = 0; virtual void SetFixedSampleLocations(Bool fixedSampleLocations) = 0; virtual Uint64 GetLifetimeId() const = 0; + // Which aspect of a packed depth/stencil texture a sampler reads (GL 4.6 core 8.10). + // DEPTH_COMPONENT until set, and meaningless for every other format. + virtual GLenum GetDepthStencilTextureMode() const = 0; + virtual void SetDepthStencilTextureMode(GLenum mode) = 0; protected: virtual Uint GetIndexOfTextureUploadTarget(TextureUploadTarget target) const = 0; @@ -104,6 +108,8 @@ namespace MobileGL::MG_State::GLState { Bool HasFixedSampleLocations() const override; void SetFixedSampleLocations(Bool fixedSampleLocations) override; Uint64 GetLifetimeId() const override; + GLenum GetDepthStencilTextureMode() const override { return m_depthStencilTextureMode; } + void SetDepthStencilTextureMode(GLenum mode) override { m_depthStencilTextureMode = mode; } protected: static Uint64 AllocateLifetimeId(); @@ -124,6 +130,7 @@ namespace MobileGL::MG_State::GLState { // Starts at 1 so a freshly-created backend resource (snapshot 0) never spuriously // matches before its first sync. Bumped only on dirty=true in MarkStorageDirty. Uint64 m_contentVersion = 1; + GLenum m_depthStencilTextureMode = GL_DEPTH_COMPONENT; Int m_samples = 0; Bool m_fixedSampleLocations = true; };