Renderer: Improve texture view support (and support emulation for OGL)
This commit is contained in:
committed by
Jérôme Leclercq
parent
08ea4c87a7
commit
56acbb2694
@@ -27,6 +27,7 @@ namespace Nz::GL
|
||||
inline void DrawBuffers(GLsizei n, const GLenum* bufs);
|
||||
inline void Renderbuffer(GLenum attachment, GLenum renderbuffer);
|
||||
inline void Texture2D(GLenum attachment, GLenum textarget, GLuint texture, GLint level = 0);
|
||||
inline void TextureLayer(GLenum attachment, GLuint texture, GLint level = 0, GLint layer = 0);
|
||||
|
||||
Framebuffer& operator=(const Framebuffer&) = delete;
|
||||
Framebuffer& operator=(Framebuffer&&) noexcept = default;
|
||||
|
||||
@@ -44,6 +44,15 @@ namespace Nz::GL
|
||||
context.glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
inline void Framebuffer::TextureLayer(GLenum attachment, GLuint texture, GLint level, GLint layer)
|
||||
{
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureContext();
|
||||
GLenum target = context.BindFramebuffer(m_objectId);
|
||||
context.glFramebufferTextureLayer(target, attachment, texture, level, layer);
|
||||
}
|
||||
|
||||
inline GLuint Framebuffer::CreateHelper(const Context& context)
|
||||
{
|
||||
GLuint fbo = 0;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Nz::GL
|
||||
inline void TexStorage3D(TextureTarget target, GLint levels, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth);
|
||||
inline void TexSubImage2D(TextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data);
|
||||
inline void TexSubImage3D(TextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* data);
|
||||
inline void TextureView(GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
|
||||
inline void TextureView(TextureTarget target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
|
||||
|
||||
Texture& operator=(const Texture&) = delete;
|
||||
Texture& operator=(Texture&&) noexcept = default;
|
||||
|
||||
@@ -111,10 +111,12 @@ namespace Nz::GL
|
||||
//< TODO: Handle errors
|
||||
}
|
||||
|
||||
inline void Texture::TextureView(GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers)
|
||||
inline void Texture::TextureView(TextureTarget target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers)
|
||||
{
|
||||
m_target = target;
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.glTextureView(m_objectId, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
|
||||
context.glTextureView(m_objectId, ToOpenGL(target), origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
|
||||
}
|
||||
|
||||
inline GLuint Texture::CreateHelper(OpenGLDevice& /*device*/, const Context& context)
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Nz
|
||||
textureInfo.width = GetLevelSize(textureInfo.width, viewInfo.baseMipLevel);
|
||||
textureInfo.height = GetLevelSize(textureInfo.height, viewInfo.baseMipLevel);
|
||||
textureInfo.depth = GetLevelSize(textureInfo.depth, viewInfo.baseMipLevel);
|
||||
textureInfo.levelCount = (textureInfo.levelCount > viewInfo.baseMipLevel) ? (textureInfo.levelCount - viewInfo.baseMipLevel) : 1;
|
||||
textureInfo.layerCount = (textureInfo.layerCount > viewInfo.baseArrayLayer) ? (textureInfo.layerCount - viewInfo.baseArrayLayer) : 1;
|
||||
textureInfo.levelCount = viewInfo.levelCount;
|
||||
textureInfo.layerCount = viewInfo.layerCount;
|
||||
|
||||
return textureInfo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user