1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +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)
{
#ifndef GLES2
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (m_pDepthTexture != NULL)
textureCache().removeFrameBufferTexture(m_pDepthTexture);
m_pDepthTexture = textureCache().addFrameBufferTexture();
@ -75,9 +75,7 @@ void DepthBuffer::initDepthTexture(FrameBuffer * _pBuffer)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _pBuffer->m_FBO);
_pBuffer->m_pDepthBuffer = this;
depthBufferList().clearBuffer();
#else
depth_texture = NULL;
#endif // GLES2
#endif // GL_IMAGE_TEXTURES_SUPPORT
}
void DepthBufferList::init()
@ -158,7 +156,7 @@ void DepthBufferList::saveBuffer(u32 _address)
void DepthBufferList::clearBuffer()
{
#ifndef GLES2
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (!video().getRender().isImageTexturesSupported())
return;
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);
glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().getCurrent()->m_FBO);
#endif // GLES2
#endif // GL_IMAGE_TEXTURES_SUPPORT
}
void DepthBuffer_Init()

View File

@ -288,7 +288,7 @@ void FrameBufferList::attachDepthBuffer()
pDepthBuffer->initDepthTexture(m_pCurrent);
m_pCurrent->m_pDepthBuffer = pDepthBuffer;
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, pDepthBuffer->m_renderbuf);
#ifndef GLES2
#ifdef GL_IMAGE_TEXTURES_SUPPORT
GLuint attachments[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, attachments);
if (video().getRender().isImageTexturesSupported())
@ -598,7 +598,7 @@ void FrameBufferToRDRAM::CopyToRDRAM( u32 address, bool bSync ) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO);
glReadBuffer(GL_COLOR_ATTACHMENT0);
#if 1 //ndef GLES2
#ifndef GLES2
// 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 (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_depth_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;
GLuint g_tlut_tex = 0;
static u32 g_paletteCRC256 = 0;
#endif // GL_IMAGE_TEXTURES_SUPPORT
static std::string strFragmentShader;
@ -61,7 +63,7 @@ bool check_program_link_status(GLuint obj)
return true;
}
#ifndef GLES2
#ifdef GL_IMAGE_TEXTURES_SUPPORT
static
void InitZlutTexture()
{
@ -156,7 +158,7 @@ void DestroyShadowMapShader()
glDeleteProgram(g_draw_shadow_map_program);
g_draw_shadow_map_program = 0;
}
#endif // GLES2
#endif // GL_IMAGE_TEXTURES_SUPPORT
void InitShaderCombiner()
{
@ -194,6 +196,7 @@ void InitShaderCombiner()
glCompileShader(g_test_alpha_shader_object);
assert(check_shader_compile_status(g_test_alpha_shader_object));
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (video().getRender().isImageTexturesSupported()) {
g_calc_depth_shader_object = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(g_calc_depth_shader_object, 1, &depth_compare_shader_float, NULL);
@ -203,7 +206,8 @@ void InitShaderCombiner()
InitZlutTexture();
InitShadowMapShader();
#endif
#endif // GL_IMAGE_TEXTURES_SUPPORT
#endif // GLES2
}
void DestroyShaderCombiner() {
@ -224,9 +228,11 @@ void DestroyShaderCombiner() {
glDeleteShader(g_calc_depth_shader_object);
g_calc_depth_shader_object = 0;
#ifdef GL_IMAGE_TEXTURES_SUPPORT
DestroyZlutTexture();
DestroyShadowMapShader();
#endif
#endif // GL_IMAGE_TEXTURES_SUPPORT
#endif // GLES2
}
const char *ColorInput[] = {
@ -765,6 +771,7 @@ void ShaderCombiner::updateAlphaTestInfo(bool _bForce) {
}
}
#ifdef GL_IMAGE_TEXTURES_SUPPORT
void SetShadowMapCombiner() {
if (!video().getRender().isImageTexturesSupported())
@ -789,3 +796,4 @@ void SetShadowMapCombiner() {
gDP.changed |= CHANGED_COMBINE;
}
#endif // GL_IMAGE_TEXTURES_SUPPORT

View File

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

View File

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

12
gSP.cpp
View File

@ -1516,7 +1516,7 @@ void gSPLineW3D( s32 v0, s32 v1, s32 wd, s32 flag )
#endif
}
#ifndef GLES2
#ifdef GL_IMAGE_TEXTURES_SUPPORT
static
void _copyDepthBuffer()
{
@ -1548,7 +1548,7 @@ void _copyDepthBuffer()
// Set back current depth buffer
depthBufferList().saveBuffer(gDP.depthImageAddress);
}
#endif // GLES2
#endif // GL_IMAGE_TEXTURES_SUPPORT
static
void loadBGImage(const uObjScaleBg * _bgInfo, bool _loadScale)
@ -1589,13 +1589,13 @@ void gSPBgRect1Cyc( u32 bg )
uObjScaleBg *objScaleBg = (uObjScaleBg*)&RDRAM[address];
loadBGImage(objScaleBg, true);
#ifndef GLES2
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (gSP.bgImage.address == gDP.depthImageAddress || depthBufferList().findBuffer(gSP.bgImage.address) != NULL)
_copyDepthBuffer();
// 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.
// 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 imageY = gSP.bgImage.imageY;
@ -1675,11 +1675,11 @@ void gSPBgRectCopy( u32 bg )
uObjScaleBg *objBg = (uObjScaleBg*)&RDRAM[address];
loadBGImage(objBg, false);
#ifndef GLES2
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (gSP.bgImage.address == gDP.depthImageAddress || depthBufferList().findBuffer(gSP.bgImage.address) != NULL)
_copyDepthBuffer();
// See comment to gSPBgRect1Cyc
#endif // GLES2
#endif // GL_IMAGE_TEXTURES_SUPPORT
f32 frameX = objBg->frameX / 4.0f;
f32 frameY = objBg->frameY / 4.0f;