meta: Don't stray outside the confines of the API specified in the context
Signed-off-by: Paul Berry <stereotype441@gmail.com> Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
8e7b6a69e9
commit
d638da23d2
2 changed files with 65 additions and 43 deletions
|
|
@ -554,8 +554,10 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
|
|||
save->PolygonCull = ctx->Polygon.CullFlag;
|
||||
_mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
_mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE);
|
||||
if (ctx->API == API_OPENGL) {
|
||||
_mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE);
|
||||
}
|
||||
_mesa_set_enable(ctx, GL_CULL_FACE, GL_FALSE);
|
||||
}
|
||||
|
||||
|
|
@ -565,14 +567,14 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
|
|||
}
|
||||
|
||||
if (state & MESA_META_SHADER) {
|
||||
if (ctx->Extensions.ARB_vertex_program) {
|
||||
if (ctx->API == API_OPENGL && ctx->Extensions.ARB_vertex_program) {
|
||||
save->VertexProgramEnabled = ctx->VertexProgram.Enabled;
|
||||
_mesa_reference_vertprog(ctx, &save->VertexProgram,
|
||||
ctx->VertexProgram.Current);
|
||||
_mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE);
|
||||
}
|
||||
|
||||
if (ctx->Extensions.ARB_fragment_program) {
|
||||
if (ctx->API == API_OPENGL && ctx->Extensions.ARB_fragment_program) {
|
||||
save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled;
|
||||
_mesa_reference_fragprog(ctx, &save->FragmentProgram,
|
||||
ctx->FragmentProgram.Current);
|
||||
|
|
@ -608,25 +610,27 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
|
|||
save->EnvMode = ctx->Texture.Unit[0].EnvMode;
|
||||
|
||||
/* Disable all texture units */
|
||||
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
|
||||
save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled;
|
||||
save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled;
|
||||
if (ctx->Texture.Unit[u].Enabled ||
|
||||
ctx->Texture.Unit[u].TexGenEnabled) {
|
||||
_mesa_ActiveTextureARB(GL_TEXTURE0 + u);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE);
|
||||
if (ctx->Extensions.ARB_texture_cube_map)
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
|
||||
if (ctx->Extensions.NV_texture_rectangle)
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE);
|
||||
if (ctx->Extensions.OES_EGL_image_external)
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_EXTERNAL_OES, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
|
||||
if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) {
|
||||
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
|
||||
save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled;
|
||||
save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled;
|
||||
if (ctx->Texture.Unit[u].Enabled ||
|
||||
ctx->Texture.Unit[u].TexGenEnabled) {
|
||||
_mesa_ActiveTextureARB(GL_TEXTURE0 + u);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE);
|
||||
if (ctx->Extensions.ARB_texture_cube_map)
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
|
||||
if (ctx->Extensions.NV_texture_rectangle)
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE);
|
||||
if (ctx->Extensions.OES_EGL_image_external)
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_EXTERNAL_OES, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE);
|
||||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -639,7 +643,9 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
|
|||
/* set defaults for unit[0] */
|
||||
_mesa_ActiveTextureARB(GL_TEXTURE0);
|
||||
_mesa_ClientActiveTextureARB(GL_TEXTURE0);
|
||||
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) {
|
||||
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
}
|
||||
}
|
||||
|
||||
if (state & MESA_META_TRANSFORM) {
|
||||
|
|
@ -770,7 +776,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
|
|||
void
|
||||
_mesa_meta_end(struct gl_context *ctx)
|
||||
{
|
||||
struct save_state *save = &ctx->Meta->Save[--ctx->Meta->SaveStackDepth];
|
||||
struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1];
|
||||
const GLbitfield state = save->SavedState;
|
||||
|
||||
if (state & MESA_META_ALPHA_TEST) {
|
||||
|
|
@ -847,9 +853,11 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||
if (state & MESA_META_RASTERIZATION) {
|
||||
_mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode);
|
||||
_mesa_PolygonMode(GL_BACK, save->BackPolygonMode);
|
||||
_mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple);
|
||||
if (ctx->API == API_OPENGL) {
|
||||
_mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple);
|
||||
_mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth);
|
||||
}
|
||||
_mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, save->PolygonOffset);
|
||||
_mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth);
|
||||
_mesa_set_enable(ctx, GL_CULL_FACE, save->PolygonCull);
|
||||
}
|
||||
|
||||
|
|
@ -860,7 +868,7 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||
}
|
||||
|
||||
if (state & MESA_META_SHADER) {
|
||||
if (ctx->Extensions.ARB_vertex_program) {
|
||||
if (ctx->API == API_OPENGL && ctx->Extensions.ARB_vertex_program) {
|
||||
_mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB,
|
||||
save->VertexProgramEnabled);
|
||||
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
|
||||
|
|
@ -868,7 +876,7 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||
_mesa_reference_vertprog(ctx, &save->VertexProgram, NULL);
|
||||
}
|
||||
|
||||
if (ctx->Extensions.ARB_fragment_program) {
|
||||
if (ctx->API == API_OPENGL && ctx->Extensions.ARB_fragment_program) {
|
||||
_mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB,
|
||||
save->FragmentProgramEnabled);
|
||||
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
|
||||
|
|
@ -901,7 +909,7 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||
|
||||
_mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled);
|
||||
_mesa_ClearStencil(stencil->Clear);
|
||||
if (ctx->Extensions.EXT_stencil_two_side) {
|
||||
if (ctx->API == API_OPENGL && ctx->Extensions.EXT_stencil_two_side) {
|
||||
_mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT,
|
||||
stencil->TestTwoSide);
|
||||
_mesa_ActiveStencilFaceEXT(stencil->ActiveFace
|
||||
|
|
@ -933,7 +941,9 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||
ASSERT(ctx->Texture.CurrentUnit == 0);
|
||||
|
||||
/* restore texenv for unit[0] */
|
||||
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode);
|
||||
if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) {
|
||||
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode);
|
||||
}
|
||||
|
||||
/* restore texture objects for unit[0] only */
|
||||
for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
|
||||
|
|
@ -946,16 +956,18 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||
}
|
||||
|
||||
/* Restore fixed function texture enables, texgen */
|
||||
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
|
||||
if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) {
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
|
||||
ctx->Texture.Unit[u].Enabled = save->TexEnabled[u];
|
||||
}
|
||||
if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) {
|
||||
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
|
||||
if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) {
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
|
||||
ctx->Texture.Unit[u].Enabled = save->TexEnabled[u];
|
||||
}
|
||||
|
||||
if (ctx->Texture.Unit[u].TexGenEnabled != save->TexGenEnabled[u]) {
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
|
||||
ctx->Texture.Unit[u].TexGenEnabled = save->TexGenEnabled[u];
|
||||
}
|
||||
if (ctx->Texture.Unit[u].TexGenEnabled != save->TexGenEnabled[u]) {
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
|
||||
ctx->Texture.Unit[u].TexGenEnabled = save->TexGenEnabled[u];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* restore current unit state */
|
||||
|
|
@ -1053,6 +1065,8 @@ _mesa_meta_end(struct gl_context *ctx)
|
|||
if (save->TransformFeedbackNeedsResume)
|
||||
_mesa_ResumeTransformFeedback();
|
||||
#endif
|
||||
|
||||
ctx->Meta->SaveStackDepth--;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1405,7 +1419,8 @@ blitframebuffer_texture(struct gl_context *ctx,
|
|||
_mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
|
||||
GL_SKIP_DECODE_EXT);
|
||||
}
|
||||
if (ctx->Extensions.EXT_framebuffer_sRGB) {
|
||||
if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_framebuffer_sRGB
|
||||
|| _mesa_is_gles3(ctx)) {
|
||||
_mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE);
|
||||
}
|
||||
|
||||
|
|
@ -3586,7 +3601,8 @@ decompress_texture_image(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
/* No sRGB decode or encode.*/
|
||||
if (ctx->Extensions.EXT_framebuffer_sRGB) {
|
||||
if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_framebuffer_sRGB
|
||||
|| _mesa_is_gles3(ctx)) {
|
||||
_mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "enums.h"
|
||||
#include "api_arrayelt.h"
|
||||
#include "texstate.h"
|
||||
#include "drivers/common/meta.h"
|
||||
|
||||
|
||||
|
||||
|
|
@ -764,8 +765,13 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
|
|||
|
||||
/* GL_ARB_multisample */
|
||||
case GL_MULTISAMPLE_ARB:
|
||||
if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
|
||||
/* Technically speaking, this should not be allowed for OpenGL ES 2.0
|
||||
* or 3.0. However, meta really needs it.
|
||||
*/
|
||||
if (!_mesa_meta_in_progress(ctx) && !_mesa_is_desktop_gl(ctx)
|
||||
&& ctx->API != API_OPENGLES)
|
||||
goto invalid_enum_error;
|
||||
|
||||
if (ctx->Multisample.Enabled == state)
|
||||
return;
|
||||
FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue