Further push/pop attrib emulation support.

Improved multi-threading, shared contexts for GLX.
Updated VC projects.
This commit is contained in:
Nigel Stewart 2013-04-12 23:25:42 -05:00
parent c65dc89bae
commit 2bd2998738
35 changed files with 1055 additions and 446 deletions

View file

@ -76,6 +76,7 @@ REGAL.H += src/regal/RegalLog.h
REGAL.H += src/regal/RegalLookup.h
REGAL.H += src/regal/RegalMarker.h
REGAL.H += src/regal/RegalTexC.h
REGAL.H += src/regal/RegalTexSto.h
REGAL.H += src/regal/RegalMac.h
REGAL.H += src/regal/RegalObj.h
REGAL.H += src/regal/RegalPpa.h

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -331,6 +331,7 @@
<ItemGroup>
<None Include="..\..\..\..\src\regal\Regal.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View file

@ -311,6 +311,7 @@
<ClInclude Include="..\..\..\..\src\regal\RegalSystem.h" />
<ClCompile Include="..\..\..\..\src\regal\RegalTexC.cpp" />
<ClInclude Include="..\..\..\..\src\regal\RegalTexC.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalTexSto.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalThread.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalTimer.h" />
<ClCompile Include="..\..\..\..\src\regal\RegalToken.cpp" />

View file

@ -311,6 +311,7 @@
<ClInclude Include="..\..\..\..\src\regal\RegalSystem.h" />
<ClCompile Include="..\..\..\..\src\regal\RegalTexC.cpp" />
<ClInclude Include="..\..\..\..\src\regal\RegalTexC.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalTexSto.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalThread.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalTimer.h" />
<ClCompile Include="..\..\..\..\src\regal\RegalToken.cpp" />

View file

@ -311,6 +311,7 @@
<ClInclude Include="..\..\..\..\src\regal\RegalSystem.h" />
<ClCompile Include="..\..\..\..\src\regal\RegalTexC.cpp" />
<ClInclude Include="..\..\..\..\src\regal\RegalTexC.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalTexSto.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalThread.h" />
<ClInclude Include="..\..\..\..\src\regal\RegalTimer.h" />
<ClCompile Include="..\..\..\..\src\regal\RegalToken.cpp" />

View file

@ -98,5 +98,9 @@ ppaFormulae = {
'entries' : [ 'glMinSampleShading' ],
'prefix' : [ '_context->ppa->glMinSampleShading( ${arg0plus} );', ],
},
'TrackMapGrid' : {
'entries' : [ 'glMapGrid(1|2)(f|d)' ],
'prefix' : [ '_context->ppa->glMapGrid${m1}( ${arg0plus} );', ],
},
}

View file

@ -117,6 +117,7 @@ struct RegalContext
~RegalContext();
void Init();
void Cleanup();
// If profile is forced at build-time, no need to check runtime flag
@ -269,10 +270,13 @@ RegalContext::Init()
RegalAssert(!initialized);
info = new ContextInfo();
RegalAssert(this);
RegalAssert(info);
info->init(*this);
if (!info)
{
info = new ContextInfo();
RegalAssert(info);
info->init(*this);
}
${MEMBER_INIT}
@ -298,7 +302,7 @@ ${EMU_MEMBER_INIT}
#endif
#if REGAL_CODE
if (Config::enableCode)
if (Config::enableCode && !codeSource && !codeHeader)
{
if (Config::codeSourceFile.length())
{
@ -321,6 +325,7 @@ ${EMU_MEMBER_INIT}
initialized = true;
}
// Note that Cleanup() may or may not have been called prior to destruction
RegalContext::~RegalContext()
{
Internal("RegalContext::~RegalContext","()");
@ -332,7 +337,7 @@ RegalContext::~RegalContext()
delete info;
${MEMBER_CLEANUP}
#if REGAL_EMULATION
${EMU_MEMBER_CLEANUP}#endif
${EMU_MEMBER_DESTRUCT}#endif
#if REGAL_CODE
if (codeSource)
@ -343,6 +348,21 @@ ${EMU_MEMBER_CLEANUP}#endif
#endif
}
// Called prior to deletion, if this context is still set for this thread.
// Need to:
// 1) clean up GL state we've modified
// 2) leave the RegalContext in a state where Init() could be called again
void
RegalContext::Cleanup()
{
Internal("RegalContext::Cleanup","()");
#if REGAL_EMULATION
${EMU_MEMBER_CLEANUP}#endif
initialized = false;
}
bool
RegalContext::groupInitialized() const
{
@ -436,20 +456,22 @@ def generateContextSource(apis, args):
emuMemberConstruct = ''
emuMemberInit = ''
emuMemberCleanup = ''
emuMemberDestruct = ''
for i in emuRegal:
if i['include']:
includes += '#include "%s"\n' % i['include']
if i['member']:
memberConstruct += ' %s(NULL),\n' % ( i['member'] )
memberInit += ' %s = new %s;\n'%(i['member'],i['type'])
memberInit += indent(wrapCIf('!%s' % i['member'],'%s = new %s;\n'%(i['member'],i['type'])),' ')
memberCleanup += indent(wrapIf(i['ifdef'],'delete %s;\n' % i['member']),' ')
emuMemberConstruct += ' emuLevel(0),\n'
emuMemberInit += ' // emu\n'
emuMemberInit += ' emuLevel = %d;\n' % ( len( emu ) - 1 )
emuMemberCleanup += ' // emu\n'
emuMemberCleanup += ' // emu\n'
emuMemberDestruct += ' // emu\n'
for i in range( len( emu ) - 1 ) :
if emu[i]['member']:
@ -459,7 +481,14 @@ def generateContextSource(apis, args):
if emu[i]['include']:
emuIncludes += '#include "%s"\n' % emu[i]['include']
if emu[i]['member']:
emuMemberCleanup += indent(wrapIf(emu[i]['ifdef'],'delete %s;\n' % emu[i]['member']),' ')
emuMemberDestruct += indent(wrapIf(emu[i]['ifdef'],'delete %s;\n' % emu[i]['member']),' ')
cleanup = ''
cleanup += 'emuLevel = %d;\n' % ( int(emu[i]['level']) - 1)
cleanup += '%s->Cleanup(*this);\n' % emu[i]['member']
cleanup += 'delete %s;\n' % emu[i]['member']
cleanup += '%s = NULL;\n' % emu[i]['member']
emuMemberCleanup += indent(wrapIf(emu[i]['ifdef'],wrapCIf(emu[i]['member'],cleanup)),' ')
revi = len( emu ) - 2 - i;
if emu[revi]['member']:
init = ''
@ -497,5 +526,6 @@ def generateContextSource(apis, args):
substitute['EMU_MEMBER_CONSTRUCT'] = emuMemberConstruct
substitute['EMU_MEMBER_INIT'] = emuMemberInit
substitute['EMU_MEMBER_CLEANUP'] = emuMemberCleanup
substitute['EMU_MEMBER_DESTRUCT'] = emuMemberDestruct
outputCode( '%s/RegalContext.cpp' % args.srcdir, contextSourceTemplate.substitute(substitute))

View file

@ -84,6 +84,9 @@ namespace Token {
std::string GLpushAttribToString(GLbitfield v)
{
if (v == GL_ALL_ATTRIB_BITS)
return std::string("GL_ALL_ATTRIB_BITS");
const GLbitfield other = v & ~(GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_EVAL_BIT | GL_FOG_BIT | GL_HINT_BIT | GL_LIGHTING_BIT | GL_LINE_BIT | GL_LIST_BIT | GL_MULTISAMPLE_BIT | GL_PIXEL_MODE_BIT | GL_POINT_BIT | GL_POLYGON_BIT | GL_POLYGON_STIPPLE_BIT | GL_SCISSOR_BIT | GL_STENCIL_BUFFER_BIT | GL_TEXTURE_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
string_list<std::string> tmp;
@ -92,7 +95,6 @@ namespace Token {
if (v & GL_CURRENT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_CURRENT_BIT"; }
if (v & GL_DEPTH_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_DEPTH_BUFFER_BIT"; }
if (v & GL_ENABLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_ENABLE_BIT"; }
if (v & GL_ENABLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_ENABLE_BIT"; }
if (v & GL_EVAL_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_EVAL_BIT"; }
if (v & GL_FOG_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_FOG_BIT"; }
if (v & GL_HINT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_HINT_BIT"; }

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -50,13 +50,18 @@ REGAL_NAMESPACE_BEGIN
namespace Emu {
struct Bin : public RegalEmu
struct Bin
{
void Init( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
void Cleanup( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
void ShaderBinary( RegalContext * ctx, GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void * binary, GLsizei length)
{
DispatchTable & tbl = ctx->dispatcher.emulation;

View file

@ -138,13 +138,22 @@ RegalContext::Init()
RegalAssert(!initialized);
info = new ContextInfo();
RegalAssert(this);
RegalAssert(info);
info->init(*this);
if (!info)
{
info = new ContextInfo();
RegalAssert(info);
info->init(*this);
}
marker = new Marker;
frame = new Frame;
if (!marker)
{
marker = new Marker;
}
if (!frame)
{
frame = new Frame;
}
#if REGAL_EMULATION
#if !REGAL_FORCE_EMULATION
@ -275,7 +284,7 @@ RegalContext::Init()
#endif
#if REGAL_CODE
if (Config::enableCode)
if (Config::enableCode && !codeSource && !codeHeader)
{
if (Config::codeSourceFile.length())
{
@ -298,6 +307,7 @@ RegalContext::Init()
initialized = true;
}
// Note that Cleanup() may or may not have been called prior to destruction
RegalContext::~RegalContext()
{
Internal("RegalContext::~RegalContext","()");
@ -359,6 +369,130 @@ RegalContext::~RegalContext()
#endif
}
// Called prior to deletion, if this context is still set for this thread.
// Need to:
// 1) clean up GL state we've modified
// 2) leave the RegalContext in a state where Init() could be called again
void
RegalContext::Cleanup()
{
Internal("RegalContext::Cleanup","()");
#if REGAL_EMULATION
// emu
#if REGAL_EMU_OBJ
if (obj)
{
emuLevel = 11;
obj->Cleanup(*this);
delete obj;
obj = NULL;
}
#endif /* REGAL_EMU_OBJ */
#if REGAL_EMU_PPA
if (ppa)
{
emuLevel = 10;
ppa->Cleanup(*this);
delete ppa;
ppa = NULL;
}
#endif /* REGAL_EMU_PPA */
#if REGAL_EMU_PPCA
if (ppca)
{
emuLevel = 9;
ppca->Cleanup(*this);
delete ppca;
ppca = NULL;
}
#endif /* REGAL_EMU_PPCA */
#if REGAL_EMU_BIN
if (bin)
{
emuLevel = 8;
bin->Cleanup(*this);
delete bin;
bin = NULL;
}
#endif /* REGAL_EMU_BIN */
#if REGAL_EMU_XFER
if (xfer)
{
emuLevel = 7;
xfer->Cleanup(*this);
delete xfer;
xfer = NULL;
}
#endif /* REGAL_EMU_XFER */
#if REGAL_EMU_DSA
if (dsa)
{
emuLevel = 6;
dsa->Cleanup(*this);
delete dsa;
dsa = NULL;
}
#endif /* REGAL_EMU_DSA */
#if REGAL_EMU_TEXSTO
if (texsto)
{
emuLevel = 5;
texsto->Cleanup(*this);
delete texsto;
texsto = NULL;
}
#endif /* REGAL_EMU_TEXSTO */
#if REGAL_EMU_IFF
if (iff)
{
emuLevel = 4;
iff->Cleanup(*this);
delete iff;
iff = NULL;
}
#endif /* REGAL_EMU_IFF */
#if REGAL_EMU_SO
if (so)
{
emuLevel = 3;
so->Cleanup(*this);
delete so;
so = NULL;
}
#endif /* REGAL_EMU_SO */
#if REGAL_EMU_VAO
if (vao)
{
emuLevel = 2;
vao->Cleanup(*this);
delete vao;
vao = NULL;
}
#endif /* REGAL_EMU_VAO */
#if REGAL_EMU_TEXC
if (texc)
{
emuLevel = 1;
texc->Cleanup(*this);
delete texc;
texc = NULL;
}
#endif /* REGAL_EMU_TEXC */
#if REGAL_EMU_FILTER
if (filt)
{
emuLevel = 0;
filt->Cleanup(*this);
delete filt;
filt = NULL;
}
#endif /* REGAL_EMU_FILTER */
#endif
initialized = false;
}
bool
RegalContext::groupInitialized() const
{

View file

@ -87,6 +87,7 @@ struct RegalContext
~RegalContext();
void Init();
void Cleanup();
// If profile is forced at build-time, no need to check runtime flag

View file

@ -7254,6 +7254,14 @@ static void REGAL_CALL emu_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2)
{
case 12 :
case 11 :
#if REGAL_EMU_PPA
if (_context->ppa)
{
Push<int> pushLevel(_context->emuLevel);
_context->emuLevel = 10;
_context->ppa->glMapGrid1( un, u1, u2 );
}
#endif
case 10 :
case 9 :
case 8 :
@ -7324,6 +7332,14 @@ static void REGAL_CALL emu_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2)
{
case 12 :
case 11 :
#if REGAL_EMU_PPA
if (_context->ppa)
{
Push<int> pushLevel(_context->emuLevel);
_context->emuLevel = 10;
_context->ppa->glMapGrid1( un, u1, u2 );
}
#endif
case 10 :
case 9 :
case 8 :
@ -7394,6 +7410,14 @@ static void REGAL_CALL emu_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint
{
case 12 :
case 11 :
#if REGAL_EMU_PPA
if (_context->ppa)
{
Push<int> pushLevel(_context->emuLevel);
_context->emuLevel = 10;
_context->ppa->glMapGrid2( un, u1, u2, vn, v1, v2 );
}
#endif
case 10 :
case 9 :
case 8 :
@ -7464,6 +7488,14 @@ static void REGAL_CALL emu_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint v
{
case 12 :
case 11 :
#if REGAL_EMU_PPA
if (_context->ppa)
{
Push<int> pushLevel(_context->emuLevel);
_context->emuLevel = 10;
_context->ppa->glMapGrid2( un, u1, u2, vn, v1, v2 );
}
#endif
case 10 :
case 9 :
case 8 :

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -59,7 +59,7 @@ template<> inline void DsaGetv( DispatchTable & tbl, GLenum pname, GLfloat * par
template<> inline void DsaGetv( DispatchTable & tbl, GLenum pname, GLdouble * params ) { tbl.glGetDoublev( pname, params ); }
struct Dsa : public RegalEmu
struct Dsa
{
int callDepth;
struct Cache {
@ -118,6 +118,11 @@ struct Dsa : public RegalEmu
dsa.renderbufferTarget = REGAL_DSA_INVALID;
}
void Cleanup( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
void Restore( RegalContext * ctx ) {
RestoreMatrixMode( ctx );
RestoreGlslProgram( ctx );

View file

@ -58,69 +58,6 @@ REGAL_NAMESPACE_BEGIN
#define REGAL_EMU_MAX_TEXTURE_UNITS 32
#endif
#ifndef REGAL_FIXED_FUNCTION_MAX_CLIP_DISTANCES
#define REGAL_FIXED_FUNCTION_MAX_CLIP_DISTANCES 8
#endif
#ifndef REGAL_MAX_VIEWPORTS
#define REGAL_MAX_VIEWPORTS 16
#endif
#ifndef REGAL_MAX_DRAW_BUFFERS
#define REGAL_MAX_DRAW_BUFFERS 8
#endif
struct Float4
{
Float4()
: x(0.f),
y(0.f),
z(0.f),
w(1.f)
{
}
Float4( const GLfloat X, const GLfloat Y, const GLfloat Z, const GLfloat W )
: x(X),
y(Y),
z(Z),
w(W)
{
}
Float4( const GLdouble X, const GLdouble Y, const GLdouble Z, const GLdouble W )
: x(static_cast<GLfloat>(X)),
y(static_cast<GLfloat>(Y)),
z(static_cast<GLfloat>(Z)),
w(static_cast<GLfloat>(W))
{
}
Float4( const GLint X, const GLint Y, const GLint Z, const GLint W )
: x(static_cast<GLfloat>(X)),
y(static_cast<GLfloat>(Y)),
z(static_cast<GLfloat>(Z)),
w(static_cast<GLfloat>(W))
{
}
Float4( const GLuint X, const GLuint Y, const GLuint Z, const GLuint W )
: x(static_cast<GLfloat>(X)),
y(static_cast<GLfloat>(Y)),
z(static_cast<GLfloat>(Z)),
w(static_cast<GLfloat>(W))
{
}
GLfloat x, y, z, w;
};
struct RegalEmu
{
};
REGAL_NAMESPACE_END
#endif // REGAL_EMULATION

View file

@ -54,7 +54,7 @@ REGAL_NAMESPACE_BEGIN
namespace Emu {
struct Filt : public RegalEmu
struct Filt
{
Filt()
: filtered(false)
@ -67,6 +67,12 @@ namespace Emu {
UNUSED_PARAMETER(ctx);
}
void
Cleanup(RegalContext &ctx)
{
UNUSED_PARAMETER(ctx);
}
void BindTexture(const RegalContext &ctx, GLenum target, GLuint name );
template <typename T> void Get(const RegalContext &ctx, GLenum pname, T *params)

96
src/regal/RegalFloat4.h Normal file
View file

@ -0,0 +1,96 @@
/*
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
Regal Float4 class.
Cass Everitt
*/
#ifndef __REGAL_FLOAT4_H__
#define __REGAL_FLOAT4_H__
#include "RegalUtil.h"
REGAL_GLOBAL_BEGIN
#include <GL/Regal.h>
REGAL_GLOBAL_END
REGAL_NAMESPACE_BEGIN
struct Float4
{
Float4()
: x(0.f),
y(0.f),
z(0.f),
w(1.f)
{
}
Float4( const GLfloat X, const GLfloat Y, const GLfloat Z, const GLfloat W )
: x(X),
y(Y),
z(Z),
w(W)
{
}
Float4( const GLdouble X, const GLdouble Y, const GLdouble Z, const GLdouble W )
: x(static_cast<GLfloat>(X)),
y(static_cast<GLfloat>(Y)),
z(static_cast<GLfloat>(Z)),
w(static_cast<GLfloat>(W))
{
}
Float4( const GLint X, const GLint Y, const GLint Z, const GLint W )
: x(static_cast<GLfloat>(X)),
y(static_cast<GLfloat>(Y)),
z(static_cast<GLfloat>(Z)),
w(static_cast<GLfloat>(W))
{
}
Float4( const GLuint X, const GLuint Y, const GLuint Z, const GLuint W )
: x(static_cast<GLfloat>(X)),
y(static_cast<GLfloat>(Y)),
z(static_cast<GLfloat>(Z)),
w(static_cast<GLfloat>(W))
{
}
GLfloat x, y, z, w;
};
REGAL_NAMESPACE_END
#endif // ! __REGAL_FLOAT4_H__

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -1430,7 +1430,7 @@ void Program::Shader( RegalContext * ctx, DispatchTable & tbl, GLenum type, GLui
if (!status)
{
std::string log;
if (helper::getInfoLog(log,tbl.call(&tbl.glGetShaderInfoLog),tbl.call(&tbl.glGetShaderiv),pg))
if (helper::getInfoLog(log,tbl.call(&tbl.glGetShaderInfoLog),tbl.call(&tbl.glGetShaderiv),shader))
Internal("Regal::Program::Shader", log);
}
#endif
@ -1527,38 +1527,34 @@ void Program::Uniforms( RegalContext * ctx, DispatchTable & tbl )
}
}
void Iff::Cleanup()
void Iff::Cleanup( RegalContext &ctx )
{
Internal("Regal::Iff::Cleanup","()");
RegalContext *ctx = REGAL_GET_CONTEXT();
if (ctx)
RestoreVao(&ctx);
DispatchTable &tbl = ctx.dispatcher.emulation;
tbl.call(&tbl.glDeleteBuffers)(1, &immVbo);
tbl.call(&tbl.glDeleteBuffers)(1, &immQuadsVbo);
tbl.call(&tbl.glDeleteVertexArrays)(1, &immVao);
for (int i = 0; i < (1 << REGAL_FIXED_FUNCTION_PROGRAM_CACHE_SIZE_BITS); ++i)
{
RestoreVao(ctx);
DispatchTable &tbl = ctx->dispatcher.emulation;
tbl.call(&tbl.glDeleteBuffers)(1, &immVbo);
tbl.call(&tbl.glDeleteBuffers)(1, &immQuadsVbo);
tbl.call(&tbl.glDeleteVertexArrays)(1, &immVao);
for (int i = 0; i < (1 << REGAL_FIXED_FUNCTION_PROGRAM_CACHE_SIZE_BITS); ++i)
const Program &pgm = ffprogs[i];
if (pgm.pg)
{
const Program &pgm = ffprogs[i];
if (pgm.pg)
{
tbl.call(&tbl.glDeleteShader)(pgm.vs);
tbl.call(&tbl.glDeleteShader)(pgm.fs);
tbl.call(&tbl.glDeleteProgram)(pgm.pg);
}
tbl.call(&tbl.glDeleteShader)(pgm.vs);
tbl.call(&tbl.glDeleteShader)(pgm.fs);
tbl.call(&tbl.glDeleteProgram)(pgm.pg);
}
}
tbl.glBindBuffer(GL_ARRAY_BUFFER, 0);
tbl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
for (GLuint i=0; i<ctx->info->maxVertexAttribs; ++i)
{
tbl.glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, NULL);
tbl.glDisableVertexAttribArray(i);
}
tbl.glBindBuffer(GL_ARRAY_BUFFER, 0);
tbl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
for (GLuint i=0; i<ctx.info->maxVertexAttribs; ++i)
{
tbl.glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, NULL);
tbl.glDisableVertexAttribArray(i);
}
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -82,6 +82,7 @@ REGAL_GLOBAL_BEGIN
#include "RegalContext.h"
#include "RegalContextInfo.h"
#include "RegalSharedMap.h"
#include "RegalFloat4.h"
#include "linear.h"
REGAL_GLOBAL_END
@ -339,7 +340,7 @@ struct Iff
{
}
void Cleanup();
void Cleanup( RegalContext &ctx );
// Info
int progcount;

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -487,8 +487,7 @@ Init::destroyContext(RegalSystemContext sysCtx)
if (context==Thread::CurrentContext())
{
if (context->iff)
context->iff->Cleanup();
context->Cleanup();
setContextTLS(NULL);
}

View file

@ -76,6 +76,7 @@ const Object parent[JSON_UNDEFINED+1] =
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE,
@ -88,6 +89,7 @@ const Object parent[JSON_UNDEFINED+1] =
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE,
JSON_REGAL_CONFIG_DISPATCH,
JSON_REGAL_CONFIG_DISPATCH_ENABLE,
JSON_REGAL_CONFIG_DISPATCH_ENABLE,
@ -215,6 +217,7 @@ Parser::onPush(const string &name)
if (name=="ppca" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_PPCA; return; }
if (name=="so" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_SO; return; }
if (name=="texc" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_TEXC; return; }
if (name=="texsto" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_TEXSTO; return; }
if (name=="vao" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_VAO; return; }
if (name=="xfer" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_XFER; return; }
break;
@ -229,6 +232,7 @@ Parser::onPush(const string &name)
if (name=="ppca" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_PPCA; return; }
if (name=="so" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_SO; return; }
if (name=="texc" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_TEXC; return; }
if (name=="texsto" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_TEXSTO; return; }
if (name=="vao" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_VAO; return; }
if (name=="xfer" ) { current = JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_XFER; return; }
break;
@ -366,6 +370,7 @@ Parser::onValue(const bool value)
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_PPCA : { set_json_regal_config_dispatch_emulation_enable_ppca(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_SO : { set_json_regal_config_dispatch_emulation_enable_so(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_TEXC : { set_json_regal_config_dispatch_emulation_enable_texc(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_TEXSTO: { set_json_regal_config_dispatch_emulation_enable_texsto(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_VAO : { set_json_regal_config_dispatch_emulation_enable_vao(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_XFER : { set_json_regal_config_dispatch_emulation_enable_xfer(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_BIN : { set_json_regal_config_dispatch_emulation_force_bin(value); return; }
@ -377,6 +382,7 @@ Parser::onValue(const bool value)
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_PPCA : { set_json_regal_config_dispatch_emulation_force_ppca(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_SO : { set_json_regal_config_dispatch_emulation_force_so(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_TEXC : { set_json_regal_config_dispatch_emulation_force_texc(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_TEXSTO : { set_json_regal_config_dispatch_emulation_force_texsto(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_VAO : { set_json_regal_config_dispatch_emulation_force_vao(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_XFER : { set_json_regal_config_dispatch_emulation_force_xfer(value); return; }
case JSON_REGAL_CONFIG_DISPATCH_ENABLE_CODE : { set_json_regal_config_dispatch_enable_code(value); return; }
@ -514,7 +520,7 @@ jsonslAction(jsonsl_t jsn, jsonsl_action_t action, struct jsonsl_state_st *state
static int
jsonslError(jsonsl_t jsn, jsonsl_error_t err, struct jsonsl_state_st *state, char *at)
{
Parser *parser = reinterpret_cast<Parser *>(jsn->data);
Parser REGAL_UNUSED *parser = reinterpret_cast<Parser *>(jsn->data);
RegalAssert(parser);
UNUSED_PARAMETER(parser);
UNUSED_PARAMETER(err);

View file

@ -70,6 +70,7 @@ enum Object
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_PPCA,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_SO,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_TEXC,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_TEXSTO,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_VAO,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_ENABLE_XFER,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE,
@ -82,6 +83,7 @@ enum Object
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_PPCA,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_SO,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_TEXC,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_TEXSTO,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_VAO,
JSON_REGAL_CONFIG_DISPATCH_EMULATION_FORCE_XFER,
JSON_REGAL_CONFIG_DISPATCH_ENABLE,

View file

@ -8,7 +8,6 @@
#define set_json_regal_config_cache_texturewrite(value) Config::cacheTextureWrite = value
#define set_json_regal_config_configfile(value) Config::configFile = value
#define set_json_regal_config_dispatch_emulation_enable_bin(value) Config::enableEmuBin = value
#define set_json_regal_config_dispatch_emulation_enable_texsto(value) Config::enableEmuTexSto = value
#define set_json_regal_config_dispatch_emulation_enable_dsa(value) Config::enableEmuDsa = value
#define set_json_regal_config_dispatch_emulation_enable_filter(value) Config::enableEmuFilter = value
#define set_json_regal_config_dispatch_emulation_enable_iff(value) Config::enableEmuIff = value
@ -17,10 +16,10 @@
#define set_json_regal_config_dispatch_emulation_enable_ppca(value) Config::enableEmuPpca = value
#define set_json_regal_config_dispatch_emulation_enable_so(value) Config::enableEmuSo = value
#define set_json_regal_config_dispatch_emulation_enable_texc(value) Config::enableEmuTexC = value
#define set_json_regal_config_dispatch_emulation_enable_texsto(value) Config::enableEmuTexSto = value
#define set_json_regal_config_dispatch_emulation_enable_vao(value) Config::enableEmuVao = value
#define set_json_regal_config_dispatch_emulation_enable_xfer(value) Config::enableEmuXfer = value
#define set_json_regal_config_dispatch_emulation_force_bin(value) Config::forceEmuBin = value
#define set_json_regal_config_dispatch_emulation_force_texsto(value) Config::forceEmuTexSto = value
#define set_json_regal_config_dispatch_emulation_force_dsa(value) Config::forceEmuDsa = value
#define set_json_regal_config_dispatch_emulation_force_filter(value) Config::forceEmuFilter = value
#define set_json_regal_config_dispatch_emulation_force_iff(value) Config::forceEmuIff = value
@ -29,6 +28,7 @@
#define set_json_regal_config_dispatch_emulation_force_ppca(value) Config::forceEmuPpca = value
#define set_json_regal_config_dispatch_emulation_force_so(value) Config::forceEmuSo = value
#define set_json_regal_config_dispatch_emulation_force_texc(value) Config::forceEmuTexC = value
#define set_json_regal_config_dispatch_emulation_force_texsto(value) Config::forceEmuTexSto = value
#define set_json_regal_config_dispatch_emulation_force_vao(value) Config::forceEmuVao = value
#define set_json_regal_config_dispatch_emulation_force_xfer(value) Config::forceEmuXfer = value
#define set_json_regal_config_dispatch_enable_code(value) Config::enableCode = value

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -133,7 +133,7 @@ struct NameTranslator
}
};
struct Obj : public RegalEmu
struct Obj
{
NameTranslator bufferNames;
NameTranslator vaoNames;
@ -160,6 +160,11 @@ struct Obj : public RegalEmu
textureNames.del = ctx.dispatcher.emulation.glDeleteTextures;
}
void Cleanup(RegalContext &ctx)
{
UNUSED_PARAMETER(ctx);
}
void BindBuffer(RegalContext &ctx, GLenum target, GLuint bufferBinding)
{
DispatchTable &tbl = ctx.dispatcher.emulation;

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -63,9 +63,9 @@ namespace Emu {
// Work in progress...
struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, State::Transform, State::Hint,
struct Ppa : public State::Stencil, State::Depth, State::Polygon, State::Transform, State::Hint,
State::Enable, State::List, State::AccumBuffer, State::Scissor, State::Viewport, State::Line,
State::Multisample
State::Multisample, State::Eval
{
void Init(RegalContext &ctx)
{
@ -73,12 +73,18 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
activeTextureUnit = 0;
}
void Cleanup(RegalContext &ctx)
{
UNUSED_PARAMETER(ctx);
}
void PushAttrib(RegalContext *ctx, GLbitfield mask)
{
maskStack.push_back(mask);
if (mask&GL_DEPTH_BUFFER_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_DEPTH_BUFFER_BIT ",State::Depth::toString());
depthStack.push_back(State::Depth());
depthStack.back() = *this;
mask &= ~GL_DEPTH_BUFFER_BIT;
@ -86,6 +92,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_STENCIL_BUFFER_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_STENCIL_BUFFER_BIT ",State::Stencil::toString());
stencilStack.push_back(State::Stencil());
stencilStack.back() = *this;
mask &= ~GL_STENCIL_BUFFER_BIT;
@ -93,6 +100,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_POLYGON_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_POLYGON_BIT ",State::Polygon::toString());
polygonStack.push_back(State::Polygon());
polygonStack.back() = *this;
mask &= ~GL_POLYGON_BIT;
@ -100,6 +108,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_TRANSFORM_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_TRANSFORM_BIT ",State::Transform::toString());
transformStack.push_back(State::Transform());
transformStack.back() = *this;
mask &= ~GL_TRANSFORM_BIT;
@ -107,6 +116,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_HINT_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_HINT_BIT ",State::Hint::toString());
hintStack.push_back(State::Hint());
hintStack.back() = *this;
mask &= ~GL_HINT_BIT;
@ -114,6 +124,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_ENABLE_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_ENABLE_BIT ",State::Enable::toString());
enableStack.push_back(State::Enable());
enableStack.back() = *this;
mask &= ~GL_ENABLE_BIT;
@ -121,6 +132,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_LIST_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_LIST_BIT ",State::List::toString());
listStack.push_back(State::List());
listStack.back() = *this;
mask &= ~GL_LIST_BIT;
@ -128,14 +140,17 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_ACCUM_BUFFER_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_ACCUM_BUFFER_BIT ",State::AccumBuffer::toString());
accumBufferStack.push_back(State::AccumBuffer());
accumBufferStack.back() = *this;
mask &= ~GL_ACCUM_BUFFER_BIT;
}
#if 0
if (mask&GL_SCISSOR_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_SCISSOR_BIT ",State::Scissor::toString());
if (!State::Scissor::defined())
State::Scissor::define(ctx->dispatcher.emulation);
scissorStack.push_back(State::Scissor());
scissorStack.back() = *this;
mask &= ~GL_SCISSOR_BIT;
@ -143,14 +158,17 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_VIEWPORT_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_VIEWPORT_BIT ",State::Viewport::toString());
if (!State::Viewport::defined())
State::Viewport::define(ctx->dispatcher.emulation);
viewportStack.push_back(State::Viewport());
viewportStack.back() = *this;
mask &= ~GL_VIEWPORT_BIT;
}
#endif
if (mask&GL_LINE_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_LINE_BIT ",State::Line::toString());
lineStack.push_back(State::Line());
lineStack.back() = *this;
mask &= ~GL_LINE_BIT;
@ -158,11 +176,20 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
if (mask&GL_MULTISAMPLE_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_MULTISAMPLE_BIT ",State::Multisample::toString());
multisampleStack.push_back(State::Multisample());
multisampleStack.back() = *this;
mask &= ~GL_MULTISAMPLE_BIT;
}
if (mask&GL_EVAL_BIT)
{
Internal("Regal::Ppa::PushAttrib GL_EVAL_BIT ",State::Eval::toString());
evalStack.push_back(State::Eval());
evalStack.back() = *this;
mask &= ~GL_EVAL_BIT;
}
// Pass the rest through, for now
RegalAssert(ctx);
@ -309,7 +336,6 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
mask &= ~GL_ACCUM_BUFFER_BIT;
}
#if 0
if (mask&GL_SCISSOR_BIT)
{
RegalAssert(scissorStack.size());
@ -321,6 +347,8 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
// Ideally we'd only set the state that has changed
// since the glPushAttrib() - revisit
if (!State::Scissor::defined())
State::Scissor::define(ctx->dispatcher.emulation);
State::Scissor::set(ctx->dispatcher.emulation);
mask &= ~GL_SCISSOR_BIT;
@ -337,11 +365,12 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
// Ideally we'd only set the state that has changed
// since the glPushAttrib() - revisit
if (!State::Viewport::defined())
State::Viewport::define(ctx->dispatcher.emulation);
State::Viewport::set(ctx->dispatcher.emulation);
mask &= ~GL_VIEWPORT_BIT;
}
#endif
if (mask&GL_LINE_BIT)
{
@ -375,6 +404,22 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
mask &= ~GL_MULTISAMPLE_BIT;
}
if (mask&GL_EVAL_BIT)
{
RegalAssert(evalStack.size());
State::Eval::swap(evalStack.back());
evalStack.pop_back();
Internal("Regal::Ppa::PopAttrib GL_EVAL_BIT ",State::Eval::toString());
// Ideally we'd only set the state that has changed
// since the glPushAttrib() - revisit
State::Eval::set(ctx->dispatcher.emulation);
mask &= ~GL_EVAL_BIT;
}
// Pass the rest through, for now
if (ctx->info->core || ctx->info->es1 || ctx->info->es2)
@ -480,10 +525,24 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
case GL_LIGHTING: State::Enable::lighting = enabled; break;
case GL_LINE_SMOOTH: State::Enable::lineSmooth = State::Line::smooth = enabled; break;
case GL_LINE_STIPPLE: State::Enable::lineStipple = State::Line::stipple = enabled; break;
// TODO: GL_MAP1_x where x is a map type (9 x B) (GL_FALSE)
// TODO: GL_MAP2_x where x is a map type (9 x B) (GL_FALSE)
case GL_MAP1_COLOR_4: State::Enable::map1Color4 = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_INDEX: State::Enable::map1Index = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_NORMAL: State::Enable::map1Normal = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_TEXTURE_COORD_1: State::Enable::map1TextureCoord1 = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_TEXTURE_COORD_2: State::Enable::map1TextureCoord2 = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_TEXTURE_COORD_3: State::Enable::map1TextureCoord3 = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_TEXTURE_COORD_4: State::Enable::map1TextureCoord4 = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_VERTEX_3: State::Enable::map1Vertex3 = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP1_VERTEX_4: State::Enable::map1Vertex4 = State::Eval::map1dEnables[cap-GL_MAP1_COLOR_4] = enabled; break;
case GL_MAP2_COLOR_4: State::Enable::map2Color4 = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_INDEX: State::Enable::map2Index = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_NORMAL: State::Enable::map2Normal = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_TEXTURE_COORD_1: State::Enable::map2TextureCoord1 = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_TEXTURE_COORD_2: State::Enable::map2TextureCoord2 = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_TEXTURE_COORD_3: State::Enable::map2TextureCoord3 = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_TEXTURE_COORD_4: State::Enable::map2TextureCoord4 = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_VERTEX_3: State::Enable::map2Vertex3 = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MAP2_VERTEX_4: State::Enable::map2Vertex4 = State::Eval::map2dEnables[cap-GL_MAP2_COLOR_4] = enabled; break;
case GL_MINMAX: State::Enable::minmax = enabled; break;
case GL_MULTISAMPLE: State::Enable::multisample = enabled; break;
case GL_NORMALIZE: State::Enable::normalize = enabled;
@ -494,7 +553,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
State::Polygon::offsetFill = enabled; break;
case GL_POLYGON_OFFSET_LINE: State::Enable::polygonOffsetLine = enabled;
State::Polygon::offsetLine = enabled; break;
case GL_POLYGON_OFFSET_POINT:State::Enable::polygonOffsetPoint = enabled;
case GL_POLYGON_OFFSET_POINT: State::Enable::polygonOffsetPoint = enabled;
State::Polygon::offsetPoint = enabled; break;
case GL_POLYGON_SMOOTH: State::Enable::polygonSmooth = enabled;
State::Polygon::smoothEnable = enabled; break;
@ -628,6 +687,7 @@ struct Ppa : public RegalEmu, State::Stencil, State::Depth, State::Polygon, Stat
std::vector<State::Viewport> viewportStack;
std::vector<State::Line> lineStack;
std::vector<State::Multisample> multisampleStack;
std::vector<State::Eval> evalStack;
GLuint activeTextureUnit;
};

View file

@ -63,7 +63,7 @@ REGAL_NAMESPACE_BEGIN
#define REGAL_PPC_MAX_TEXTURE_COORDS 16
struct RegalPpc : public RegalEmu {
struct RegalPpc {
struct ClientPixelStoreState {

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -53,6 +53,7 @@ REGAL_GLOBAL_BEGIN
#include <GL/Regal.h>
#include "RegalEmu.h"
#include "RegalContext.h"
REGAL_GLOBAL_END
@ -243,7 +244,7 @@ void Transition( const DispatchTable& dt, const State& current, const State& tar
namespace Emu {
struct Ppca : public RegalEmu {
struct Ppca {
typedef std::vector<GLbitfield> ClientAttribMaskStack;
typedef std::vector<ClientState::PixelStore::State> PixelStoreStateStack;
typedef std::vector<ClientState::VertexArray::State> VertexArrayStateStack;
@ -251,6 +252,10 @@ struct Ppca : public RegalEmu {
Ppca();
void Init( RegalContext &ctx );
void Cleanup( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
void Reset();

View file

@ -59,7 +59,7 @@ REGAL_NAMESPACE_BEGIN
namespace Emu {
struct So : public RegalEmu
struct So
{
So()
: activeTextureUnit(0),
@ -86,6 +86,11 @@ struct So : public RegalEmu
noSamplersInUse = true;
}
void Cleanup( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
static GLenum TT_Index2Enum(GLuint index)
{
if( index > REGAL_NUM_TEXTURE_TARGETS ) {

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -51,6 +51,7 @@ REGAL_GLOBAL_BEGIN
#include <boost/cstdint.hpp>
#include "RegalEmu.h"
#include "RegalContext.h"
#include "RegalSharedMap.h"
REGAL_GLOBAL_END
@ -173,12 +174,17 @@ struct TextureUnitState
};
struct TexC : public RegalEmu
struct TexC
{
TexC();
void Init( RegalContext &ctx );
void Cleanup( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
void Reset_();
TextureState* GetBoundTexture_( GLenum textureUnit, GLenum target );

View file

@ -47,16 +47,18 @@ REGAL_GLOBAL_BEGIN
#include "RegalEmu.h"
#include <utility>
#include <cmath>
#include <set>
#include <algorithm>
REGAL_GLOBAL_END
REGAL_NAMESPACE_BEGIN
namespace Emu {
struct TexSto : public RegalEmu
struct TexSto
{
void Init( RegalContext &ctx )
{
@ -88,7 +90,7 @@ namespace Emu {
for (GLsizei i = 0; i < levels; i++)
{
tbl.call(&tbl.glTexImage1D)( target, i, internalformat, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
width = (GLsizei)std::max(1.0f, (float)floor(width / 2.0f));
width = std::max<GLsizei>(1, width/2);
}
GLint id;
@ -96,6 +98,11 @@ namespace Emu {
immutableTextures.insert( id );
}
void Cleanup(RegalContext &ctx)
{
UNUSED_PARAMETER(ctx);
}
void TextureStorage( RegalContext * ctx, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height )
{
DispatchTable & tbl = ctx->dispatcher.emulation;
@ -112,9 +119,9 @@ namespace Emu {
else
tbl.call(&tbl.glTexImage2D)( target, i, internalformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
width = (GLsizei)std::max(1.0f, (float)floor(width / 2.0f));
width = std::max<GLsizei>(1, width/2);
if (target != GL_TEXTURE_1D_ARRAY)
height = (GLsizei)std::max(1.0f, (float)floor(height / 2.0f));
height = std::max<GLsizei>(1, height/2);
}
GLint id;
@ -128,10 +135,10 @@ namespace Emu {
for (GLsizei i = 0; i < levels; i++)
{
tbl.call(&tbl.glTexImage3D)( target, i, internalformat, width, height, depth, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
width = (GLsizei)std::max(1.0f, (float)floor(width / 2.0f));
height = (GLsizei)std::max(1.0f, (float)floor(height / 2.0f));
width = std::max<GLsizei>(1, width/2);
height = std::max<GLsizei>(1, height/2);
if (target != GL_TEXTURE_2D_ARRAY && target != GL_TEXTURE_CUBE_MAP_ARRAY)
depth = (GLsizei)std::max(1.0f, (float)floor(depth / 2.0f));
depth = std::max<GLsizei>(1, depth/2);
}
GLint id;

View file

@ -113,38 +113,34 @@ namespace Token {
std::string GLpushAttribToString(GLbitfield v)
{
if (v == GL_ALL_ATTRIB_BITS)
return std::string("GL_ALL_ATTRIB_BITS");
const GLbitfield other = v & ~(GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_EVAL_BIT | GL_FOG_BIT | GL_HINT_BIT | GL_LIGHTING_BIT | GL_LINE_BIT | GL_LIST_BIT | GL_MULTISAMPLE_BIT | GL_PIXEL_MODE_BIT | GL_POINT_BIT | GL_POLYGON_BIT | GL_POLYGON_STIPPLE_BIT | GL_SCISSOR_BIT | GL_STENCIL_BUFFER_BIT | GL_TEXTURE_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
string_list<std::string> tmp;
if (v == GL_ALL_ATTRIB_BITS)
{
tmp += "GL_ALL_ATTRIB_BITS";
}
else
{
if (v & GL_ACCUM_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_ACCUM_BUFFER_BIT"; }
if (v & GL_COLOR_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_COLOR_BUFFER_BIT"; }
if (v & GL_CURRENT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_CURRENT_BIT"; }
if (v & GL_DEPTH_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_DEPTH_BUFFER_BIT"; }
if (v & GL_ENABLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_ENABLE_BIT"; }
if (v & GL_EVAL_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_EVAL_BIT"; }
if (v & GL_FOG_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_FOG_BIT"; }
if (v & GL_HINT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_HINT_BIT"; }
if (v & GL_LIGHTING_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_LIGHTING_BIT"; }
if (v & GL_LINE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_LINE_BIT"; }
if (v & GL_LIST_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_LIST_BIT"; }
if (v & GL_MULTISAMPLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_MULTISAMPLE_BIT"; }
if (v & GL_PIXEL_MODE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_PIXEL_MODE_BIT"; }
if (v & GL_POINT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_POINT_BIT"; }
if (v & GL_POLYGON_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_POLYGON_BIT"; }
if (v & GL_POLYGON_STIPPLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_POLYGON_STIPPLE_BIT"; }
if (v & GL_SCISSOR_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_SCISSOR_BIT"; }
if (v & GL_STENCIL_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_STENCIL_BUFFER_BIT"; }
if (v & GL_TEXTURE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_TEXTURE_BIT"; }
if (v & GL_TRANSFORM_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_TRANSFORM_BIT"; }
if (v & GL_VIEWPORT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_VIEWPORT_BIT"; }
if (other || v==0) { if (tmp.size()) tmp += " | "; tmp += size_t(other); }
}
if (v & GL_ACCUM_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_ACCUM_BUFFER_BIT"; }
if (v & GL_COLOR_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_COLOR_BUFFER_BIT"; }
if (v & GL_CURRENT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_CURRENT_BIT"; }
if (v & GL_DEPTH_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_DEPTH_BUFFER_BIT"; }
if (v & GL_ENABLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_ENABLE_BIT"; }
if (v & GL_EVAL_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_EVAL_BIT"; }
if (v & GL_FOG_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_FOG_BIT"; }
if (v & GL_HINT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_HINT_BIT"; }
if (v & GL_LIGHTING_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_LIGHTING_BIT"; }
if (v & GL_LINE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_LINE_BIT"; }
if (v & GL_LIST_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_LIST_BIT"; }
if (v & GL_MULTISAMPLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_MULTISAMPLE_BIT"; }
if (v & GL_PIXEL_MODE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_PIXEL_MODE_BIT"; }
if (v & GL_POINT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_POINT_BIT"; }
if (v & GL_POLYGON_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_POLYGON_BIT"; }
if (v & GL_POLYGON_STIPPLE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_POLYGON_STIPPLE_BIT"; }
if (v & GL_SCISSOR_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_SCISSOR_BIT"; }
if (v & GL_STENCIL_BUFFER_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_STENCIL_BUFFER_BIT"; }
if (v & GL_TEXTURE_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_TEXTURE_BIT"; }
if (v & GL_TRANSFORM_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_TRANSFORM_BIT"; }
if (v & GL_VIEWPORT_BIT) { if (tmp.size()) tmp += " | "; tmp += "GL_VIEWPORT_BIT"; }
if (other || v==0) { if (tmp.size()) tmp += " | "; tmp += size_t(other); }
return tmp.str();
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -45,6 +45,7 @@ REGAL_GLOBAL_BEGIN
#include <string>
#include "RegalEmu.h"
#include "RegalContext.h"
#include "RegalContextInfo.h"
#include "RegalSharedMap.h"
@ -56,7 +57,7 @@ REGAL_NAMESPACE_BEGIN
namespace Emu {
struct Vao : public RegalEmu {
struct Vao {
struct Array {
@ -161,6 +162,11 @@ struct Vao : public RegalEmu {
BindVertexArray( &ctx, 0 );
}
void Cleanup( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
void ShadowBufferBinding( GLenum target, GLuint bufferBinding ) {
RegalAssert( currObject != NULL );
if( target == GL_ARRAY_BUFFER ) {

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2011-2012 NVIDIA Corporation
Copyright (c) 2011-2013 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
@ -57,7 +57,7 @@ REGAL_NAMESPACE_BEGIN
namespace Emu {
struct Xfer : public RegalEmu
struct Xfer
{
void Init( RegalContext &ctx )
{
@ -71,6 +71,11 @@ struct Xfer : public RegalEmu
unpackSkipPixels = 0;
}
void Cleanup( RegalContext &ctx )
{
UNUSED_PARAMETER(ctx);
}
void PixelStore( RegalContext * ctx, GLenum pname, GLint param );
void PixelStore( RegalContext * ctx, GLenum pname, GLfloat param ) {
PixelStore( ctx, pname, GLint( param ) );

View file

@ -166,6 +166,8 @@ TEST( RegalClientStatePixelStore, Transition ) {
RegalGMockInterface mock;
DispatchTable dt;
::memset(&dt,0,sizeof(DispatchTable));
dt._enabled = true;
InitDispatchTableGMock( dt );
State current;
@ -334,6 +336,8 @@ TEST( RegalClientStateVertexArrayFixedState, Transition ) {
RegalGMockInterface mock;
DispatchTable dt;
::memset(&dt,0,sizeof(DispatchTable));
dt._enabled = true;
InitDispatchTableGMock( dt );
State current;
@ -599,6 +603,8 @@ TEST( RegalClientStateVertexArrayGenericState, Transition ) {
RegalGMockInterface mock;
DispatchTable dt;
::memset(&dt,0,sizeof(DispatchTable));
dt._enabled = true;
InitDispatchTableGMock( dt );
State current;
@ -730,6 +736,8 @@ TEST( RegalClientStateVertexArrayState, Transition ) {
RegalGMockInterface mock;
DispatchTable dt;
::memset(&dt,0,sizeof(DispatchTable));
dt._enabled = true;
InitDispatchTableGMock( dt );
State current;

View file

@ -73,6 +73,8 @@ TEST( RegalStateDepth, SetDispatchesCorrectly )
RegalGMockInterface mock;
DispatchTable dt;
::memset(&dt,0,sizeof(DispatchTable));
dt._enabled = true;
InitDispatchTableGMock( dt );
State::Depth depth;
@ -181,6 +183,8 @@ TEST( RegalStateTransform, TransitionSetsStateCorrectly )
RegalGMockInterface mock;
DispatchTable dt;
::memset(&dt,0,sizeof(DispatchTable));
dt._enabled = true;
InitDispatchTableGMock( dt );
// No state difference means no calls are made.