mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Implement FramebufferTextureFormats
This commit is contained in:
parent
5e67d79ae7
commit
a30c317c4b
|
@ -438,6 +438,7 @@
|
||||||
<ClInclude Include="..\..\src\Graphics\CombinerProgram.h" />
|
<ClInclude Include="..\..\src\Graphics\CombinerProgram.h" />
|
||||||
<ClInclude Include="..\..\src\Graphics\Context.h" />
|
<ClInclude Include="..\..\src\Graphics\Context.h" />
|
||||||
<ClInclude Include="..\..\src\Graphics\ContextImpl.h" />
|
<ClInclude Include="..\..\src\Graphics\ContextImpl.h" />
|
||||||
|
<ClInclude Include="..\..\src\Graphics\FramebufferTextureFormats.h" />
|
||||||
<ClInclude Include="..\..\src\Graphics\ObjectHandle.h" />
|
<ClInclude Include="..\..\src\Graphics\ObjectHandle.h" />
|
||||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLFunctions.h" />
|
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLFunctions.h" />
|
||||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerInputs.h" />
|
<ClInclude Include="..\..\src\Graphics\OpenGLContext\GLSL\glsl_CombinerInputs.h" />
|
||||||
|
|
|
@ -643,5 +643,8 @@
|
||||||
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GraphicsDrawer.h">
|
<ClInclude Include="..\..\src\Graphics\OpenGLContext\opengl_GraphicsDrawer.h">
|
||||||
<Filter>Header Files\Graphics\OpenGL</Filter>
|
<Filter>Header Files\Graphics\OpenGL</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Graphics\FramebufferTextureFormats.h">
|
||||||
|
<Filter>Header Files\Graphics</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -15,6 +15,7 @@ void Context::init()
|
||||||
{
|
{
|
||||||
m_impl.reset(new opengl::ContextImpl);
|
m_impl.reset(new opengl::ContextImpl);
|
||||||
m_impl->init();
|
m_impl->init();
|
||||||
|
m_fbTexFormats.reset(m_impl->getFramebufferTextureFormats());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::destroy()
|
void Context::destroy()
|
||||||
|
@ -100,6 +101,11 @@ void Context::setTextureParameters(const TexParameters & _parameters)
|
||||||
|
|
||||||
/*---------------Framebuffer-------------*/
|
/*---------------Framebuffer-------------*/
|
||||||
|
|
||||||
|
const FramebufferTextureFormats & Context::getFramebufferTextureFormats()
|
||||||
|
{
|
||||||
|
return *m_fbTexFormats.get();
|
||||||
|
}
|
||||||
|
|
||||||
ObjectHandle Context::createFramebuffer()
|
ObjectHandle Context::createFramebuffer()
|
||||||
{
|
{
|
||||||
return m_impl->createFramebuffer();
|
return m_impl->createFramebuffer();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "CombinerProgram.h"
|
#include "CombinerProgram.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
#include "PixelBuffer.h"
|
#include "PixelBuffer.h"
|
||||||
|
#include "FramebufferTextureFormats.h"
|
||||||
|
|
||||||
#define GRAPHICS_CONTEXT
|
#define GRAPHICS_CONTEXT
|
||||||
|
|
||||||
|
@ -105,6 +106,8 @@ namespace graphics {
|
||||||
|
|
||||||
/*---------------Framebuffer-------------*/
|
/*---------------Framebuffer-------------*/
|
||||||
|
|
||||||
|
const FramebufferTextureFormats & getFramebufferTextureFormats();
|
||||||
|
|
||||||
ObjectHandle createFramebuffer();
|
ObjectHandle createFramebuffer();
|
||||||
|
|
||||||
void deleteFramebuffer(ObjectHandle _name);
|
void deleteFramebuffer(ObjectHandle _name);
|
||||||
|
@ -210,6 +213,7 @@ namespace graphics {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<ContextImpl> m_impl;
|
std::unique_ptr<ContextImpl> m_impl;
|
||||||
|
std::unique_ptr<FramebufferTextureFormats> m_fbTexFormats;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace graphics {
|
||||||
virtual void init2DTexture(const Context::InitTextureParams & _params) = 0;
|
virtual void init2DTexture(const Context::InitTextureParams & _params) = 0;
|
||||||
virtual void update2DTexture(const Context::UpdateTextureDataParams & _params) = 0;
|
virtual void update2DTexture(const Context::UpdateTextureDataParams & _params) = 0;
|
||||||
virtual void setTextureParameters(const Context::TexParameters & _parameters) = 0;
|
virtual void setTextureParameters(const Context::TexParameters & _parameters) = 0;
|
||||||
|
virtual FramebufferTextureFormats * getFramebufferTextureFormats() = 0;
|
||||||
virtual ObjectHandle createFramebuffer() = 0;
|
virtual ObjectHandle createFramebuffer() = 0;
|
||||||
virtual void deleteFramebuffer(ObjectHandle _name) = 0;
|
virtual void deleteFramebuffer(ObjectHandle _name) = 0;
|
||||||
virtual void addFrameBufferRenderTarget(const Context::FrameBufferRenderTarget & _params) = 0;
|
virtual void addFrameBufferRenderTarget(const Context::FrameBufferRenderTarget & _params) = 0;
|
||||||
|
|
41
src/Graphics/FramebufferTextureFormats.h
Normal file
41
src/Graphics/FramebufferTextureFormats.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef GRAPHICS_FRAMEBUFFER_TEXTUREFORMATS_H
|
||||||
|
#define GRAPHICS_FRAMEBUFFER_TEXTUREFORMATS_H
|
||||||
|
#include "Parameter.h"
|
||||||
|
|
||||||
|
namespace graphics {
|
||||||
|
|
||||||
|
struct FramebufferTextureFormats
|
||||||
|
{
|
||||||
|
Parameter colorInternalFormat;
|
||||||
|
Parameter colorFormat;
|
||||||
|
Parameter colorType;
|
||||||
|
u32 colorFormatBytes;
|
||||||
|
|
||||||
|
Parameter monochromeInternalFormat;
|
||||||
|
Parameter monochromeFormat;
|
||||||
|
Parameter monochromeType;
|
||||||
|
u32 monochromeFormatBytes;
|
||||||
|
|
||||||
|
Parameter depthInternalFormat;
|
||||||
|
Parameter depthFormat;
|
||||||
|
Parameter depthType;
|
||||||
|
u32 depthFormatBytes;
|
||||||
|
|
||||||
|
Parameter depthImageInternalFormat;
|
||||||
|
Parameter depthImageFormat;
|
||||||
|
Parameter depthImageType;
|
||||||
|
u32 depthImageFormatBytes;
|
||||||
|
|
||||||
|
Parameter lutInternalFormat;
|
||||||
|
Parameter lutFormat;
|
||||||
|
Parameter lutType;
|
||||||
|
u32 lutFormatBytes;
|
||||||
|
|
||||||
|
virtual ~FramebufferTextureFormats() {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void init() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // GRAPHICS_FRAMEBUFFER_TEXTUREFORMATS_H
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <assert.h>
|
||||||
#include <Graphics/Parameters.h>
|
#include <Graphics/Parameters.h>
|
||||||
#include "opengl_GLInfo.h"
|
#include "opengl_GLInfo.h"
|
||||||
#include "opengl_CachedFunctions.h"
|
#include "opengl_CachedFunctions.h"
|
||||||
|
@ -259,6 +260,135 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*---------------FramebufferTextureFormats-------------*/
|
||||||
|
|
||||||
|
struct FramebufferTextureFormatsGLES2 : public graphics::FramebufferTextureFormats
|
||||||
|
{
|
||||||
|
static bool Check(const GLInfo & _glinfo) {
|
||||||
|
return _glinfo.isGLES2;
|
||||||
|
}
|
||||||
|
|
||||||
|
FramebufferTextureFormatsGLES2()
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init() override
|
||||||
|
{
|
||||||
|
monochromeInternalFormat = GL_RGB;
|
||||||
|
monochromeFormat = GL_RGB;
|
||||||
|
monochromeType = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
monochromeFormatBytes = 2;
|
||||||
|
|
||||||
|
#ifndef USE_DEPTH_RENDERBUFFER
|
||||||
|
depthInternalFormat = GL_DEPTH_COMPONENT;
|
||||||
|
depthFormatBytes = 4;
|
||||||
|
#else
|
||||||
|
depthInternalFormat = GL_DEPTH_COMPONENT16;
|
||||||
|
depthFormatBytes = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
depthFormat = GL_DEPTH_COMPONENT;
|
||||||
|
depthType = GL_UNSIGNED_INT;
|
||||||
|
|
||||||
|
if (Utils::isExtensionSupported("GL_OES_rgb8_rgba8")) {
|
||||||
|
colorInternalFormat = GL_RGBA;
|
||||||
|
colorFormat = GL_RGBA;
|
||||||
|
colorType = GL_UNSIGNED_BYTE;
|
||||||
|
colorFormatBytes = 4;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
colorInternalFormat = GL_RGB;
|
||||||
|
colorFormat = GL_RGB;
|
||||||
|
colorType = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
colorFormatBytes = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FramebufferTextureFormatsGLES3 : public graphics::FramebufferTextureFormats
|
||||||
|
{
|
||||||
|
static bool Check(const GLInfo & _glinfo) {
|
||||||
|
return _glinfo.isGLESX && !_glinfo.isGLES2;
|
||||||
|
}
|
||||||
|
|
||||||
|
FramebufferTextureFormatsGLES3()
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init() override
|
||||||
|
{
|
||||||
|
colorInternalFormat = GL_RGBA8;
|
||||||
|
colorFormat = GL_RGBA;
|
||||||
|
colorType = GL_UNSIGNED_BYTE;
|
||||||
|
colorFormatBytes = 4;
|
||||||
|
|
||||||
|
monochromeInternalFormat = GL_R8;
|
||||||
|
monochromeFormat = GL_RED;
|
||||||
|
monochromeType = GL_UNSIGNED_BYTE;
|
||||||
|
monochromeFormatBytes = 1;
|
||||||
|
|
||||||
|
depthInternalFormat = GL_DEPTH_COMPONENT24;
|
||||||
|
depthFormat = GL_DEPTH_COMPONENT;
|
||||||
|
depthType = GL_UNSIGNED_INT;
|
||||||
|
depthFormatBytes = 4;
|
||||||
|
|
||||||
|
depthImageInternalFormat = GL_RGBA32F;
|
||||||
|
depthImageFormat = GL_RGBA;
|
||||||
|
depthImageType = GL_FLOAT;
|
||||||
|
depthImageFormatBytes = 16;
|
||||||
|
|
||||||
|
lutInternalFormat = GL_R32UI;
|
||||||
|
lutFormat = GL_RED_INTEGER;
|
||||||
|
lutType = GL_UNSIGNED_INT;
|
||||||
|
lutFormatBytes = 4;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FramebufferTextureFormatsOpenGL : public graphics::FramebufferTextureFormats
|
||||||
|
{
|
||||||
|
static bool Check(const GLInfo & _glinfo) {
|
||||||
|
return !_glinfo.isGLESX;
|
||||||
|
}
|
||||||
|
|
||||||
|
FramebufferTextureFormatsOpenGL()
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init() override
|
||||||
|
{
|
||||||
|
colorInternalFormat = GL_RGBA;
|
||||||
|
colorFormat = GL_RGBA;
|
||||||
|
colorType = GL_UNSIGNED_BYTE;
|
||||||
|
colorFormatBytes = 4;
|
||||||
|
|
||||||
|
monochromeInternalFormat = GL_RED;
|
||||||
|
monochromeFormat = GL_RED;
|
||||||
|
monochromeType = GL_UNSIGNED_BYTE;
|
||||||
|
monochromeFormatBytes = 1;
|
||||||
|
|
||||||
|
depthInternalFormat = GL_DEPTH_COMPONENT;
|
||||||
|
depthFormat = GL_DEPTH_COMPONENT;
|
||||||
|
depthType = GL_FLOAT;
|
||||||
|
depthFormatBytes = 4;
|
||||||
|
|
||||||
|
depthImageInternalFormat = GL_RG32F;
|
||||||
|
depthImageFormat = GL_RG;
|
||||||
|
depthImageType = GL_FLOAT;
|
||||||
|
depthImageFormatBytes = 8;
|
||||||
|
|
||||||
|
lutInternalFormat = GL_R16;
|
||||||
|
lutFormat = GL_RED;
|
||||||
|
lutType = GL_UNSIGNED_SHORT;
|
||||||
|
lutFormatBytes = 2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*---------------BufferManipulationObjectFactory-------------*/
|
/*---------------BufferManipulationObjectFactory-------------*/
|
||||||
|
|
||||||
BufferManipulationObjectFactory::BufferManipulationObjectFactory(const GLInfo & _info,
|
BufferManipulationObjectFactory::BufferManipulationObjectFactory(const GLInfo & _info,
|
||||||
|
@ -314,3 +444,18 @@ CreatePixelWriteBuffer * BufferManipulationObjectFactory::createPixelWriteBuffer
|
||||||
|
|
||||||
return new CreatePixelWriteBufferT<PBOWriteBuffer>(m_cachedFunctions.geCachedBindBuffer());
|
return new CreatePixelWriteBufferT<PBOWriteBuffer>(m_cachedFunctions.geCachedBindBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
graphics::FramebufferTextureFormats * BufferManipulationObjectFactory::getFramebufferTextureFormats() const
|
||||||
|
{
|
||||||
|
if (FramebufferTextureFormatsOpenGL::Check(m_glInfo))
|
||||||
|
return new FramebufferTextureFormatsOpenGL;
|
||||||
|
|
||||||
|
if (FramebufferTextureFormatsGLES3::Check(m_glInfo))
|
||||||
|
return new FramebufferTextureFormatsGLES3;
|
||||||
|
|
||||||
|
if (FramebufferTextureFormatsGLES2::Check(m_glInfo))
|
||||||
|
return new FramebufferTextureFormatsGLES2;
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ namespace opengl {
|
||||||
|
|
||||||
BlitFramebuffers * getBlitFramebuffers() const;
|
BlitFramebuffers * getBlitFramebuffers() const;
|
||||||
|
|
||||||
|
graphics::FramebufferTextureFormats * getFramebufferTextureFormats() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const GLInfo & m_glInfo;
|
const GLInfo & m_glInfo;
|
||||||
CachedFunctions & m_cachedFunctions;
|
CachedFunctions & m_cachedFunctions;
|
||||||
|
|
|
@ -37,6 +37,7 @@ void ContextImpl::init()
|
||||||
|
|
||||||
{
|
{
|
||||||
BufferManipulationObjectFactory bufferObjectFactory(m_glInfo, *m_cachedFunctions.get());
|
BufferManipulationObjectFactory bufferObjectFactory(m_glInfo, *m_cachedFunctions.get());
|
||||||
|
m_fbTexFormats.reset(bufferObjectFactory.getFramebufferTextureFormats());
|
||||||
m_createFramebuffer.reset(bufferObjectFactory.getCreateFramebufferObject());
|
m_createFramebuffer.reset(bufferObjectFactory.getCreateFramebufferObject());
|
||||||
m_createRenderbuffer.reset(bufferObjectFactory.getCreateRenderbuffer());
|
m_createRenderbuffer.reset(bufferObjectFactory.getCreateRenderbuffer());
|
||||||
m_initRenderbuffer.reset(bufferObjectFactory.getInitRenderbuffer());
|
m_initRenderbuffer.reset(bufferObjectFactory.getInitRenderbuffer());
|
||||||
|
@ -55,18 +56,18 @@ void ContextImpl::init()
|
||||||
|
|
||||||
void ContextImpl::destroy()
|
void ContextImpl::destroy()
|
||||||
{
|
{
|
||||||
m_cachedFunctions.reset(nullptr);
|
m_cachedFunctions.reset();
|
||||||
m_createTexture.reset(nullptr);
|
m_createTexture.reset();
|
||||||
m_init2DTexture.reset(nullptr);
|
m_init2DTexture.reset();
|
||||||
m_set2DTextureParameters.reset(nullptr);
|
m_set2DTextureParameters.reset();
|
||||||
|
|
||||||
m_createFramebuffer.reset(nullptr);
|
m_createFramebuffer.reset();
|
||||||
m_createRenderbuffer.reset(nullptr);
|
m_createRenderbuffer.reset();
|
||||||
m_initRenderbuffer.reset(nullptr);
|
m_initRenderbuffer.reset();
|
||||||
m_addFramebufferRenderTarget.reset(nullptr);
|
m_addFramebufferRenderTarget.reset();
|
||||||
|
|
||||||
|
|
||||||
m_combinerProgramBuilder.reset(nullptr);
|
m_combinerProgramBuilder.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextImpl::enable(graphics::Parameter _parameter, bool _enable)
|
void ContextImpl::enable(graphics::Parameter _parameter, bool _enable)
|
||||||
|
@ -168,6 +169,11 @@ void ContextImpl::setTextureParameters(const graphics::Context::TexParameters &
|
||||||
|
|
||||||
/*---------------Framebuffer-------------*/
|
/*---------------Framebuffer-------------*/
|
||||||
|
|
||||||
|
graphics::FramebufferTextureFormats * ContextImpl::getFramebufferTextureFormats()
|
||||||
|
{
|
||||||
|
return m_fbTexFormats.release();
|
||||||
|
}
|
||||||
|
|
||||||
graphics::ObjectHandle ContextImpl::createFramebuffer()
|
graphics::ObjectHandle ContextImpl::createFramebuffer()
|
||||||
{
|
{
|
||||||
return m_createFramebuffer->createFramebuffer();
|
return m_createFramebuffer->createFramebuffer();
|
||||||
|
|
|
@ -58,6 +58,8 @@ namespace opengl {
|
||||||
|
|
||||||
/*---------------Framebuffer-------------*/
|
/*---------------Framebuffer-------------*/
|
||||||
|
|
||||||
|
graphics::FramebufferTextureFormats * getFramebufferTextureFormats() override;
|
||||||
|
|
||||||
graphics::ObjectHandle createFramebuffer() override;
|
graphics::ObjectHandle createFramebuffer() override;
|
||||||
|
|
||||||
void deleteFramebuffer(graphics::ObjectHandle _name) override;
|
void deleteFramebuffer(graphics::ObjectHandle _name) override;
|
||||||
|
@ -115,6 +117,7 @@ namespace opengl {
|
||||||
std::unique_ptr<AddFramebufferRenderTarget> m_addFramebufferRenderTarget;
|
std::unique_ptr<AddFramebufferRenderTarget> m_addFramebufferRenderTarget;
|
||||||
std::unique_ptr<CreatePixelWriteBuffer> m_createPixelWriteBuffer;
|
std::unique_ptr<CreatePixelWriteBuffer> m_createPixelWriteBuffer;
|
||||||
std::unique_ptr<BlitFramebuffers> m_blitFramebuffers;
|
std::unique_ptr<BlitFramebuffers> m_blitFramebuffers;
|
||||||
|
std::unique_ptr<graphics::FramebufferTextureFormats> m_fbTexFormats;
|
||||||
|
|
||||||
std::unique_ptr<GraphicsDrawer> m_graphicsDrawer;
|
std::unique_ptr<GraphicsDrawer> m_graphicsDrawer;
|
||||||
std::unique_ptr<TextDrawer> m_textDrawer;
|
std::unique_ptr<TextDrawer> m_textDrawer;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user