mirror of
https://github.com/DrBeef/QuestZDoom.git
synced 2025-04-24 18:22:02 +00:00
Changes to support buffer investigation
This commit is contained in:
parent
35163ee836
commit
9d6e140f7c
18 changed files with 197 additions and 150 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.drbeef.questzdoom"
|
||||
android:versionCode="22"
|
||||
android:versionName="1.1.4" android:installLocation="auto" >
|
||||
android:versionCode="24"
|
||||
android:versionName="1.1.6" android:installLocation="auto" >
|
||||
|
||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
|
||||
|
|
|
@ -25,6 +25,11 @@ android {
|
|||
}
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 26
|
||||
|
||||
// packagingOptions {
|
||||
// specify the path to your object binaries, or generally:
|
||||
// doNotStrip '**.so'
|
||||
// }
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -42,6 +47,11 @@ android {
|
|||
}
|
||||
compileSdkVersion = 24
|
||||
buildToolsVersion = '29.0.1'
|
||||
/* buildTypes {
|
||||
release {
|
||||
debuggable true
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -104,7 +104,7 @@ int GPU_LEVEL = 4;
|
|||
int NUM_MULTI_SAMPLES = 1;
|
||||
int FFR = 0;
|
||||
float SS_MULTIPLIER = 1.0f;
|
||||
int DISPLAY_REFRESH = 72;
|
||||
int DISPLAY_REFRESH = -1;
|
||||
|
||||
jclass clazz;
|
||||
|
||||
|
@ -620,11 +620,6 @@ void ovrFramebuffer_Destroy( ovrFramebuffer * frameBuffer )
|
|||
|
||||
void ovrFramebuffer_SetCurrent( ovrFramebuffer * frameBuffer )
|
||||
{
|
||||
while (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GL( glBindFramebuffer( GL_FRAMEBUFFER, frameBuffer->FrameBuffers[frameBuffer->ProcessingTextureSwapChainIndex] ) );
|
||||
}
|
||||
|
||||
|
@ -694,7 +689,7 @@ void ovrRenderer_Clear( ovrRenderer * renderer )
|
|||
{
|
||||
ovrFramebuffer_Clear( &renderer->FrameBuffer[eye] );
|
||||
}
|
||||
renderer->ProjectionMatrix = ovrMatrix4f_CreateIdentity();
|
||||
|
||||
renderer->NumBuffers = VRAPI_FRAME_LAYER_EYE_MAX;
|
||||
}
|
||||
|
||||
|
@ -716,11 +711,6 @@ void ovrRenderer_Create( int width, int height, ovrRenderer * renderer, const ov
|
|||
height,
|
||||
NUM_MULTI_SAMPLES );
|
||||
}
|
||||
|
||||
// Setup the projection matrix.
|
||||
renderer->ProjectionMatrix = ovrMatrix4f_CreateProjectionFov(
|
||||
vrFOV, vrFOV, 0.0f, 0.0f, 1.0f, 0.0f );
|
||||
|
||||
}
|
||||
|
||||
void ovrRenderer_Destroy( ovrRenderer * renderer )
|
||||
|
@ -729,7 +719,6 @@ void ovrRenderer_Destroy( ovrRenderer * renderer )
|
|||
{
|
||||
ovrFramebuffer_Destroy( &renderer->FrameBuffer[eye] );
|
||||
}
|
||||
renderer->ProjectionMatrix = ovrMatrix4f_CreateIdentity();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1307,6 +1296,10 @@ static ovrApp gAppState;
|
|||
static ovrJava java;
|
||||
static bool destroyed = false;
|
||||
|
||||
int QzDoom_GetRefresh()
|
||||
{
|
||||
return vrapi_GetSystemPropertyInt(&gAppState.Java, VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE);
|
||||
}
|
||||
|
||||
float QzDoom_GetFOV()
|
||||
{
|
||||
|
@ -1473,7 +1466,9 @@ void * AppThreadFunction(void * parm ) {
|
|||
}
|
||||
|
||||
//Set the screen refresh
|
||||
vrapi_SetDisplayRefreshRate(gAppState.Ovr, DISPLAY_REFRESH);
|
||||
if (DISPLAY_REFRESH != -1) {
|
||||
vrapi_SetDisplayRefreshRate(gAppState.Ovr, DISPLAY_REFRESH);
|
||||
}
|
||||
|
||||
// Create the scene if not yet created.
|
||||
ovrScene_Create( m_width, m_height, &gAppState.Scene, &java );
|
||||
|
|
|
@ -84,7 +84,6 @@ ovrRenderer
|
|||
typedef struct
|
||||
{
|
||||
ovrFramebuffer FrameBuffer[VRAPI_FRAME_LAYER_EYE_MAX];
|
||||
ovrMatrix4f ProjectionMatrix;
|
||||
int NumBuffers;
|
||||
} ovrRenderer;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ include $(CLEAR_VARS)
|
|||
|
||||
LOCAL_MODULE := qzdoom
|
||||
|
||||
LOCAL_CFLAGS := -D__MOBILE__ -DNO_PIX_BUFF -DOPNMIDI_DISABLE_GX_EMULATOR -DGZDOOM -DLZDOOM -DUSE_GL_HW_BUFFERS -DNO_VBO -D__STDINT_LIMITS -DENGINE_NAME=\"lzdoom\"
|
||||
LOCAL_CFLAGS := -D__MOBILE__ -DNO_PIX_BUFF -DOPNMIDI_DISABLE_GX_EMULATOR -DGZDOOM -DLZDOOM -DNO_VBO -D__STDINT_LIMITS -DENGINE_NAME=\"lzdoom\"
|
||||
|
||||
|
||||
LOCAL_CPPFLAGS := -DHAVE_FLUIDSYNTH -DHAVE_MPG123 -DHAVE_SNDFILE -std=c++14 -DHAVE_JWZGLES -Wno-switch -Wno-inconsistent-missing-override -Werror=format-security -fexceptions -fpermissive -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D__forceinline=inline -DNO_GTK -DNO_SSE -fsigned-char
|
||||
|
@ -497,7 +497,7 @@ LOCAL_LDLIBS += -lEGL
|
|||
#LOCAL_LDLIBS += -Wl,--no-warn-shared-textrel
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := sndfile mpg123 fluidsynth-static libjpeg zlib_lz lzma_lz gdtoa_lz dumb_lz gme_lz bzip2_lz zmusic_lz
|
||||
LOCAL_SHARED_LIBRARIES := openal vrapi saffal
|
||||
LOCAL_SHARED_LIBRARIES := openal vrapi
|
||||
|
||||
LOCAL_STATIC_LIBRARIES +=
|
||||
|
||||
|
|
|
@ -542,8 +542,6 @@ enum
|
|||
|
||||
#define BLINKTHRESHOLD (4*32)
|
||||
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
#define MAX_HW_BUFFERS 4
|
||||
#endif
|
||||
#define MAX_HW_BUFFERS 10
|
||||
|
||||
#endif // __DOOMDEF_H__
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
|
||||
CVAR(Int, gl_buffer_size, 2000000, CVAR_ARCHIVE);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -133,7 +134,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
{
|
||||
case BM_PERSISTENT:
|
||||
{
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
unsigned int bytesize = gl_buffer_size * sizeof(FFlatVertex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||
|
@ -143,7 +144,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
|
||||
case BM_DEFERRED:
|
||||
{
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
unsigned int bytesize = gl_buffer_size * sizeof(FFlatVertex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
glBufferData(GL_ARRAY_BUFFER, bytesize, NULL, GL_STREAM_DRAW);
|
||||
map = nullptr;
|
||||
|
@ -153,7 +154,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
|
||||
default:
|
||||
{
|
||||
map = new FFlatVertex[BUFFER_SIZE];
|
||||
map = new FFlatVertex[gl_buffer_size];
|
||||
DPrintf(DMSG_NOTIFY, "Using client array buffer\n");
|
||||
break;
|
||||
}
|
||||
|
@ -254,10 +255,16 @@ void FFlatVertexBuffer::Map()
|
|||
{
|
||||
if (gl.buffermethod == BM_DEFERRED)
|
||||
{
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
unsigned int bytesize = gl_buffer_size * sizeof(FFlatVertex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
gl_RenderState.ResetVertexBuffer();
|
||||
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
//map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT );
|
||||
if (map == nullptr)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
Printf("ERROR: glMapBufferRange failed to map with error %X - crash imminent!\n", (int)err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,10 +272,14 @@ void FFlatVertexBuffer::Unmap()
|
|||
{
|
||||
if (gl.buffermethod == BM_DEFERRED)
|
||||
{
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
unsigned int bytesize = gl_buffer_size * sizeof(FFlatVertex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
gl_RenderState.ResetVertexBuffer();
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
if (glUnmapBuffer(GL_ARRAY_BUFFER) == GL_FALSE)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
Printf("ERROR: glUnmapBuffer failed to unmap with error %X\n", (int)err);
|
||||
}
|
||||
map = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "gl/system/gl_interface.h"
|
||||
#include "r_data/models/models.h"
|
||||
|
||||
EXTERN_CVAR(Int, gl_buffer_size);
|
||||
|
||||
struct vertex_t;
|
||||
struct secplane_t;
|
||||
struct subsector_t;
|
||||
|
@ -113,9 +115,6 @@ class FFlatVertexBuffer : public FVertexBuffer
|
|||
|
||||
void CheckPlanes(sector_t *sector);
|
||||
|
||||
static const unsigned int BUFFER_SIZE = 2000000;
|
||||
static const unsigned int BUFFER_SIZE_TO_USE = 1999500;
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
|
@ -142,24 +141,50 @@ public:
|
|||
|
||||
FFlatVertex *GetBuffer()
|
||||
{
|
||||
if (mCurIndex >= gl_buffer_size)
|
||||
{
|
||||
Printf("ERROR - Trying to index an invalid BUFFER!, mCurIndex=%d\n", mCurIndex);
|
||||
mCurIndex = mIndex;
|
||||
return nullptr;
|
||||
}
|
||||
return &map[mCurIndex];
|
||||
}
|
||||
|
||||
FFlatVertex *Alloc(int num, int *poffset)
|
||||
{
|
||||
FFlatVertex *p = GetBuffer();
|
||||
*poffset = mCurIndex;
|
||||
mCurIndex += num;
|
||||
if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex;
|
||||
if (mCurIndex >= (gl_buffer_size - 500))
|
||||
{
|
||||
Printf("ERROR - We have run out of BUFFERS!, mCurIndex=%d\n", mCurIndex);
|
||||
mCurIndex = mIndex;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
bool IsValid(FFlatVertex *newptr)
|
||||
{
|
||||
unsigned int newofs = (unsigned int)(newptr - map);
|
||||
if (newofs >= (gl_buffer_size - 500))
|
||||
{
|
||||
Printf("ERROR - Trying to index an invalid BUFFER!, newofs=%d\n", newofs);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset)
|
||||
{
|
||||
unsigned int newofs = (unsigned int)(newptr - map);
|
||||
unsigned int diff = newofs - mCurIndex;
|
||||
*poffset = mCurIndex;
|
||||
mCurIndex = newofs;
|
||||
if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex;
|
||||
if (mCurIndex >= (gl_buffer_size - 500))
|
||||
{
|
||||
Printf("ERROR - We have run out of BUFFERS!, mCurIndex=%d\n", mCurIndex);
|
||||
mCurIndex = mIndex;
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway.
|
||||
|
|
|
@ -74,11 +74,18 @@
|
|||
#include "gl/models/gl_models.h"
|
||||
#include "gl/dynlights/gl_lightbuffer.h"
|
||||
#include "r_videoscale.h"
|
||||
#include "QzDoom/VrCommon.h"
|
||||
|
||||
EXTERN_CVAR(Int, screenblocks)
|
||||
|
||||
CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);
|
||||
|
||||
CVAR(Int, gl_client_wait_timeout_ms, 100, CVAR_ARCHIVE);
|
||||
CUSTOM_CVAR(Int, gl_hardware_buffers, 4, CVAR_ARCHIVE)
|
||||
{
|
||||
if (self < 0 || self > MAX_HW_BUFFERS) self = MAX_HW_BUFFERS;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Renderer interface
|
||||
|
@ -132,12 +139,23 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
|||
mShadowMapShader = nullptr;
|
||||
mCustomPostProcessShaders = nullptr;
|
||||
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
for(int n = 0; n < MAX_HW_BUFFERS; n++)
|
||||
mVBOBuff = new FFlatVertexBuffer*[gl_hardware_buffers];
|
||||
for(int n = 0; n < gl_hardware_buffers; n++)
|
||||
{
|
||||
mVBOBuff[n] = nullptr;
|
||||
}
|
||||
|
||||
mSkyVBOBuff = new FSkyVertexBuffer*[gl_hardware_buffers];
|
||||
for(int n = 0; n < gl_hardware_buffers; n++)
|
||||
{
|
||||
mSkyVBOBuff[n] = nullptr;
|
||||
}
|
||||
|
||||
syncBuff = new GLsync[gl_hardware_buffers];
|
||||
for(int n = 0; n < gl_hardware_buffers; n++)
|
||||
{
|
||||
syncBuff[n] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void FGLRenderer::Initialize(int width, int height)
|
||||
|
@ -177,18 +195,16 @@ void FGLRenderer::Initialize(int width, int height)
|
|||
FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID");
|
||||
}
|
||||
else mVAOID = 0;
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
for(int n = 0; n < nbrHwBuffers; n++)
|
||||
{
|
||||
mVBOBuff[n] = new FFlatVertexBuffer(width, height);
|
||||
mSkyVBOBuff[n] = new FSkyVertexBuffer;
|
||||
}
|
||||
NextVtxBuffer();
|
||||
NextSkyBuffer();
|
||||
#else
|
||||
mVBO = new FFlatVertexBuffer(width, height);
|
||||
mSkyVBO = new FSkyVertexBuffer;
|
||||
#endif
|
||||
|
||||
for (int n = 0; n < gl_hardware_buffers; n++) {
|
||||
mVBOBuff[n] = new FFlatVertexBuffer(width, height);
|
||||
mSkyVBOBuff[n] = new FSkyVertexBuffer;
|
||||
}
|
||||
|
||||
//Set up the VBO pointer to the first buffer
|
||||
NextVtxBuffer();
|
||||
NextSkyBuffer();
|
||||
|
||||
if (!gl.legacyMode) mLights = new FLightBuffer();
|
||||
else mLights = NULL;
|
||||
|
||||
|
@ -213,8 +229,20 @@ FGLRenderer::~FGLRenderer()
|
|||
if (m2DDrawer != nullptr) delete m2DDrawer;
|
||||
if (mShaderManager != NULL) delete mShaderManager;
|
||||
if (mSamplerManager != NULL) delete mSamplerManager;
|
||||
if (mVBO != NULL) delete mVBO;
|
||||
if (mSkyVBO != NULL) delete mSkyVBO;
|
||||
|
||||
for(int n = 0; n < gl_hardware_buffers; n++)
|
||||
{
|
||||
delete mVBOBuff[n];
|
||||
}
|
||||
if (mVBOBuff) delete []mVBOBuff;
|
||||
|
||||
for(int n = 0; n < gl_hardware_buffers; n++)
|
||||
{
|
||||
delete mSkyVBOBuff[n];
|
||||
}
|
||||
if (mSkyVBOBuff) delete []mSkyVBOBuff;
|
||||
if (syncBuff) delete []syncBuff;
|
||||
|
||||
if (mLights != NULL) delete mLights;
|
||||
if (mFBID != 0) glDeleteFramebuffers(1, &mFBID);
|
||||
if (mVAOID != 0)
|
||||
|
@ -376,22 +404,16 @@ int FGLRenderer::ScreenToWindowY(int y)
|
|||
|
||||
void FGLRenderer::SetupLevel(bool resetBufferIndices)
|
||||
{
|
||||
if (resetBufferIndices)
|
||||
{
|
||||
if (resetBufferIndices) {
|
||||
VtxBuff = 0;
|
||||
NextVtxBuffer();
|
||||
SkyBuff = 0;
|
||||
NextSkyBuffer();
|
||||
}
|
||||
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
for (int n = 0; n < nbrHwBuffers; n++)
|
||||
{
|
||||
mVBOBuff[n]->CreateVBO();
|
||||
for (int n = 0; n < gl_hardware_buffers; n++) {
|
||||
mVBOBuff[n]->CreateVBO();
|
||||
}
|
||||
#else
|
||||
mVBO->CreateVBO();
|
||||
#endif
|
||||
}
|
||||
|
||||
void FGLRenderer::Begin2D()
|
||||
|
@ -465,10 +487,9 @@ unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
void FGLRenderer::GPUDropSync()
|
||||
{
|
||||
if(nbrHwBuffers > 1)
|
||||
if(gl_hardware_buffers > 1)
|
||||
{
|
||||
if (syncBuff[VtxBuff] != NULL)
|
||||
{
|
||||
|
@ -481,18 +502,25 @@ void FGLRenderer::GPUDropSync()
|
|||
|
||||
void FGLRenderer::GPUWaitSync()
|
||||
{
|
||||
if(nbrHwBuffers > 1)
|
||||
if(gl_hardware_buffers > 1)
|
||||
{
|
||||
if( syncBuff[VtxBuff] )
|
||||
{
|
||||
GLenum status = glClientWaitSync(syncBuff[VtxBuff], GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 * 50); // Wait for a max of 50ms...
|
||||
if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED)
|
||||
{
|
||||
Printf("Error on glClientWaitSync: %d\n", status);
|
||||
}
|
||||
GLenum status = glClientWaitSync(syncBuff[VtxBuff], GL_SYNC_FLUSH_COMMANDS_BIT,
|
||||
1000 * 1000 *
|
||||
gl_client_wait_timeout_ms);
|
||||
|
||||
if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED) {
|
||||
if (status == GL_TIMEOUT_EXPIRED) {
|
||||
double time = GetTimeInMilliSeconds();
|
||||
Printf("Error on glClientWaitSync: BUFFER: %d TIMEOUT_MS: %d EXPIRED_TIME (ms): %.3f\n", VtxBuff, (int)gl_client_wait_timeout_ms, time);
|
||||
} else {
|
||||
Printf("Error on glClientWaitSync: %X\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
glDeleteSync(syncBuff[VtxBuff]);
|
||||
syncBuff[VtxBuff] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -9,9 +9,7 @@
|
|||
#include "gl/dynlights/gl_shadowmap.h"
|
||||
#include <functional>
|
||||
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
#include "gl/system/gl_system.h"
|
||||
#endif
|
||||
|
||||
struct particle_t;
|
||||
class FCanvasTexture;
|
||||
|
@ -50,7 +48,7 @@ class FShadowMapShader;
|
|||
class FCustomPostProcessShaders;
|
||||
class GLSceneDrawer;
|
||||
|
||||
|
||||
EXTERN_CVAR(Int, gl_hardware_buffers)
|
||||
|
||||
inline float DEG2RAD(float deg)
|
||||
{
|
||||
|
@ -154,18 +152,15 @@ public:
|
|||
FRotator mAngles;
|
||||
FVector2 mViewVector;
|
||||
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
int nbrHwBuffers = 4;
|
||||
|
||||
int LightBuff = 0;
|
||||
int SkyBuff = 0;
|
||||
int VtxBuff = 0;
|
||||
|
||||
FFlatVertexBuffer *mVBOBuff[MAX_HW_BUFFERS];
|
||||
FSkyVertexBuffer *mSkyVBOBuff[MAX_HW_BUFFERS];
|
||||
FFlatVertexBuffer **mVBOBuff;
|
||||
FSkyVertexBuffer **mSkyVBOBuff;
|
||||
|
||||
// Used instead of GLsync
|
||||
GLsync syncBuff[MAX_HW_BUFFERS];
|
||||
GLsync *syncBuff;
|
||||
|
||||
void GPUDropSync();
|
||||
void GPUWaitSync();
|
||||
|
@ -173,19 +168,24 @@ public:
|
|||
void NextVtxBuffer()
|
||||
{
|
||||
mVBO = mVBOBuff[VtxBuff];
|
||||
VtxBuff++;
|
||||
VtxBuff %= nbrHwBuffers;
|
||||
if (gl_hardware_buffers > 1) {
|
||||
VtxBuff++;
|
||||
VtxBuff %= (int)gl_hardware_buffers;
|
||||
}
|
||||
}
|
||||
|
||||
void NextSkyBuffer()
|
||||
{
|
||||
mSkyVBO = mSkyVBOBuff[SkyBuff];
|
||||
SkyBuff++;
|
||||
SkyBuff %= nbrHwBuffers;
|
||||
if (gl_hardware_buffers > 1) {
|
||||
SkyBuff++;
|
||||
SkyBuff %= (int)gl_hardware_buffers;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FFlatVertexBuffer *mVBO;
|
||||
FSkyVertexBuffer *mSkyVBO;
|
||||
|
||||
FLightBuffer *mLights;
|
||||
F2DDrawer *m2DDrawer;
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ EXTERN_CVAR (Float, underwater_fade_scalar)
|
|||
EXTERN_CVAR (Float, r_visibility)
|
||||
EXTERN_CVAR (Bool, gl_legacy_mode)
|
||||
EXTERN_CVAR (Bool, r_drawvoxels)
|
||||
EXTERN_CVAR(Bool, gl_sync)
|
||||
|
||||
extern bool NoInterpolateView;
|
||||
|
||||
|
@ -943,12 +944,12 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
|
|||
|
||||
void FGLRenderer::RenderView (player_t* player)
|
||||
{
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
GLRenderer->NextVtxBuffer();
|
||||
GLRenderer->NextSkyBuffer();
|
||||
GLRenderer->NextVtxBuffer();
|
||||
GLRenderer->NextSkyBuffer();
|
||||
|
||||
GLRenderer->GPUWaitSync();
|
||||
#endif
|
||||
if (gl_sync) {
|
||||
GLRenderer->GPUWaitSync();
|
||||
}
|
||||
|
||||
gl_ClearFakeFlat();
|
||||
|
||||
|
|
|
@ -171,19 +171,21 @@ void GLWall::MakeVertices(bool nosplit)
|
|||
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
|
||||
ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
|
||||
ptr++;
|
||||
if (split && glseg.fracleft == 0) SplitLeftEdge(ptr);
|
||||
ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
|
||||
ptr++;
|
||||
if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr);
|
||||
ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v);
|
||||
ptr++;
|
||||
if (split && glseg.fracright == 1) SplitRightEdge(ptr);
|
||||
ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v);
|
||||
ptr++;
|
||||
if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr);
|
||||
vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex);
|
||||
if (ptr != nullptr) {
|
||||
ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
|
||||
ptr++;
|
||||
if (split && glseg.fracleft == 0) SplitLeftEdge(ptr);
|
||||
ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
|
||||
ptr++;
|
||||
if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr);
|
||||
ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v);
|
||||
ptr++;
|
||||
if (split && glseg.fracright == 1) SplitRightEdge(ptr);
|
||||
ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v);
|
||||
ptr++;
|
||||
if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr);
|
||||
vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace s3d
|
|||
outViewShift[0] = outViewShift[1] = outViewShift[2] = 0;
|
||||
|
||||
vec3_t angles;
|
||||
VectorSet(angles, -GLRenderer->mAngles.Pitch.Degrees, getViewpointYaw(), GLRenderer->mAngles.Roll.Degrees);
|
||||
VectorSet(angles, GLRenderer->mAngles.Pitch.Degrees, getViewpointYaw(), GLRenderer->mAngles.Roll.Degrees);
|
||||
|
||||
vec3_t v_forward, v_right, v_up;
|
||||
AngleVectors(angles, v_forward, v_right, v_up);
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
EXTERN_CVAR (Float, vid_brightness)
|
||||
EXTERN_CVAR (Float, vid_contrast)
|
||||
EXTERN_CVAR (Bool, vid_vsync)
|
||||
EXTERN_CVAR (Int, gl_hardware_buffers)
|
||||
|
||||
CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE)
|
||||
|
||||
|
@ -77,11 +78,7 @@ CUSTOM_CVAR(Int, vid_hwgamma, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITC
|
|||
//
|
||||
//
|
||||
//==========================================================================
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, int nbrHwBuffers) :
|
||||
#else
|
||||
OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) :
|
||||
#endif
|
||||
Super(hMonitor, width, height, bits, refreshHz, fullscreen, false)
|
||||
{
|
||||
// SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver.
|
||||
|
@ -94,9 +91,6 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int
|
|||
gl_RenderState.Reset();
|
||||
|
||||
GLRenderer = new FGLRenderer(this);
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
GLRenderer->nbrHwBuffers = nbrHwBuffers;
|
||||
#endif
|
||||
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
|
||||
UpdatePalette ();
|
||||
ScreenshotBuffer = NULL;
|
||||
|
@ -198,14 +192,10 @@ void OpenGLFrameBuffer::Update()
|
|||
Pitch = Width = clientWidth;
|
||||
Height = clientHeight;
|
||||
V_OutputResized(Width, Height);
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
for (int n = 0; n < GLRenderer->nbrHwBuffers; n++)
|
||||
{
|
||||
GLRenderer->mVBOBuff[n]->OutputResized(Width, Height);
|
||||
}
|
||||
#else
|
||||
GLRenderer->mVBO->OutputResized(Width, Height);
|
||||
#endif
|
||||
|
||||
for (int n = 0; n < gl_hardware_buffers; n++) {
|
||||
GLRenderer->mVBOBuff[n]->OutputResized(Width, Height);
|
||||
}
|
||||
}
|
||||
|
||||
GLRenderer->SetOutputViewport(nullptr);
|
||||
|
@ -218,22 +208,22 @@ void OpenGLFrameBuffer::Update()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
CVAR(Bool, gl_finishbeforeswap, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
CVAR(Bool, gl_finish, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
CVAR(Bool, gl_sync, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
extern int camtexcount;
|
||||
|
||||
void OpenGLFrameBuffer::Swap()
|
||||
{
|
||||
bool swapbefore = gl_finishbeforeswap && camtexcount == 0;
|
||||
Finish.Reset();
|
||||
Finish.Clock();
|
||||
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
GLRenderer->GPUDropSync();
|
||||
#else
|
||||
if (swapbefore) glFinish();
|
||||
SwapBuffers();
|
||||
if (!swapbefore) glFinish();
|
||||
#endif
|
||||
if (gl_sync) {
|
||||
GLRenderer->GPUDropSync();
|
||||
}
|
||||
else if (gl_finish)
|
||||
{
|
||||
glFinish(); // Don't appear to need this on the Quest 2
|
||||
}
|
||||
|
||||
gl_RenderState.SetVertexBuffer(NULL);
|
||||
|
||||
|
|
|
@ -28,11 +28,7 @@ class OpenGLFrameBuffer : public NoSDLGLFB
|
|||
public:
|
||||
|
||||
explicit OpenGLFrameBuffer() {}
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, int nbrHwBuffers) ;
|
||||
#else
|
||||
OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) ;
|
||||
#endif
|
||||
~OpenGLFrameBuffer();
|
||||
|
||||
void InitializeState();
|
||||
|
|
|
@ -81,6 +81,8 @@ EXTERN_CVAR (Int, vid_displaybits)
|
|||
EXTERN_CVAR (Int, vid_renderer)
|
||||
EXTERN_CVAR (Int, vid_maxfps)
|
||||
EXTERN_CVAR (Bool, cl_capfps)
|
||||
EXTERN_CVAR (Int, gl_hardware_buffers)
|
||||
|
||||
|
||||
DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fullscreen);
|
||||
|
||||
|
@ -145,6 +147,8 @@ bool NoSDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
|
|||
return false;
|
||||
}
|
||||
|
||||
extern "C" int QzDoom_GetRefresh();
|
||||
|
||||
DFrameBuffer *NoSDLGLVideo::CreateFrameBuffer (int width, int height, bool bgra, bool fullscreen, DFrameBuffer *old)
|
||||
{
|
||||
static int retry = 0;
|
||||
|
@ -164,14 +168,9 @@ DFrameBuffer *NoSDLGLVideo::CreateFrameBuffer (int width, int height, bool bgra,
|
|||
}
|
||||
|
||||
NoSDLBaseFB *fb;
|
||||
const char *hwBuffers = Args->CheckValue("-hwbuffers");
|
||||
int buffers = 4;
|
||||
if (hwBuffers)
|
||||
{
|
||||
buffers = atoi(hwBuffers);
|
||||
}
|
||||
Printf("HW buffers = %d\n", buffers);
|
||||
fb = new OpenGLFrameBuffer(0, width, height, 32, 72, true, buffers);
|
||||
|
||||
Printf("HW buffers = %d\n", (int)gl_hardware_buffers);
|
||||
fb = new OpenGLFrameBuffer(0, width, height, 32, QzDoom_GetRefresh(), true);
|
||||
|
||||
retry = 0;
|
||||
return fb;
|
||||
|
|
|
@ -1091,21 +1091,14 @@ public:
|
|||
};
|
||||
|
||||
int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
double vboheight[MAX_HW_BUFFERS][2]; // Last calculated height for the 2 planes of this actual sector
|
||||
#else
|
||||
double vboheight[2]; // Last calculated height for the 2 planes of this actual sector
|
||||
#endif
|
||||
double _vboheight[MAX_HW_BUFFERS][2]; // Last calculated height for the 2 planes of this actual sector
|
||||
int vbocount[2]; // Total count of vertices belonging to this sector's planes
|
||||
|
||||
float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; }
|
||||
#ifdef USE_GL_HW_BUFFERS
|
||||
bool VBOHeightcheck(int buffer,int pos) const { return vboheight[buffer][pos] == GetPlaneTexZ(pos); }
|
||||
bool VBOHeightcheck(int buffer,int pos) const { return _vboheight[buffer][pos] == GetPlaneTexZ(pos); }
|
||||
#define VBOHeightcheck(X) VBOHeightcheck(GLRenderer->VtxBuff,X)
|
||||
#define vboheight vboheight[GLRenderer->VtxBuff]
|
||||
#else
|
||||
bool VBOHeightcheck(int pos) const { return vboheight[pos] == GetPlaneTexZ(pos); }
|
||||
#endif
|
||||
#define vboheight _vboheight[GLRenderer->VtxBuff]
|
||||
|
||||
FPortal *GetGLPortal(int plane) { return portals[plane]; }
|
||||
|
||||
enum
|
||||
|
|
|
@ -41,7 +41,7 @@ const char *GetVersionString();
|
|||
|
||||
/** Lots of different version numbers **/
|
||||
|
||||
#define VERSIONSTR "DrBeef's QuestZDoom-1.1.4 (LZDoom 3.85)"
|
||||
#define VERSIONSTR "** 1.1.6-test_build_3 **"
|
||||
|
||||
// The version as seen in the Windows resource
|
||||
#define RC_FILEVERSION 3,85,0
|
||||
|
|
Loading…
Reference in a new issue