This commit is contained in:
Rachael Alexanderson 2017-05-30 12:43:14 -04:00
commit e1a2de4989
5 changed files with 64 additions and 4 deletions

View file

@ -50,6 +50,7 @@
#include "gl/data/gl_data.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/scene/gl_drawinfo.h"
#include "gl/scene/gl_portal.h"
#include "gl/shaders/gl_shader.h"
#include "gl/shaders/gl_ambientshader.h"
#include "gl/shaders/gl_bloomshader.h"
@ -184,10 +185,14 @@ void FGLRenderer::Initialize(int width, int height)
mShaderManager = new FShaderManager;
mSamplerManager = new FSamplerManager;
gl_LoadModels();
GLPortal::Initialize();
}
FGLRenderer::~FGLRenderer()
{
GLPortal::Shutdown();
gl_FlushModels();
AActor::DeleteAllAttachedLights();
FMaterial::FlushAll();

View file

@ -205,7 +205,6 @@ bool GLPortal::Start(bool usestencil, bool doquery)
else if (gl_noquery) doquery = false;
// If occlusion query is supported let's use it to avoid rendering portals that aren't visible
if (!QueryObject && doquery) glGenQueries(1, &QueryObject);
if (QueryObject)
{
glBeginQuery(GL_SAMPLES_PASSED, QueryObject);
@ -1264,6 +1263,21 @@ void GLEEHorizonPortal::DrawContents()
}
void GLPortal::Initialize()
{
assert(0 == QueryObject);
glGenQueries(1, &QueryObject);
}
void GLPortal::Shutdown()
{
if (0 != QueryObject)
{
glDeleteQueries(1, &QueryObject);
QueryObject = 0;
}
}
const char *GLSkyPortal::GetName() { return "Sky"; }
const char *GLSkyboxPortal::GetName() { return "Skybox"; }
const char *GLSectorStackPortal::GetName() { return "Sectorstack"; }

View file

@ -177,6 +177,9 @@ public:
static bool RenderFirstSkyPortal(int recursion);
static void EndFrame();
static GLPortal * FindPortal(const void * src);
static void Initialize();
static void Shutdown();
};
struct GLLinePortal : public GLPortal

View file

@ -101,7 +101,7 @@ void ThrowVMException(VMException *x);
}
#define GETADDR(a,o,x) \
if (a == NULL) { ThrowAbortException(x, nullptr); } \
if (a == NULL) { ThrowAbortException(x, nullptr); return 0; } \
ptr = (VM_SBYTE *)a + o
#ifdef NDEBUG

View file

@ -139,14 +139,30 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
NEXTOP;
OP(CLSS):
{
ASSERTA(a); ASSERTA(B);
reg.a[a] = ((DObject*)reg.a[B])->GetClass(); // I wish this could be done without a special opcode but there's really no good way to guarantee initialization of the Class pointer...
DObject *o = (DObject*)reg.a[B];
if (o == nullptr)
{
ThrowAbortException(X_READ_NIL, nullptr);
return 0;
}
reg.a[a] = o->GetClass();
NEXTOP;
}
OP(META):
{
ASSERTA(a); ASSERTA(B);
reg.a[a] = ((DObject*)reg.a[B])->GetClass()->Meta; // I wish this could be done without a special opcode but there's really no good way to guarantee initialization of the Class pointer...
DObject *o = (DObject*)reg.a[B];
if (o == nullptr)
{
ThrowAbortException(X_READ_NIL, nullptr);
return 0;
}
reg.a[a] = o->GetClass()->Meta;
NEXTOP;
}
OP(LB):
ASSERTD(a); ASSERTA(B); ASSERTKD(C);
@ -815,15 +831,18 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (cls->ConstructNative == nullptr)
{
ThrowAbortException(X_OTHER, "Class %s requires native construction", cls->TypeName.GetChars());
return 0;
}
if (cls->bAbstract)
{
ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s", cls->TypeName.GetChars());
return 0;
}
// Creating actors here must be outright prohibited,
if (cls->IsDescendantOf(NAME_Actor))
{
ThrowAbortException(X_OTHER, "Cannot create actors with 'new'");
return 0;
}
// [ZZ] validate readonly and between scope construction
c = C;
@ -878,6 +897,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[a] >= BC)
{
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Max.index = %u, current index = %u\n", BC, reg.d[a]);
return 0;
}
NEXTOP;
@ -886,6 +906,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[a] >= konstd[BC])
{
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Max.index = %u, current index = %u\n", konstd[BC], reg.d[a]);
return 0;
}
NEXTOP;
@ -894,6 +915,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[a] >= reg.d[B])
{
ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Max.index = %u, current index = %u\n", reg.d[B], reg.d[a]);
return 0;
}
NEXTOP;
@ -1041,6 +1063,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = reg.d[B] / reg.d[C];
NEXTOP;
@ -1049,6 +1072,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (konstd[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = reg.d[B] / konstd[C];
NEXTOP;
@ -1057,6 +1081,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = konstd[B] / reg.d[C];
NEXTOP;
@ -1066,6 +1091,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = int((unsigned)reg.d[B] / (unsigned)reg.d[C]);
NEXTOP;
@ -1074,6 +1100,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (konstd[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = int((unsigned)reg.d[B] / (unsigned)konstd[C]);
NEXTOP;
@ -1082,6 +1109,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = int((unsigned)konstd[B] / (unsigned)reg.d[C]);
NEXTOP;
@ -1091,6 +1119,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = reg.d[B] % reg.d[C];
NEXTOP;
@ -1099,6 +1128,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (konstd[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = reg.d[B] % konstd[C];
NEXTOP;
@ -1107,6 +1137,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = konstd[B] % reg.d[C];
NEXTOP;
@ -1116,6 +1147,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = int((unsigned)reg.d[B] % (unsigned)reg.d[C]);
NEXTOP;
@ -1124,6 +1156,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (konstd[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = int((unsigned)reg.d[B] % (unsigned)konstd[C]);
NEXTOP;
@ -1132,6 +1165,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.d[C] == 0)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.d[a] = int((unsigned)konstd[B] % (unsigned)reg.d[C]);
NEXTOP;
@ -1288,6 +1322,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.f[C] == 0.)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.f[a] = reg.f[B] / reg.f[C];
NEXTOP;
@ -1296,6 +1331,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (konstf[C] == 0.)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.f[a] = reg.f[B] / konstf[C];
NEXTOP;
@ -1304,6 +1340,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (reg.f[C] == 0.)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.f[a] = konstf[B] / reg.f[C];
NEXTOP;
@ -1315,6 +1352,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
if (fc == 0.)
{
ThrowAbortException(X_DIVISION_BY_ZERO, nullptr);
return 0;
}
reg.f[a] = luai_nummod(fb, fc);
NEXTOP;