diff --git a/scripts/initLayers.py b/scripts/initLayers.py index ba55f8f..e4c0bf0 100755 --- a/scripts/initLayers.py +++ b/scripts/initLayers.py @@ -85,7 +85,11 @@ void InitLayers( RegalContext * ctx ) { out.write( " layer = constr( ctx );\n" ) out.write( " bool success = layer->Initialize( \"%s\" );\n" % instInf ) out.write( " if( success ) {\n" ) + out.write( " Info(\"%s initialization succeeded.\");\n" % c ) out.write( " ctx->layer.push_back( layer );\n" ) + out.write( " } else {\n" ) + out.write( " Info(\"%s initialization failed.\");\n" % c ) + out.write( " delete layer;\n" ) out.write( " }\n" ) out.write( " }\n" ) diff --git a/scripts/regal/RegalDispatch.py b/scripts/regal/RegalDispatch.py index a119da9..ae377b7 100755 --- a/scripts/regal/RegalDispatch.py +++ b/scripts/regal/RegalDispatch.py @@ -199,6 +199,7 @@ REGAL_NAMESPACE_BEGIN struct Layer { Layer( RegalContext * context ) : ctx( context ) {} + virtual ~Layer() {} RegalContext * GetContext() { return ctx; } virtual std::string GetName() const = 0; virtual bool Initialize( const std::string & instanceInfo ) = 0; diff --git a/src/regal/RegalDispatch.h b/src/regal/RegalDispatch.h index 1ee184f..de4606a 100644 --- a/src/regal/RegalDispatch.h +++ b/src/regal/RegalDispatch.h @@ -55,6 +55,7 @@ REGAL_NAMESPACE_BEGIN struct Layer { Layer( RegalContext * context ) : ctx( context ) {} + virtual ~Layer() {} RegalContext * GetContext() { return ctx; } virtual std::string GetName() const = 0; virtual bool Initialize( const std::string & instanceInfo ) = 0; diff --git a/src/regal/RegalInitLayers.cpp b/src/regal/RegalInitLayers.cpp index 0802eca..d0d51cc 100644 --- a/src/regal/RegalInitLayers.cpp +++ b/src/regal/RegalInitLayers.cpp @@ -65,7 +65,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createLog initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createLog initialization failed."); + delete layer; } } constr = createFilt; @@ -73,7 +77,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createFilt initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createFilt initialization failed."); + delete layer; } } constr = createTexC; @@ -81,7 +89,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createTexC initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createTexC initialization failed."); + delete layer; } } constr = createVao; @@ -89,7 +101,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createVao initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createVao initialization failed."); + delete layer; } } constr = createDsa; @@ -97,7 +113,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createDsa initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createDsa initialization failed."); + delete layer; } } constr = createSo; @@ -105,7 +125,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createSo initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createSo initialization failed."); + delete layer; } } constr = createQuads; @@ -113,7 +137,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createQuads initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createQuads initialization failed."); + delete layer; } } constr = createIff; @@ -121,7 +149,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createIff initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createIff initialization failed."); + delete layer; } } constr = createTexSto; @@ -129,7 +161,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createTexSto initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createTexSto initialization failed."); + delete layer; } } constr = createBaseVertex; @@ -137,7 +173,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createBaseVertex initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createBaseVertex initialization failed."); + delete layer; } } constr = createPpca; @@ -145,7 +185,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createPpca initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createPpca initialization failed."); + delete layer; } } constr = createPpa; @@ -153,7 +197,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createPpa initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createPpa initialization failed."); + delete layer; } } constr = createHint; @@ -161,7 +209,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createHint initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createHint initialization failed."); + delete layer; } } constr = createObj; @@ -169,7 +221,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createObj initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createObj initialization failed."); + delete layer; } } constr = createHttp; @@ -177,7 +233,11 @@ void InitLayers( RegalContext * ctx ) { layer = constr( ctx ); bool success = layer->Initialize( "" ); if( success ) { + Info("createHttp initialization succeeded."); ctx->layer.push_back( layer ); + } else { + Info("createHttp initialization failed."); + delete layer; } } diff --git a/src/regal/layer/bv/BaseVertex.h b/src/regal/layer/bv/BaseVertex.h index bbe3200..5ba5315 100644 --- a/src/regal/layer/bv/BaseVertex.h +++ b/src/regal/layer/bv/BaseVertex.h @@ -77,7 +77,18 @@ namespace Emu { } virtual bool Initialize( const std::string & instanceInfo ) { - ResetInterception(); + RegalContext * ctx = GetContext(); + orig.Initialize( ctx->dispatchGL ); + + bool from_core = ctx->info->gl_version_3_2; + bool from_ext = ctx->info->gl_arb_draw_elements_base_vertex; + bool emulationNeeded = from_core == false && from_ext == false; + + if( emulationNeeded == false ) { + return false; + } + + BaseVertexIntercept( this, ctx->dispatchGL ); return true; } diff --git a/src/regal/layer/error/ErrorProcs.cpp b/src/regal/layer/error/ErrorProcs.cpp index 378f527..7fb36e1 100644 --- a/src/regal/layer/error/ErrorProcs.cpp +++ b/src/regal/layer/error/ErrorProcs.cpp @@ -1,5 +1,5 @@ /* NOTE: Do not edit this file, it is generated by a script: - Err.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . + Export.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . */ /* diff --git a/src/regal/layer/hint/Hint.h b/src/regal/layer/hint/Hint.h index 4df2561..d646f19 100644 --- a/src/regal/layer/hint/Hint.h +++ b/src/regal/layer/hint/Hint.h @@ -88,8 +88,8 @@ struct Hint : public Layer RegalContext * ctx = GetContext(); orig.Initialize( ctx->dispatchGL ); // check whether we can init - bool canInit = true; - if( canInit == false ) { + bool emulationNeeded = ctx->info->es2; + if( emulationNeeded == false ) { return false; } HintIntercept( this, ctx->dispatchGL ); diff --git a/src/regal/layer/http/HttpProcs.cpp b/src/regal/layer/http/HttpProcs.cpp index 2e02eb0..ec0e160 100644 --- a/src/regal/layer/http/HttpProcs.cpp +++ b/src/regal/layer/http/HttpProcs.cpp @@ -1,5 +1,5 @@ /* NOTE: Do not edit this file, it is generated by a script: - H.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . + Export.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . */ /* diff --git a/src/regal/layer/iff/Iff.cpp b/src/regal/layer/iff/Iff.cpp index 54f170f..9bbab44 100644 --- a/src/regal/layer/iff/Iff.cpp +++ b/src/regal/layer/iff/Iff.cpp @@ -3381,6 +3381,14 @@ namespace Emu orig.Initialize( ctx.dispatchGL ); instProcs.Initialize( ctx.dispatchGL ); + bool emulationNeeded = ctx.info->es2 || ctx.info->core; + bool has_glsl = ( ctx.info->gl_version_major >= 2 + || ctx.info->gles_version_major >= 2 ); + bool has_vao = ctx.emuInfo->gl_arb_vertex_array_object; + bool emulationSupported = has_glsl && has_vao; + if( emulationNeeded == false || emulationSupported == false ) { + return false; + } IffIntercept( this, ctx.dispatchGL ); shadowMatrixMode = GL_MODELVIEW; diff --git a/src/regal/layer/loader/LoaderProcs.cpp b/src/regal/layer/loader/LoaderProcs.cpp index 74f26b6..b5ed6de 100644 --- a/src/regal/layer/loader/LoaderProcs.cpp +++ b/src/regal/layer/loader/LoaderProcs.cpp @@ -1,5 +1,5 @@ /* NOTE: Do not edit this file, it is generated by a script: - L.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . + Export.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . */ /* diff --git a/src/regal/layer/log/LogProcs.cpp b/src/regal/layer/log/LogProcs.cpp index ad053ea..bb4bea5 100644 --- a/src/regal/layer/log/LogProcs.cpp +++ b/src/regal/layer/log/LogProcs.cpp @@ -1,5 +1,5 @@ /* NOTE: Do not edit this file, it is generated by a script: - Log.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . + Export.py --api gl 4.4 --api wgl 4.4 --api glx 4.4 --api cgl 1.4 --api egl 1.0 --outdir . */ /* diff --git a/src/regal/layer/ppa/Ppa.h b/src/regal/layer/ppa/Ppa.h index 498f938..eb9144d 100644 --- a/src/regal/layer/ppa/Ppa.h +++ b/src/regal/layer/ppa/Ppa.h @@ -79,6 +79,10 @@ struct Ppa : public Layer, public State::Stencil, State::Depth, State::Polygon, { RegalContext &ctx = *GetContext(); orig.Initialize( ctx.dispatchGL ); + bool emulationNeeded = ctx.info->compat == false; + if( emulationNeeded == false ) { + return false; + } PpaIntercept( this, ctx.dispatchGL ); activeTextureUnit = 0; diff --git a/src/regal/layer/ppca/Ppca.h b/src/regal/layer/ppca/Ppca.h index 13cf0ad..230fc1f 100644 --- a/src/regal/layer/ppca/Ppca.h +++ b/src/regal/layer/ppca/Ppca.h @@ -78,7 +78,13 @@ struct Ppca : public Layer, public ClientState::VertexArray, ClientState::PixelS virtual bool Initialize( const std::string & instanceInfo ) { - ResetInterception(); + RegalContext * ctx = GetContext(); + orig.Initialize( ctx->dispatchGL ); + bool emulationNeeded = ctx->info->es1 || ctx->info->es2 || ctx->info->core; + if( emulationNeeded == false ) { + return false; + } + PpcaIntercept( this, ctx->dispatchGL ); Reset(); return true; } diff --git a/src/regal/layer/quads/Quads.cpp b/src/regal/layer/quads/Quads.cpp index f231e72..4879c14 100644 --- a/src/regal/layer/quads/Quads.cpp +++ b/src/regal/layer/quads/Quads.cpp @@ -102,7 +102,10 @@ namespace Emu RegalContext * ctx = GetContext(); orig.Initialize( ctx->dispatchGL ); // if not supported, return false here - + bool emulationNeeded = ctx->info->es1 || ctx->info->es2 || ctx->info->core; + if( emulationNeeded == false ) { + return false; + } QuadsIntercept( this, ctx->dispatchGL ); elementArrayBuffer = 0; RglGenBuffers( orig, 1, &quadIndexBuffer); diff --git a/src/regal/layer/rect/Rect.h b/src/regal/layer/rect/Rect.h index cfb61f4..68bc2da 100644 --- a/src/regal/layer/rect/Rect.h +++ b/src/regal/layer/rect/Rect.h @@ -89,7 +89,13 @@ namespace Emu { virtual std::string GetName() const { return "rect"; } virtual bool Initialize( const std::string & instanceInfo ) { - ResetInterception(); + RegalContext * ctx = GetContext(); + orig.Initialize( ctx->dispatchGL ); + bool emulationNeeded = ctx->info->es1 || ctx->info->es2 || ctx->info->core; + if( emulationNeeded == false ) { + return false; + } + RectIntercept( this, ctx->dispatchGL ); return true; } diff --git a/src/regal/layer/so/So.h b/src/regal/layer/so/So.h index 0ec2d95..9f0e569 100644 --- a/src/regal/layer/so/So.h +++ b/src/regal/layer/so/So.h @@ -83,7 +83,12 @@ namespace Emu { orig.Initialize( ctx->dispatchGL ); // if not needed or not supported, return false now - + bool from_core = ctx->info->gl_version_3_3 == GL_TRUE || ctx->info->gles_version_major >= 3; + bool from_ext = ctx->info->gl_arb_sampler_objects == GL_TRUE; + bool emulationNeeded = ! ( from_core || from_ext ); + if( emulationNeeded == false ) { + return false; + } SoIntercept( this, ctx->dispatchGL ); activeTextureUnit = 0; nextSamplerObjectId = 1; diff --git a/src/regal/layer/texc/TexC.cpp b/src/regal/layer/texc/TexC.cpp index e3ad99d..9beff74 100644 --- a/src/regal/layer/texc/TexC.cpp +++ b/src/regal/layer/texc/TexC.cpp @@ -319,6 +319,10 @@ namespace Emu { orig.Initialize( ctx->dispatchGL ); // if not supported or not needed return false here + bool emulationNeeded = ctx->info->es2; + if( emulationNeeded == false ) { + return false; + } TexCIntercept( this, ctx->dispatchGL ); RegalContext * sharingWith = ctx->shareGroup->front(); diff --git a/src/regal/layer/texsto/TexSto.h b/src/regal/layer/texsto/TexSto.h index eb4f0fb..b2b77f8 100644 --- a/src/regal/layer/texsto/TexSto.h +++ b/src/regal/layer/texsto/TexSto.h @@ -66,7 +66,19 @@ namespace Emu { virtual std::string GetName() const { return "texsto"; } bool Initialize( const std::string & instanceInfo ) { - ResetInterception(); + RegalContext * ctx = GetContext(); + orig.Initialize( ctx->dispatchGL ); + TexStoIntercept( this, ctx->dispatchGL ); + + bool from_core = ctx->info->gl_version_4_2; + bool from_ext = ctx->info->gl_arb_texture_storage || ctx->info->gl_ext_texture_storage; + bool emulationNeeded = from_core == false && from_ext == false; + if( emulationNeeded ) { + return false; + } + + TexStoIntercept( this, ctx->dispatchGL ); + return true; } diff --git a/src/regal/layer/vao/Vao.h b/src/regal/layer/vao/Vao.h index 870caee..2467e22 100644 --- a/src/regal/layer/vao/Vao.h +++ b/src/regal/layer/vao/Vao.h @@ -129,8 +129,19 @@ namespace Emu clientActiveTexture = GL_TEXTURE0; orig.Initialize( ctx->dispatchGL ); // if not supported or not needed return false here + + bool from_core = ( ctx->info->gl_version_major >= 3 + || ctx->info->gles_version_major >= 3 ); + bool from_ext = ctx->info->gl_arb_vertex_array_object; + // need to handle the default vao case, which core profile doesn't handle... + bool emulationNeeded = ctx->info->core || ( from_core == false && from_ext == false ); + if( emulationNeeded == false ) { + return false; + } VaoIntercept( this, ctx->dispatchGL ); + ctx->emuInfo->gl_arb_vertex_array_object = GL_TRUE; + max_vertex_attribs = ctx->emuInfo->gl_max_vertex_attribs; RegalAssert( max_vertex_attribs <= REGAL_EMU_MAX_VERTEX_ATTRIBS ); if (max_vertex_attribs > REGAL_EMU_MAX_VERTEX_ATTRIBS)