1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Buffers to RDRAM rewrite WIP

This commit is contained in:
Sergey Lipskiy 2017-01-23 14:43:40 +07:00
parent 86708c6dc2
commit a94bac0dd0
6 changed files with 20 additions and 14 deletions

View File

@ -44,18 +44,21 @@ ColorBufferToRDRAM::~ColorBufferToRDRAM()
void ColorBufferToRDRAM::init() void ColorBufferToRDRAM::init()
{ {
// generate a framebuffer // generate a framebuffer
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); // glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glGenFramebuffers(1, &m_FBO); // glGenFramebuffers(1, &m_FBO);
m_FBO = gfxContext.createFramebuffer();
_init(); _init();
} }
void ColorBufferToRDRAM::destroy() { void ColorBufferToRDRAM::destroy() {
_destroyFBTexure(); _destroyFBTexure();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
if (m_FBO != 0) { // glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &m_FBO); if (m_FBO.isNotNull()) {
m_FBO = 0; gfxContext.deleteFramebuffer(m_FBO);
// glDeleteFramebuffers(1, &m_FBO);
m_FBO.reset();
} }
} }
@ -109,7 +112,9 @@ void ColorBufferToRDRAM::_initFBTexture(void)
// check if everything is OK // check if everything is OK
assert(checkFBO()); assert(checkFBO());
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER, graphics::ObjectHandle());
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
_initBuffers(); _initBuffers();
} }

View File

@ -4,6 +4,7 @@
#include <OpenGL.h> #include <OpenGL.h>
#include <array> #include <array>
#include <vector> #include <vector>
#include <Graphics/ObjectHandle.h>
struct CachedTexture; struct CachedTexture;
struct FrameBuffer; struct FrameBuffer;
@ -25,13 +26,13 @@ protected:
virtual ~ColorBufferToRDRAM(); virtual ~ColorBufferToRDRAM();
CachedTexture * m_pTexture; CachedTexture * m_pTexture;
std::vector<GLubyte> m_pixelData; std::vector<u8> m_pixelData;
private: private:
virtual void _init() = 0; virtual void _init() = 0;
virtual void _initBuffers(void) = 0; virtual void _initBuffers(void) = 0;
virtual void _destroyBuffers(void) = 0; virtual void _destroyBuffers(void) = 0;
virtual bool _readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) = 0; virtual bool _readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) = 0;
virtual void _cleanUp() = 0; virtual void _cleanUp() = 0;
union RGBA { union RGBA {
@ -56,7 +57,7 @@ private:
static u16 _RGBAtoRGBA16(u32 _c); static u16 _RGBAtoRGBA16(u32 _c);
static u32 _RGBAtoRGBA32(u32 _c); static u32 _RGBAtoRGBA32(u32 _c);
GLuint m_FBO; graphics::ObjectHandle m_FBO;
FrameBuffer * m_pCurFrameBuffer; FrameBuffer * m_pCurFrameBuffer;
u32 m_frameCount; u32 m_frameCount;
u32 m_startAddress; u32 m_startAddress;

View File

@ -52,7 +52,7 @@ void ColorBufferToRDRAM_BufferStorageExt::_destroyBuffers(void)
m_PBO[index] = 0; m_PBO[index] = 0;
} }
bool ColorBufferToRDRAM_BufferStorageExt::_readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) bool ColorBufferToRDRAM_BufferStorageExt::_readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync)
{ {
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
GLenum colorFormat, colorType, colorFormatBytes; GLenum colorFormat, colorType, colorFormatBytes;

View File

@ -10,7 +10,7 @@ public:
~ColorBufferToRDRAM_BufferStorageExt() = default; ~ColorBufferToRDRAM_BufferStorageExt() = default;
private: private:
bool _readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) override; bool _readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) override;
void _cleanUp() override; void _cleanUp() override;
void _init(void) override; void _init(void) override;
void _initBuffers(void) override; void _initBuffers(void) override;

View File

@ -36,7 +36,7 @@ void ColorBufferToRDRAM_GL::_initBuffers(void)
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
} }
bool ColorBufferToRDRAM_GL::_readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) bool ColorBufferToRDRAM_GL::_readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync)
{ {
const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
GLenum colorFormat, colorType, colorFormatBytes; GLenum colorFormat, colorType, colorFormatBytes;

View File

@ -11,7 +11,7 @@ public:
private: private:
void _init() override; void _init() override;
void _destroyBuffers() override; void _destroyBuffers() override;
bool _readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) override; bool _readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) override;
void _cleanUp() override; void _cleanUp() override;
void _initBuffers(void) override; void _initBuffers(void) override;
static const int _numPBO = 3; static const int _numPBO = 3;