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

Add separate define for ImageTextures.

Set it on for platforms, which support this functionality.
This commit is contained in:
Sergey Lipskiy 2014-10-13 19:37:43 +07:00
parent 94c381f734
commit 09eea95270
6 changed files with 33 additions and 25 deletions

View File

@ -39,7 +39,7 @@ DepthBuffer::~DepthBuffer()
void DepthBuffer::initDepthTexture(FrameBuffer * _pBuffer) void DepthBuffer::initDepthTexture(FrameBuffer * _pBuffer)
{ {
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
if (m_pDepthTexture != NULL) if (m_pDepthTexture != NULL)
textureCache().removeFrameBufferTexture(m_pDepthTexture); textureCache().removeFrameBufferTexture(m_pDepthTexture);
m_pDepthTexture = textureCache().addFrameBufferTexture(); m_pDepthTexture = textureCache().addFrameBufferTexture();
@ -75,9 +75,7 @@ void DepthBuffer::initDepthTexture(FrameBuffer * _pBuffer)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _pBuffer->m_FBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _pBuffer->m_FBO);
_pBuffer->m_pDepthBuffer = this; _pBuffer->m_pDepthBuffer = this;
depthBufferList().clearBuffer(); depthBufferList().clearBuffer();
#else #endif // GL_IMAGE_TEXTURES_SUPPORT
depth_texture = NULL;
#endif // GLES2
} }
void DepthBufferList::init() void DepthBufferList::init()
@ -158,7 +156,7 @@ void DepthBufferList::saveBuffer(u32 _address)
void DepthBufferList::clearBuffer() void DepthBufferList::clearBuffer()
{ {
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
if (!video().getRender().isImageTexturesSupported()) if (!video().getRender().isImageTexturesSupported())
return; return;
if (m_pCurrent == NULL || m_pCurrent->m_FBO == 0) if (m_pCurrent == NULL || m_pCurrent->m_FBO == 0)
@ -169,7 +167,7 @@ void DepthBufferList::clearBuffer()
video().getRender().drawRect(0,0,VI.width, VI.height, color); video().getRender().drawRect(0,0,VI.width, VI.height, color);
glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F); glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().getCurrent()->m_FBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().getCurrent()->m_FBO);
#endif // GLES2 #endif // GL_IMAGE_TEXTURES_SUPPORT
} }
void DepthBuffer_Init() void DepthBuffer_Init()

View File

@ -288,7 +288,7 @@ void FrameBufferList::attachDepthBuffer()
pDepthBuffer->initDepthTexture(m_pCurrent); pDepthBuffer->initDepthTexture(m_pCurrent);
m_pCurrent->m_pDepthBuffer = pDepthBuffer; m_pCurrent->m_pDepthBuffer = pDepthBuffer;
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, pDepthBuffer->m_renderbuf); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, pDepthBuffer->m_renderbuf);
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
GLuint attachments[1] = { GL_COLOR_ATTACHMENT0 }; GLuint attachments[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, attachments); glDrawBuffers(1, attachments);
if (video().getRender().isImageTexturesSupported()) if (video().getRender().isImageTexturesSupported())
@ -598,7 +598,7 @@ void FrameBufferToRDRAM::CopyToRDRAM( u32 address, bool bSync ) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
glReadBuffer(GL_COLOR_ATTACHMENT0); glReadBuffer(GL_COLOR_ATTACHMENT0);
#if 1 //ndef GLES2 #ifndef GLES2
// If Sync, read pixels from the buffer, copy them to RDRAM. // If Sync, read pixels from the buffer, copy them to RDRAM.
// If not Sync, read pixels from the buffer, copy pixels from the previous buffer to RDRAM. // If not Sync, read pixels from the buffer, copy pixels from the previous buffer to RDRAM.
if (m_aAddress[m_curIndex] == 0) if (m_aAddress[m_curIndex] == 0)

View File

@ -19,11 +19,13 @@ static GLuint g_calc_mipmap_shader_object;
static GLuint g_calc_noise_shader_object; static GLuint g_calc_noise_shader_object;
static GLuint g_calc_depth_shader_object; static GLuint g_calc_depth_shader_object;
static GLuint g_test_alpha_shader_object; static GLuint g_test_alpha_shader_object;
static GLuint g_zlut_tex = 0;
#ifdef GL_IMAGE_TEXTURES_SUPPORT
static GLuint g_zlut_tex = 0;
static GLuint g_draw_shadow_map_program; static GLuint g_draw_shadow_map_program;
GLuint g_tlut_tex = 0; GLuint g_tlut_tex = 0;
static u32 g_paletteCRC256 = 0; static u32 g_paletteCRC256 = 0;
#endif // GL_IMAGE_TEXTURES_SUPPORT
static std::string strFragmentShader; static std::string strFragmentShader;
@ -61,7 +63,7 @@ bool check_program_link_status(GLuint obj)
return true; return true;
} }
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
static static
void InitZlutTexture() void InitZlutTexture()
{ {
@ -156,7 +158,7 @@ void DestroyShadowMapShader()
glDeleteProgram(g_draw_shadow_map_program); glDeleteProgram(g_draw_shadow_map_program);
g_draw_shadow_map_program = 0; g_draw_shadow_map_program = 0;
} }
#endif // GLES2 #endif // GL_IMAGE_TEXTURES_SUPPORT
void InitShaderCombiner() void InitShaderCombiner()
{ {
@ -194,6 +196,7 @@ void InitShaderCombiner()
glCompileShader(g_test_alpha_shader_object); glCompileShader(g_test_alpha_shader_object);
assert(check_shader_compile_status(g_test_alpha_shader_object)); assert(check_shader_compile_status(g_test_alpha_shader_object));
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (video().getRender().isImageTexturesSupported()) { if (video().getRender().isImageTexturesSupported()) {
g_calc_depth_shader_object = glCreateShader(GL_FRAGMENT_SHADER); g_calc_depth_shader_object = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(g_calc_depth_shader_object, 1, &depth_compare_shader_float, NULL); glShaderSource(g_calc_depth_shader_object, 1, &depth_compare_shader_float, NULL);
@ -203,7 +206,8 @@ void InitShaderCombiner()
InitZlutTexture(); InitZlutTexture();
InitShadowMapShader(); InitShadowMapShader();
#endif #endif // GL_IMAGE_TEXTURES_SUPPORT
#endif // GLES2
} }
void DestroyShaderCombiner() { void DestroyShaderCombiner() {
@ -224,9 +228,11 @@ void DestroyShaderCombiner() {
glDeleteShader(g_calc_depth_shader_object); glDeleteShader(g_calc_depth_shader_object);
g_calc_depth_shader_object = 0; g_calc_depth_shader_object = 0;
#ifdef GL_IMAGE_TEXTURES_SUPPORT
DestroyZlutTexture(); DestroyZlutTexture();
DestroyShadowMapShader(); DestroyShadowMapShader();
#endif #endif // GL_IMAGE_TEXTURES_SUPPORT
#endif // GLES2
} }
const char *ColorInput[] = { const char *ColorInput[] = {
@ -765,6 +771,7 @@ void ShaderCombiner::updateAlphaTestInfo(bool _bForce) {
} }
} }
#ifdef GL_IMAGE_TEXTURES_SUPPORT
void SetShadowMapCombiner() { void SetShadowMapCombiner() {
if (!video().getRender().isImageTexturesSupported()) if (!video().getRender().isImageTexturesSupported())
@ -789,3 +796,4 @@ void SetShadowMapCombiner() {
gDP.changed |= CHANGED_COMBINE; gDP.changed |= CHANGED_COMBINE;
} }
#endif // GL_IMAGE_TEXTURES_SUPPORT

View File

@ -617,10 +617,10 @@ void OGLRender::_setTexCoordArrays() const
void OGLRender::_prepareDrawTriangle(bool _dma) void OGLRender::_prepareDrawTriangle(bool _dma)
{ {
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
if (m_bImageTexture) if (m_bImageTexture)
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
#endif #endif // GL_IMAGE_TEXTURES_SUPPORT
if (gSP.changed || gDP.changed) if (gSP.changed || gDP.changed)
_updateStates(); _updateStates();
@ -812,11 +812,11 @@ void OGLRender::drawTexturedRect(float _ulx, float _uly, float _lrx, float _lry,
currentCombiner()->updateRenderState(); currentCombiner()->updateRenderState();
} }
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
if ((gDP.otherMode.l >> 16) == 0x3c18 && gDP.combine.muxs0 == 0x00ffffff && gDP.combine.muxs1 == 0xfffff238) //depth image based fog if ((gDP.otherMode.l >> 16) == 0x3c18 && gDP.combine.muxs0 == 0x00ffffff && gDP.combine.muxs1 == 0xfffff238) //depth image based fog
//if (gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress && gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width*6/4)) //if (gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress && gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width*6/4))
SetShadowMapCombiner(); SetShadowMapCombiner();
#endif // GLES2 #endif // GL_IMAGE_TEXTURES_SUPPORT
FrameBufferList & fbList = frameBufferList(); FrameBufferList & fbList = frameBufferList();
FrameBuffer* pBuffer = fbList.getCurrent(); FrameBuffer* pBuffer = fbList.getCurrent();
@ -972,13 +972,13 @@ void OGLRender::clearColorBuffer(float *_pColor )
void OGLRender::_initExtensions() void OGLRender::_initExtensions()
{ {
#ifdef GL_IMAGE_TEXTURES_SUPPORT
const char *version = reinterpret_cast<const char*>(glGetString(GL_VERSION)); const char *version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
u32 uVersion = atol(version); u32 uVersion = atol(version);
#ifndef GLES2
m_bImageTexture = (uVersion >= 4) && (glBindImageTexture != NULL); m_bImageTexture = (uVersion >= 4) && (glBindImageTexture != NULL);
#else #else
bImageTexture = false; m_bImageTexture = false;
#endif #endif
} }

View File

@ -7,6 +7,7 @@
#include <GL/gl.h> #include <GL/gl.h>
#include "glext.h" #include "glext.h"
#include "windows/GLFunctions.h" #include "windows/GLFunctions.h"
#define GL_IMAGE_TEXTURES_SUPPORT
#else #else
#include "winlnxdefs.h" #include "winlnxdefs.h"
#ifdef GLES2 #ifdef GLES2
@ -22,6 +23,7 @@
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glext.h> #include <GL/glext.h>
#define GL_IMAGE_TEXTURES_SUPPORT
#endif // OS_MAC_OS_X #endif // OS_MAC_OS_X
#endif // GLES2 #endif // GLES2
#ifdef USE_SDL #ifdef USE_SDL

12
gSP.cpp
View File

@ -1516,7 +1516,7 @@ void gSPLineW3D( s32 v0, s32 v1, s32 wd, s32 flag )
#endif #endif
} }
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
static static
void _copyDepthBuffer() void _copyDepthBuffer()
{ {
@ -1548,7 +1548,7 @@ void _copyDepthBuffer()
// Set back current depth buffer // Set back current depth buffer
depthBufferList().saveBuffer(gDP.depthImageAddress); depthBufferList().saveBuffer(gDP.depthImageAddress);
} }
#endif // GLES2 #endif // GL_IMAGE_TEXTURES_SUPPORT
static static
void loadBGImage(const uObjScaleBg * _bgInfo, bool _loadScale) void loadBGImage(const uObjScaleBg * _bgInfo, bool _loadScale)
@ -1589,13 +1589,13 @@ void gSPBgRect1Cyc( u32 bg )
uObjScaleBg *objScaleBg = (uObjScaleBg*)&RDRAM[address]; uObjScaleBg *objScaleBg = (uObjScaleBg*)&RDRAM[address];
loadBGImage(objScaleBg, true); loadBGImage(objScaleBg, true);
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
if (gSP.bgImage.address == gDP.depthImageAddress || depthBufferList().findBuffer(gSP.bgImage.address) != NULL) if (gSP.bgImage.address == gDP.depthImageAddress || depthBufferList().findBuffer(gSP.bgImage.address) != NULL)
_copyDepthBuffer(); _copyDepthBuffer();
// Zelda MM uses depth buffer copy in LoT and in pause screen. // Zelda MM uses depth buffer copy in LoT and in pause screen.
// In later case depth buffer is used as temporal color buffer, and usual rendering must be used. // In later case depth buffer is used as temporal color buffer, and usual rendering must be used.
// Since both situations are hard to distinguish, do the both depth buffer copy and bg rendering. // Since both situations are hard to distinguish, do the both depth buffer copy and bg rendering.
#endif // GLES2 #endif // GL_IMAGE_TEXTURES_SUPPORT
f32 imageX = gSP.bgImage.imageX; f32 imageX = gSP.bgImage.imageX;
f32 imageY = gSP.bgImage.imageY; f32 imageY = gSP.bgImage.imageY;
@ -1675,11 +1675,11 @@ void gSPBgRectCopy( u32 bg )
uObjScaleBg *objBg = (uObjScaleBg*)&RDRAM[address]; uObjScaleBg *objBg = (uObjScaleBg*)&RDRAM[address];
loadBGImage(objBg, false); loadBGImage(objBg, false);
#ifndef GLES2 #ifdef GL_IMAGE_TEXTURES_SUPPORT
if (gSP.bgImage.address == gDP.depthImageAddress || depthBufferList().findBuffer(gSP.bgImage.address) != NULL) if (gSP.bgImage.address == gDP.depthImageAddress || depthBufferList().findBuffer(gSP.bgImage.address) != NULL)
_copyDepthBuffer(); _copyDepthBuffer();
// See comment to gSPBgRect1Cyc // See comment to gSPBgRect1Cyc
#endif // GLES2 #endif // GL_IMAGE_TEXTURES_SUPPORT
f32 frameX = objBg->frameX / 4.0f; f32 frameX = objBg->frameX / 4.0f;
f32 frameY = objBg->frameY / 4.0f; f32 frameY = objBg->frameY / 4.0f;