+Mesa 10.5.5 is a bug fix release which fixes bugs found since the 10.5.4 release.
+
+
+Mesa 10.5.5 implements the OpenGL 3.3 API, but the version reported by
+glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
+glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
+Some drivers don't support all the features required in OpenGL 3.3. OpenGL
+3.3 is only available if requested at context creation
+because compatibility contexts are not supported.
+
+
+
+
SHA256 checksums
+
+TBD
+
+
+
+
New features
+
None
+
+
Bug fixes
+
+
This list is likely incomplete.
+
+
+
+
Bug 88521 - GLBenchmark 2.7 TRex renders with artifacts on Gen8 with !UXA
+
+
Bug 89455 - [NVC0/Gallium] Unigine Heaven black and white boxes
+
+
Bug 89689 - [Regression] Weston on DRM backend won't start with new version of mesa
From 95089bfaebcff449289494267c3461704f48452e Mon Sep 17 00:00:00 2001
From: Emil Velikov
Date: Mon, 11 May 2015 22:07:46 +0100
Subject: [PATCH 026/834] docs: add news item and link release notes for mesa
10.5.5
Signed-off-by: Emil Velikov
---
docs/index.html | 6 ++++++
docs/relnotes.html | 1 +
2 files changed, 7 insertions(+)
diff --git a/docs/index.html b/docs/index.html
index e01790cd79d..325e554df5b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -16,6 +16,12 @@
News
+
May 11, 2015
+
+Mesa 10.5.5 is released.
+This is a bug-fix release.
+
+
April 24, 2015
Mesa 10.5.4 is released.
diff --git a/docs/relnotes.html b/docs/relnotes.html
index 7f2e1d851b9..6ba9e5904be 100644
--- a/docs/relnotes.html
+++ b/docs/relnotes.html
@@ -21,6 +21,7 @@ The release notes summarize what's new or changed in each Mesa release.
GL_ARB_pipeline_statistics_query on i965, nv50, nvc0, r600, radeonsi, softpipe
GL_ARB_program_interface_query (all drivers)
GL_ARB_texture_stencil8 on nv50, nvc0, r600, radeonsi, softpipe
+
GL_ARB_texture_view on llvmpipe
GL_ARB_uniform_buffer_object on freedreno
GL_ARB_vertex_attrib_64bit on nvc0, softpipe
GL_ARB_viewport_array, GL_AMD_vertex_shader_viewport_index on i965/gen6
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 5b220450bf3..4befb3a1c80 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -113,7 +113,7 @@ lp_sampler_static_texture_state(struct lp_static_texture_state *state,
state->swizzle_b = view->swizzle_b;
state->swizzle_a = view->swizzle_a;
- state->target = texture->target;
+ state->target = view->target;
state->pot_width = util_is_power_of_two(texture->width0);
state->pot_height = util_is_power_of_two(texture->height0);
state->pot_depth = util_is_power_of_two(texture->depth0);
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 509b9bce116..09ac9af50ec 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -258,8 +258,9 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
return 1;
case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
- case PIPE_CAP_SAMPLER_VIEW_TARGET:
return 0;
+ case PIPE_CAP_SAMPLER_VIEW_TARGET:
+ return 1;
case PIPE_CAP_FAKE_SW_MSAA:
return 1;
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 96cc77c250c..56292c68c5f 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -854,9 +854,10 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
jit_tex->img_stride[j] = lp_tex->img_stride[j];
}
- if (res->target == PIPE_TEXTURE_1D_ARRAY ||
- res->target == PIPE_TEXTURE_2D_ARRAY ||
- res->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ if (view->target == PIPE_TEXTURE_1D_ARRAY ||
+ view->target == PIPE_TEXTURE_2D_ARRAY ||
+ view->target == PIPE_TEXTURE_CUBE ||
+ view->target == PIPE_TEXTURE_CUBE_ARRAY) {
/*
* For array textures, we don't have first_layer, instead
* adjust last_layer (stored as depth) plus the mip level offsets
@@ -868,7 +869,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
jit_tex->mip_offsets[j] += view->u.tex.first_layer *
lp_tex->img_stride[j];
}
- if (res->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ if (view->target == PIPE_TEXTURE_CUBE ||
+ view->target == PIPE_TEXTURE_CUBE_ARRAY) {
assert(jit_tex->depth % 6 == 0);
}
assert(view->u.tex.first_layer <= view->u.tex.last_layer);
diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
index 21da6290574..b205f02fdba 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
@@ -170,6 +170,36 @@ llvmpipe_create_sampler_view(struct pipe_context *pipe,
view->texture = NULL;
pipe_resource_reference(&view->texture, texture);
view->context = pipe;
+
+#ifdef DEBUG
+ /*
+ * This is possibly too lenient, but the primary reason is just
+ * to catch state trackers which forget to initialize this, so
+ * it only catches clearly impossible view targets.
+ */
+ if (view->target != texture->target) {
+ if (view->target == PIPE_TEXTURE_1D)
+ assert(texture->target == PIPE_TEXTURE_1D_ARRAY);
+ else if (view->target == PIPE_TEXTURE_1D_ARRAY)
+ assert(texture->target == PIPE_TEXTURE_1D);
+ else if (view->target == PIPE_TEXTURE_2D)
+ assert(texture->target == PIPE_TEXTURE_2D_ARRAY ||
+ texture->target == PIPE_TEXTURE_CUBE ||
+ texture->target == PIPE_TEXTURE_CUBE_ARRAY);
+ else if (view->target == PIPE_TEXTURE_2D_ARRAY)
+ assert(texture->target == PIPE_TEXTURE_2D ||
+ texture->target == PIPE_TEXTURE_CUBE ||
+ texture->target == PIPE_TEXTURE_CUBE_ARRAY);
+ else if (view->target == PIPE_TEXTURE_CUBE)
+ assert(texture->target == PIPE_TEXTURE_CUBE_ARRAY ||
+ texture->target == PIPE_TEXTURE_2D_ARRAY);
+ else if (view->target == PIPE_TEXTURE_CUBE_ARRAY)
+ assert(texture->target == PIPE_TEXTURE_CUBE ||
+ texture->target == PIPE_TEXTURE_2D_ARRAY);
+ else
+ assert(0);
+ }
+#endif
}
return view;
@@ -245,15 +275,17 @@ prepare_shader_sampling(
row_stride[j] = lp_tex->row_stride[j];
img_stride[j] = lp_tex->img_stride[j];
}
- if (res->target == PIPE_TEXTURE_1D_ARRAY ||
- res->target == PIPE_TEXTURE_2D_ARRAY ||
- res->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ if (view->target == PIPE_TEXTURE_1D_ARRAY ||
+ view->target == PIPE_TEXTURE_2D_ARRAY ||
+ view->target == PIPE_TEXTURE_CUBE ||
+ view->target == PIPE_TEXTURE_CUBE_ARRAY) {
num_layers = view->u.tex.last_layer - view->u.tex.first_layer + 1;
for (j = first_level; j <= last_level; j++) {
mip_offsets[j] += view->u.tex.first_layer *
lp_tex->img_stride[j];
}
- if (res->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ if (view->target == PIPE_TEXTURE_CUBE ||
+ view->target == PIPE_TEXTURE_CUBE_ARRAY) {
assert(num_layers % 6 == 0);
}
assert(view->u.tex.first_layer <= view->u.tex.last_layer);
From adcf8f8a13717f7eb53b2aa86c4b56e344f2f317 Mon Sep 17 00:00:00 2001
From: Roland Scheidegger
Date: Wed, 13 May 2015 22:56:07 +0200
Subject: [PATCH 061/834] softpipe: enable ARB_texture_view
Some bits were already there for texture views but some were missing.
In particular for cube map views things needed to change a bit.
For simplicity I ended up removing the separate face addr bit (just use
the z bit) - cube arrays didn't use it already, so just follow the same
logic there. (In theory using separate bits could allow for better hash
function but I don't think anyone ever did some measurements of that so
probably not worth the trouble, if we'd reintroduce it we'd certainly
wanted to use the same logic for cube arrays and cube maps.)
Also extend the seamless cube sampling to cube arrays - as there were no
piglit failures before this is apparently untested, but things now generally
work quite the same for cube textures and cube array textures so there
hopefully shouldn't be any trouble...
49 new piglits, 47 pass, 2 fail (both due to fake multisampling).
v2: incorporate Brian's feedback, add sampler view validation,
function rename, formatting fixes.
Reviewed-by: Brian Paul
---
docs/GL3.txt | 2 +-
docs/relnotes/10.6.0.html | 2 +-
src/gallium/drivers/softpipe/sp_screen.c | 3 +-
.../drivers/softpipe/sp_state_sampler.c | 12 +-
src/gallium/drivers/softpipe/sp_tex_sample.c | 273 +++++++++++-------
.../drivers/softpipe/sp_tex_tile_cache.c | 11 +-
.../drivers/softpipe/sp_tex_tile_cache.h | 4 +-
7 files changed, 181 insertions(+), 126 deletions(-)
diff --git a/docs/GL3.txt b/docs/GL3.txt
index 32b7809d10c..5a15bc55f47 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -169,7 +169,7 @@ GL 4.3, GLSL 4.30:
GL_ARB_texture_buffer_range DONE (nv50, nvc0, i965, r600, radeonsi, llvmpipe)
GL_ARB_texture_query_levels DONE (all drivers that support GLSL 1.30)
GL_ARB_texture_storage_multisample DONE (all drivers that support GL_ARB_texture_multisample)
- GL_ARB_texture_view DONE (i965, nv50, nvc0, llvmpipe)
+ GL_ARB_texture_view DONE (i965, nv50, nvc0, llvmpipe, softpipe)
GL_ARB_vertex_attrib_binding DONE (all drivers)
diff --git a/docs/relnotes/10.6.0.html b/docs/relnotes/10.6.0.html
index 3f69f986ccd..6d379868865 100644
--- a/docs/relnotes/10.6.0.html
+++ b/docs/relnotes/10.6.0.html
@@ -56,7 +56,7 @@ Note: some of the new features are only available with certain drivers.
GL_ARB_pipeline_statistics_query on i965, nv50, nvc0, r600, radeonsi, softpipe
GL_ARB_program_interface_query (all drivers)
GL_ARB_texture_stencil8 on nv50, nvc0, r600, radeonsi, softpipe
-
GL_ARB_texture_view on llvmpipe
+
GL_ARB_texture_view on llvmpipe, softpipe
GL_ARB_uniform_buffer_object on freedreno
GL_ARB_vertex_attrib_64bit on nvc0, softpipe
GL_ARB_viewport_array, GL_AMD_vertex_shader_viewport_index on i965/gen6
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index fc32c56b699..b3bc1773e9f 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -200,8 +200,9 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
return 1;
case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
- case PIPE_CAP_SAMPLER_VIEW_TARGET:
return 0;
+ case PIPE_CAP_SAMPLER_VIEW_TARGET:
+ return 1;
case PIPE_CAP_FAKE_SW_MSAA:
return 1;
case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET:
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index e56fb5b1485..d7a3360713f 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -202,7 +202,7 @@ prepare_shader_sampling(
struct pipe_resource *res = view->texture;
int j;
- if (res->target != PIPE_BUFFER) {
+ if (view->target != PIPE_BUFFER) {
first_level = view->u.tex.first_level;
last_level = view->u.tex.last_level;
assert(first_level <= last_level);
@@ -214,15 +214,17 @@ prepare_shader_sampling(
row_stride[j] = sp_tex->stride[j];
img_stride[j] = sp_tex->img_stride[j];
}
- if (res->target == PIPE_TEXTURE_1D_ARRAY ||
- res->target == PIPE_TEXTURE_2D_ARRAY ||
- res->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ if (view->target == PIPE_TEXTURE_1D_ARRAY ||
+ view->target == PIPE_TEXTURE_2D_ARRAY ||
+ view->target == PIPE_TEXTURE_CUBE ||
+ view->target == PIPE_TEXTURE_CUBE_ARRAY) {
num_layers = view->u.tex.last_layer - view->u.tex.first_layer + 1;
for (j = first_level; j <= last_level; j++) {
mip_offsets[j] += view->u.tex.first_layer *
sp_tex->img_stride[j];
}
- if (res->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ if (view->target == PIPE_TEXTURE_CUBE ||
+ view->target == PIPE_TEXTURE_CUBE_ARRAY) {
assert(num_layers % 6 == 0);
}
assert(view->u.tex.first_layer <= view->u.tex.last_layer);
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 68dcf57240d..21fb6b00e30 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -474,11 +474,11 @@ wrap_linear_unorm_clamp_to_edge(float s, unsigned size,
/**
* Do coordinate to array index conversion. For array textures.
*/
-static INLINE void
-wrap_array_layer(float coord, unsigned size, int *layer)
+static INLINE int
+coord_to_layer(float coord, unsigned first_layer, unsigned last_layer)
{
int c = util_ifloor(coord + 0.5F);
- *layer = CLAMP(c, 0, (int) size - 1);
+ return CLAMP(c, (int)first_layer, (int)last_layer);
}
@@ -757,61 +757,6 @@ get_next_ycoord(unsigned face, unsigned fall_off_index, int max, int xc, int yc)
}
-static INLINE const float *
-get_texel_cube_seamless(const struct sp_sampler_view *sp_sview,
- union tex_tile_address addr, int x, int y,
- float *corner)
-{
- const struct pipe_resource *texture = sp_sview->base.texture;
- unsigned level = addr.bits.level;
- unsigned face = addr.bits.face;
- int new_x, new_y, max_x;
-
- max_x = (int) u_minify(texture->width0, level);
-
- assert(texture->width0 == texture->height0);
- new_x = x;
- new_y = y;
-
- /* change the face */
- if (x < 0) {
- /*
- * Cheat with corners. They are difficult and I believe because we don't get
- * per-pixel faces we can actually have multiple corner texels per pixel,
- * which screws things up majorly in any case (as the per spec behavior is
- * to average the 3 remaining texels, which we might not have).
- * Hence just make sure that the 2nd coord is clamped, will simply pick the
- * sample which would have fallen off the x coord, but not y coord.
- * So the filter weight of the samples will be wrong, but at least this
- * ensures that only valid texels near the corner are used.
- */
- if (y < 0 || y >= max_x) {
- y = CLAMP(y, 0, max_x - 1);
- }
- new_x = get_next_xcoord(face, 0, max_x -1, x, y);
- new_y = get_next_ycoord(face, 0, max_x -1, x, y);
- face = get_next_face(face, 0);
- } else if (x >= max_x) {
- if (y < 0 || y >= max_x) {
- y = CLAMP(y, 0, max_x - 1);
- }
- new_x = get_next_xcoord(face, 1, max_x -1, x, y);
- new_y = get_next_ycoord(face, 1, max_x -1, x, y);
- face = get_next_face(face, 1);
- } else if (y < 0) {
- new_x = get_next_xcoord(face, 2, max_x -1, x, y);
- new_y = get_next_ycoord(face, 2, max_x -1, x, y);
- face = get_next_face(face, 2);
- } else if (y >= max_x) {
- new_x = get_next_xcoord(face, 3, max_x -1, x, y);
- new_y = get_next_ycoord(face, 3, max_x -1, x, y);
- face = get_next_face(face, 3);
- }
-
- addr.bits.face = face;
- return get_texel_2d_no_border( sp_sview, addr, new_x, new_y );
-}
-
/* Gather a quad of adjacent texels within a tile:
*/
static INLINE void
@@ -948,6 +893,60 @@ get_texel_2d_array(const struct sp_sampler_view *sp_sview,
}
+static INLINE const float *
+get_texel_cube_seamless(const struct sp_sampler_view *sp_sview,
+ union tex_tile_address addr, int x, int y,
+ float *corner, int layer, unsigned face)
+{
+ const struct pipe_resource *texture = sp_sview->base.texture;
+ unsigned level = addr.bits.level;
+ int new_x, new_y, max_x;
+
+ max_x = (int) u_minify(texture->width0, level);
+
+ assert(texture->width0 == texture->height0);
+ new_x = x;
+ new_y = y;
+
+ /* change the face */
+ if (x < 0) {
+ /*
+ * Cheat with corners. They are difficult and I believe because we don't get
+ * per-pixel faces we can actually have multiple corner texels per pixel,
+ * which screws things up majorly in any case (as the per spec behavior is
+ * to average the 3 remaining texels, which we might not have).
+ * Hence just make sure that the 2nd coord is clamped, will simply pick the
+ * sample which would have fallen off the x coord, but not y coord.
+ * So the filter weight of the samples will be wrong, but at least this
+ * ensures that only valid texels near the corner are used.
+ */
+ if (y < 0 || y >= max_x) {
+ y = CLAMP(y, 0, max_x - 1);
+ }
+ new_x = get_next_xcoord(face, 0, max_x -1, x, y);
+ new_y = get_next_ycoord(face, 0, max_x -1, x, y);
+ face = get_next_face(face, 0);
+ } else if (x >= max_x) {
+ if (y < 0 || y >= max_x) {
+ y = CLAMP(y, 0, max_x - 1);
+ }
+ new_x = get_next_xcoord(face, 1, max_x -1, x, y);
+ new_y = get_next_ycoord(face, 1, max_x -1, x, y);
+ face = get_next_face(face, 1);
+ } else if (y < 0) {
+ new_x = get_next_xcoord(face, 2, max_x -1, x, y);
+ new_y = get_next_ycoord(face, 2, max_x -1, x, y);
+ face = get_next_face(face, 2);
+ } else if (y >= max_x) {
+ new_x = get_next_xcoord(face, 3, max_x -1, x, y);
+ new_y = get_next_ycoord(face, 3, max_x -1, x, y);
+ face = get_next_face(face, 3);
+ }
+
+ return get_texel_3d_no_border(sp_sview, addr, new_x, new_y, layer + face);
+}
+
+
/* Get texel pointer for cube array texture */
static INLINE const float *
get_texel_cube_array(const struct sp_sampler_view *sp_sview,
@@ -1208,7 +1207,8 @@ img_filter_1d_array_nearest(struct sp_sampler_view *sp_sview,
addr.bits.level = level;
sp_samp->nearest_texcoord_s(s, width, &x);
- wrap_array_layer(t, texture->array_size, &layer);
+ layer = coord_to_layer(t, sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer);
out = get_texel_1d_array(sp_sview, sp_samp, addr, x, layer);
for (c = 0; c < TGSI_QUAD_SIZE; c++)
@@ -1287,7 +1287,8 @@ img_filter_2d_array_nearest(struct sp_sampler_view *sp_sview,
sp_samp->nearest_texcoord_s(s, width, &x);
sp_samp->nearest_texcoord_t(t, height, &y);
- wrap_array_layer(p, texture->array_size, &layer);
+ layer = coord_to_layer(p, sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer);
out = get_texel_2d_array(sp_sview, sp_samp, addr, x, y, layer);
for (c = 0; c < TGSI_QUAD_SIZE; c++)
@@ -1299,14 +1300,6 @@ img_filter_2d_array_nearest(struct sp_sampler_view *sp_sview,
}
-static INLINE union tex_tile_address
-face(union tex_tile_address addr, unsigned face )
-{
- addr.bits.face = face;
- return addr;
-}
-
-
static void
img_filter_cube_nearest(struct sp_sampler_view *sp_sview,
struct sp_sampler *sp_samp,
@@ -1319,7 +1312,7 @@ img_filter_cube_nearest(struct sp_sampler_view *sp_sview,
{
const struct pipe_resource *texture = sp_sview->base.texture;
int width, height;
- int x, y;
+ int x, y, layerface;
union tex_tile_address addr;
const float *out;
int c;
@@ -1346,7 +1339,8 @@ img_filter_cube_nearest(struct sp_sampler_view *sp_sview,
sp_samp->nearest_texcoord_t(t, height, &y);
}
- out = get_texel_2d(sp_sview, sp_samp, face(addr, face_id), x, y);
+ layerface = face_id + sp_sview->base.u.tex.first_layer;
+ out = get_texel_cube_array(sp_sview, sp_samp, addr, x, y, layerface);
for (c = 0; c < TGSI_QUAD_SIZE; c++)
rgba[TGSI_NUM_CHANNELS*c] = out[c];
@@ -1367,7 +1361,7 @@ img_filter_cube_array_nearest(struct sp_sampler_view *sp_sview,
{
const struct pipe_resource *texture = sp_sview->base.texture;
int width, height;
- int x, y, layer;
+ int x, y, layerface;
union tex_tile_address addr;
const float *out;
int c;
@@ -1383,9 +1377,11 @@ img_filter_cube_array_nearest(struct sp_sampler_view *sp_sview,
sp_samp->nearest_texcoord_s(s, width, &x);
sp_samp->nearest_texcoord_t(t, height, &y);
- wrap_array_layer(p, texture->array_size, &layer);
+ layerface = coord_to_layer(6 * p + sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer - 5) + face_id;
- out = get_texel_cube_array(sp_sview, sp_samp, addr, x, y, layer * 6 + face_id);
+ out = get_texel_cube_array(sp_sview, sp_samp, addr, x, y, layerface);
for (c = 0; c < TGSI_QUAD_SIZE; c++)
rgba[TGSI_NUM_CHANNELS*c] = out[c];
@@ -1494,7 +1490,8 @@ img_filter_1d_array_linear(struct sp_sampler_view *sp_sview,
addr.bits.level = level;
sp_samp->linear_texcoord_s(s, width, &x0, &x1, &xw);
- wrap_array_layer(t, texture->array_size, &layer);
+ layer = coord_to_layer(t, sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer);
tx0 = get_texel_1d_array(sp_sview, sp_samp, addr, x0, layer);
tx1 = get_texel_1d_array(sp_sview, sp_samp, addr, x1, layer);
@@ -1577,7 +1574,8 @@ img_filter_2d_array_linear(struct sp_sampler_view *sp_sview,
sp_samp->linear_texcoord_s(s, width, &x0, &x1, &xw);
sp_samp->linear_texcoord_t(t, height, &y0, &y1, &yw);
- wrap_array_layer(p, texture->array_size, &layer);
+ layer = coord_to_layer(p, sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer);
tx0 = get_texel_2d_array(sp_sview, sp_samp, addr, x0, y0, layer);
tx1 = get_texel_2d_array(sp_sview, sp_samp, addr, x1, y0, layer);
@@ -1604,9 +1602,9 @@ img_filter_cube_linear(struct sp_sampler_view *sp_sview,
{
const struct pipe_resource *texture = sp_sview->base.texture;
int width, height;
- int x0, y0, x1, y1;
+ int x0, y0, x1, y1, layer;
float xw, yw; /* weights */
- union tex_tile_address addr, addrj;
+ union tex_tile_address addr;
const float *tx0, *tx1, *tx2, *tx3;
float corner0[TGSI_QUAD_SIZE], corner1[TGSI_QUAD_SIZE],
corner2[TGSI_QUAD_SIZE], corner3[TGSI_QUAD_SIZE];
@@ -1635,19 +1633,20 @@ img_filter_cube_linear(struct sp_sampler_view *sp_sview,
sp_samp->linear_texcoord_t(t, height, &y0, &y1, &yw);
}
- addrj = face(addr, face_id);
+ layer = sp_sview->base.u.tex.first_layer;
if (sp_samp->base.seamless_cube_map) {
- tx0 = get_texel_cube_seamless(sp_sview, addrj, x0, y0, corner0);
- tx1 = get_texel_cube_seamless(sp_sview, addrj, x1, y0, corner1);
- tx2 = get_texel_cube_seamless(sp_sview, addrj, x0, y1, corner2);
- tx3 = get_texel_cube_seamless(sp_sview, addrj, x1, y1, corner3);
+ tx0 = get_texel_cube_seamless(sp_sview, addr, x0, y0, corner0, layer, face_id);
+ tx1 = get_texel_cube_seamless(sp_sview, addr, x1, y0, corner1, layer, face_id);
+ tx2 = get_texel_cube_seamless(sp_sview, addr, x0, y1, corner2, layer, face_id);
+ tx3 = get_texel_cube_seamless(sp_sview, addr, x1, y1, corner3, layer, face_id);
} else {
- tx0 = get_texel_2d(sp_sview, sp_samp, addrj, x0, y0);
- tx1 = get_texel_2d(sp_sview, sp_samp, addrj, x1, y0);
- tx2 = get_texel_2d(sp_sview, sp_samp, addrj, x0, y1);
- tx3 = get_texel_2d(sp_sview, sp_samp, addrj, x1, y1);
+ tx0 = get_texel_cube_array(sp_sview, sp_samp, addr, x0, y0, layer + face_id);
+ tx1 = get_texel_cube_array(sp_sview, sp_samp, addr, x1, y0, layer + face_id);
+ tx2 = get_texel_cube_array(sp_sview, sp_samp, addr, x0, y1, layer + face_id);
+ tx3 = get_texel_cube_array(sp_sview, sp_samp, addr, x1, y1, layer + face_id);
}
+
/* interpolate R, G, B, A */
for (c = 0; c < TGSI_QUAD_SIZE; c++)
rgba[TGSI_NUM_CHANNELS*c] = lerp_2d(xw, yw,
@@ -1672,6 +1671,8 @@ img_filter_cube_array_linear(struct sp_sampler_view *sp_sview,
float xw, yw; /* weights */
union tex_tile_address addr;
const float *tx0, *tx1, *tx2, *tx3;
+ float corner0[TGSI_QUAD_SIZE], corner1[TGSI_QUAD_SIZE],
+ corner2[TGSI_QUAD_SIZE], corner3[TGSI_QUAD_SIZE];
int c;
width = u_minify(texture->width0, level);
@@ -1683,14 +1684,35 @@ img_filter_cube_array_linear(struct sp_sampler_view *sp_sview,
addr.value = 0;
addr.bits.level = level;
- sp_samp->linear_texcoord_s(s, width, &x0, &x1, &xw);
- sp_samp->linear_texcoord_t(t, height, &y0, &y1, &yw);
- wrap_array_layer(p, texture->array_size, &layer);
+ /*
+ * For seamless if LINEAR filtering is done within a miplevel,
+ * always apply wrap mode CLAMP_TO_BORDER.
+ */
+ if (sp_samp->base.seamless_cube_map) {
+ /* Note this is a bit overkill, actual clamping is not required */
+ wrap_linear_clamp_to_border(s, width, &x0, &x1, &xw);
+ wrap_linear_clamp_to_border(t, height, &y0, &y1, &yw);
+ } else {
+ /* Would probably make sense to ignore mode and just do edge clamp */
+ sp_samp->linear_texcoord_s(s, width, &x0, &x1, &xw);
+ sp_samp->linear_texcoord_t(t, height, &y0, &y1, &yw);
+ }
- tx0 = get_texel_cube_array(sp_sview, sp_samp, addr, x0, y0, layer * 6 + face_id);
- tx1 = get_texel_cube_array(sp_sview, sp_samp, addr, x1, y0, layer * 6 + face_id);
- tx2 = get_texel_cube_array(sp_sview, sp_samp, addr, x0, y1, layer * 6 + face_id);
- tx3 = get_texel_cube_array(sp_sview, sp_samp, addr, x1, y1, layer * 6 + face_id);
+ layer = coord_to_layer(6 * p + sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer - 5);
+
+ if (sp_samp->base.seamless_cube_map) {
+ tx0 = get_texel_cube_seamless(sp_sview, addr, x0, y0, corner0, layer, face_id);
+ tx1 = get_texel_cube_seamless(sp_sview, addr, x1, y0, corner1, layer, face_id);
+ tx2 = get_texel_cube_seamless(sp_sview, addr, x0, y1, corner2, layer, face_id);
+ tx3 = get_texel_cube_seamless(sp_sview, addr, x1, y1, corner3, layer, face_id);
+ } else {
+ tx0 = get_texel_cube_array(sp_sview, sp_samp, addr, x0, y0, layer + face_id);
+ tx1 = get_texel_cube_array(sp_sview, sp_samp, addr, x1, y0, layer + face_id);
+ tx2 = get_texel_cube_array(sp_sview, sp_samp, addr, x0, y1, layer + face_id);
+ tx3 = get_texel_cube_array(sp_sview, sp_samp, addr, x1, y1, layer + face_id);
+ }
/* interpolate R, G, B, A */
for (c = 0; c < TGSI_QUAD_SIZE; c++)
@@ -2408,13 +2430,13 @@ sample_compare(struct sp_sampler_view *sp_sview,
* RGBA channels. We look at the red channel here.
*/
- if (sp_sview->base.texture->target == PIPE_TEXTURE_2D_ARRAY ||
- sp_sview->base.texture->target == PIPE_TEXTURE_CUBE) {
+ if (sp_sview->base.target == PIPE_TEXTURE_2D_ARRAY ||
+ sp_sview->base.target == PIPE_TEXTURE_CUBE) {
pc[0] = c0[0];
pc[1] = c0[1];
pc[2] = c0[2];
pc[3] = c0[3];
- } else if (sp_sview->base.texture->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ } else if (sp_sview->base.target == PIPE_TEXTURE_CUBE_ARRAY) {
pc[0] = c1[0];
pc[1] = c1[1];
pc[2] = c1[2];
@@ -2681,7 +2703,7 @@ get_img_filter(const struct sp_sampler_view *sp_sview,
const struct pipe_sampler_state *sampler,
unsigned filter)
{
- switch (sp_sview->base.texture->target) {
+ switch (sp_sview->base.target) {
case PIPE_BUFFER:
case PIPE_TEXTURE_1D:
if (filter == PIPE_TEX_FILTER_NEAREST)
@@ -2907,7 +2929,7 @@ sp_get_dims(struct sp_sampler_view *sp_sview, int level,
const struct pipe_sampler_view *view = &sp_sview->base;
const struct pipe_resource *texture = view->texture;
- if (texture->target == PIPE_BUFFER) {
+ if (view->target == PIPE_BUFFER) {
dims[0] = (view->u.buf.last_element - view->u.buf.first_element) + 1;
/* the other values are undefined, but let's avoid potential valgrind
* warnings.
@@ -2924,7 +2946,7 @@ sp_get_dims(struct sp_sampler_view *sp_sview, int level,
dims[3] = view->u.tex.last_level - view->u.tex.first_level + 1;
dims[0] = u_minify(texture->width0, level);
- switch(texture->target) {
+ switch (view->target) {
case PIPE_TEXTURE_1D_ARRAY:
dims[1] = view->u.tex.last_layer - view->u.tex.first_layer + 1;
/* fallthrough */
@@ -2975,13 +2997,16 @@ sp_get_texels(struct sp_sampler_view *sp_sview,
addr.value = 0;
/* TODO write a better test for LOD */
- addr.bits.level = lod[0];
+ addr.bits.level = sp_sview->base.target == PIPE_BUFFER ? 0 :
+ CLAMP(lod[0] + sp_sview->base.u.tex.first_level,
+ sp_sview->base.u.tex.first_level,
+ sp_sview->base.u.tex.last_level);
width = u_minify(texture->width0, addr.bits.level);
height = u_minify(texture->height0, addr.bits.level);
depth = u_minify(texture->depth0, addr.bits.level);
- switch(texture->target) {
+ switch (sp_sview->base.target) {
case PIPE_BUFFER:
case PIPE_TEXTURE_1D:
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
@@ -2995,7 +3020,8 @@ sp_get_texels(struct sp_sampler_view *sp_sview,
case PIPE_TEXTURE_1D_ARRAY:
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
int x = CLAMP(v_i[j] + offset[0], 0, width - 1);
- int y = CLAMP(v_j[j], sp_sview->base.u.tex.first_layer, sp_sview->base.u.tex.last_layer);
+ int y = CLAMP(v_j[j], sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer);
tx = get_texel_2d_no_border(sp_sview, addr, x, y);
for (c = 0; c < 4; c++) {
rgba[c][j] = tx[c];
@@ -3017,7 +3043,8 @@ sp_get_texels(struct sp_sampler_view *sp_sview,
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
int x = CLAMP(v_i[j] + offset[0], 0, width - 1);
int y = CLAMP(v_j[j] + offset[1], 0, height - 1);
- int layer = CLAMP(v_k[j], sp_sview->base.u.tex.first_layer, sp_sview->base.u.tex.last_layer);
+ int layer = CLAMP(v_k[j], sp_sview->base.u.tex.first_layer,
+ sp_sview->base.u.tex.last_layer);
tx = get_texel_3d_no_border(sp_sview, addr, x, y, layer);
for (c = 0; c < 4; c++) {
rgba[c][j] = tx[c];
@@ -3140,7 +3167,7 @@ softpipe_get_lambda_func(const struct pipe_sampler_view *view, unsigned shader)
if (shader != PIPE_SHADER_FRAGMENT)
return compute_lambda_vert;
- switch (view->texture->target) {
+ switch (view->target) {
case PIPE_BUFFER:
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_1D_ARRAY:
@@ -3176,19 +3203,49 @@ softpipe_create_sampler_view(struct pipe_context *pipe,
pipe_resource_reference(&view->texture, resource);
view->context = pipe;
+#ifdef DEBUG
+ /*
+ * This is possibly too lenient, but the primary reason is just
+ * to catch state trackers which forget to initialize this, so
+ * it only catches clearly impossible view targets.
+ */
+ if (view->target != resource->target) {
+ if (view->target == PIPE_TEXTURE_1D)
+ assert(resource->target == PIPE_TEXTURE_1D_ARRAY);
+ else if (view->target == PIPE_TEXTURE_1D_ARRAY)
+ assert(resource->target == PIPE_TEXTURE_1D);
+ else if (view->target == PIPE_TEXTURE_2D)
+ assert(resource->target == PIPE_TEXTURE_2D_ARRAY ||
+ resource->target == PIPE_TEXTURE_CUBE ||
+ resource->target == PIPE_TEXTURE_CUBE_ARRAY);
+ else if (view->target == PIPE_TEXTURE_2D_ARRAY)
+ assert(resource->target == PIPE_TEXTURE_2D ||
+ resource->target == PIPE_TEXTURE_CUBE ||
+ resource->target == PIPE_TEXTURE_CUBE_ARRAY);
+ else if (view->target == PIPE_TEXTURE_CUBE)
+ assert(resource->target == PIPE_TEXTURE_CUBE_ARRAY ||
+ resource->target == PIPE_TEXTURE_2D_ARRAY);
+ else if (view->target == PIPE_TEXTURE_CUBE_ARRAY)
+ assert(resource->target == PIPE_TEXTURE_CUBE ||
+ resource->target == PIPE_TEXTURE_2D_ARRAY);
+ else
+ assert(0);
+ }
+#endif
+
if (any_swizzle(view)) {
sview->need_swizzle = TRUE;
}
- if (resource->target == PIPE_TEXTURE_CUBE ||
- resource->target == PIPE_TEXTURE_CUBE_ARRAY)
+ if (view->target == PIPE_TEXTURE_CUBE ||
+ view->target == PIPE_TEXTURE_CUBE_ARRAY)
sview->get_samples = sample_cube;
else {
sview->get_samples = sample_mip;
}
sview->pot2d = spr->pot &&
- (resource->target == PIPE_TEXTURE_2D ||
- resource->target == PIPE_TEXTURE_RECT);
+ (view->target == PIPE_TEXTURE_2D ||
+ view->target == PIPE_TEXTURE_RECT);
sview->xpot = util_logbase2( resource->width0 );
sview->ypot = util_logbase2( resource->height0 );
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
index ab8ba60849a..4a421a8f882 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
@@ -151,7 +151,7 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
tc->entries[i].addr.bits.invalid = 1;
}
- tc->tex_face = -1; /* any invalid value here */
+ tc->tex_z = -1; /* any invalid value here */
}
}
@@ -172,7 +172,7 @@ sp_flush_tex_tile_cache(struct softpipe_tex_tile_cache *tc)
for (pos = 0; pos < Elements(tc->entries); pos++) {
tc->entries[pos].addr.bits.invalid = 1;
}
- tc->tex_face = -1;
+ tc->tex_z = -1;
}
}
@@ -190,8 +190,7 @@ tex_cache_pos( union tex_tile_address addr )
{
uint entry = (addr.bits.x +
addr.bits.y * 9 +
- addr.bits.z * 3 +
- addr.bits.face +
+ addr.bits.z +
addr.bits.level * 7);
return entry % NUM_TEX_TILE_ENTRIES;
@@ -226,7 +225,6 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
/* check if we need to get a new transfer */
if (!tc->tex_trans ||
- tc->tex_face != addr.bits.face ||
tc->tex_level != addr.bits.level ||
tc->tex_z != addr.bits.z) {
/* get new transfer (view into texture) */
@@ -245,7 +243,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
}
else {
height = u_minify(tc->texture->height0, addr.bits.level);
- layer = addr.bits.face + addr.bits.z;
+ layer = addr.bits.z;
}
tc->tex_trans_map =
@@ -255,7 +253,6 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED,
0, 0, width, height, &tc->tex_trans);
- tc->tex_face = addr.bits.face;
tc->tex_level = addr.bits.level;
tc->tex_z = addr.bits.z;
}
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
index 4eb42460552..2233effc439 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
@@ -55,7 +55,6 @@ union tex_tile_address {
unsigned x:TEX_ADDR_BITS; /* 16K / TILE_SIZE */
unsigned y:TEX_ADDR_BITS; /* 16K / TILE_SIZE */
unsigned z:TEX_Z_BITS; /* 16K -- z not tiled */
- unsigned face:3;
unsigned level:4;
unsigned invalid:1;
} bits;
@@ -94,7 +93,7 @@ struct softpipe_tex_tile_cache
struct pipe_transfer *tex_trans;
void *tex_trans_map;
- int tex_face, tex_level, tex_z;
+ int tex_level, tex_z;
unsigned swizzle_r;
unsigned swizzle_g;
@@ -141,7 +140,6 @@ tex_tile_address( unsigned x,
addr.bits.x = x / TEX_TILE_SIZE;
addr.bits.y = y / TEX_TILE_SIZE;
addr.bits.z = z;
- addr.bits.face = face;
addr.bits.level = level;
return addr;
From 6d8eff4af7816d675f8ee91f99106fa118cda424 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 22 Jan 2015 10:23:35 -0800
Subject: [PATCH 062/834] main: Add utility function
_mesa_lookup_framebuffer_err.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: Generate an error for non-existent framebuffers]
Reviewed-by: Fredrik Höglund
Reviewed-by: Anuj Phogat
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 21 +++++++++++++++++++++
src/mesa/main/fbobject.h | 4 ++++
2 files changed, 25 insertions(+)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 27cf97f1778..3f5c0d7ef19 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -137,6 +137,27 @@ _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id)
}
+/**
+ * A convenience function for direct state access that throws
+ * GL_INVALID_OPERATION if the framebuffer doesn't exist.
+ */
+struct gl_framebuffer *
+_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func)
+{
+ struct gl_framebuffer *fb;
+
+ fb = _mesa_lookup_framebuffer(ctx, id);
+ if (!fb || fb == &DummyFramebuffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(non-existent framebuffer %u)", func, id);
+ return NULL;
+ }
+
+ return fb;
+}
+
+
/**
* Mark the given framebuffer as invalid. This will force the
* test for framebuffer completeness to be done before the framebuffer
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 61aa1f50308..1f0eb0b5b78 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -67,6 +67,10 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id);
extern struct gl_framebuffer *
_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);
+extern struct gl_framebuffer *
+_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func);
+
void
_mesa_update_texture_renderbuffer(struct gl_context *ctx,
From f868de7d6b1370105414eb3d83b4b38b598bff66 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 23 Jan 2015 14:54:48 -0800
Subject: [PATCH 063/834] main: Add glCreateFramebuffers.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: Whitespace fixes]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 7 ++++
src/mesa/main/fbobject.c | 42 ++++++++++++++++---
src/mesa/main/fbobject.h | 3 ++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 9e0cf2d6ce1..7801ef45bb2 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -152,6 +152,13 @@
+
+
+
+
+
+
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 3f5c0d7ef19..e4cb8cc71b6 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2417,15 +2417,23 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
}
-void GLAPIENTRY
-_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
+/**
+ * This is the implementation for glGenFramebuffers and glCreateFramebuffers.
+ * It is not exposed to the rest of Mesa to encourage the use of
+ * nameless buffers in driver internals.
+ */
+static void
+create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa)
{
GET_CURRENT_CONTEXT(ctx);
GLuint first;
GLint i;
+ struct gl_framebuffer *fb;
+
+ const char *func = dsa ? "glCreateFramebuffers" : "glGenFramebuffers";
if (n < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
return;
}
@@ -2437,14 +2445,38 @@ _mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
for (i = 0; i < n; i++) {
GLuint name = first + i;
framebuffers[i] = name;
- /* insert dummy placeholder into hash table */
+
+ if (dsa) {
+ fb = ctx->Driver.NewFramebuffer(ctx, framebuffers[i]);
+ if (!fb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
+ return;
+ }
+ }
+ else
+ fb = &DummyFramebuffer;
+
mtx_lock(&ctx->Shared->Mutex);
- _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer);
+ _mesa_HashInsert(ctx->Shared->FrameBuffers, name, fb);
mtx_unlock(&ctx->Shared->Mutex);
}
}
+void GLAPIENTRY
+_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
+{
+ create_framebuffers(n, framebuffers, false);
+}
+
+
+void GLAPIENTRY
+_mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers)
+{
+ create_framebuffers(n, framebuffers, true);
+}
+
+
GLenum GLAPIENTRY
_mesa_CheckFramebufferStatus(GLenum target)
{
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 1f0eb0b5b78..37d9535018b 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -169,6 +169,9 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers);
extern void GLAPIENTRY
_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers);
+extern void GLAPIENTRY
+_mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers);
+
extern GLenum GLAPIENTRY
_mesa_CheckFramebufferStatus(GLenum target);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index ccd0124a2bb..6e1293d98e5 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -980,6 +980,7 @@ const struct function gl_core_functions_possible[] = {
{ "glGetNamedBufferParameteri64v", 45, -1 },
{ "glGetNamedBufferPointerv", 45, -1 },
{ "glGetNamedBufferSubData", 45, -1 },
+ { "glCreateFramebuffers", 45, -1 },
{ "glCreateRenderbuffers", 45, -1 },
{ "glNamedRenderbufferStorage", 45, -1 },
{ "glNamedRenderbufferStorageMultisample", 45, -1 },
From 2bb138e7ec24b9e56715a53f9c4e911b99d4a97b Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 23 Jan 2015 16:38:36 -0800
Subject: [PATCH 064/834] main: Add utility function
_mesa_lookup_renderbuffer_err.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: Generate an error for non-existent renderbuffers]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 21 +++++++++++++++++++++
src/mesa/main/fbobject.h | 4 ++++
2 files changed, 25 insertions(+)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index e4cb8cc71b6..adadf3c980b 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -120,6 +120,27 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id)
}
+/**
+ * A convenience function for direct state access that throws
+ * GL_INVALID_OPERATION if the renderbuffer doesn't exist.
+ */
+struct gl_renderbuffer *
+_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func)
+{
+ struct gl_renderbuffer *rb;
+
+ rb = _mesa_lookup_renderbuffer(ctx, id);
+ if (!rb || rb == &DummyRenderbuffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(non-existent renderbuffer %u)", func, id);
+ return NULL;
+ }
+
+ return rb;
+}
+
+
/**
* Helper routine for getting a gl_framebuffer.
*/
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 37d9535018b..6ac16fca241 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -64,6 +64,10 @@ _mesa_get_incomplete_framebuffer(void);
extern struct gl_renderbuffer *
_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id);
+extern struct gl_renderbuffer *
+_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func);
+
extern struct gl_framebuffer *
_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);
From 3d100372f15c377bb1cff3d23621f1f5958f4c53 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 27 Feb 2015 17:23:59 -0800
Subject: [PATCH 065/834] main: Rename framebuffer renderbuffer software
fallback.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Rename _mesa_framebuffer_renderbuffer to _mesa_FramebufferRenderbuffer_sw in
preparation for adding the ARB_direct_state_access backend function for
FramebufferRenderbuffer and NamedFramebufferRenderbuffer to share.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/drivers/common/driverfuncs.c | 2 +-
src/mesa/drivers/dri/i915/intel_fbo.c | 2 +-
src/mesa/drivers/dri/nouveau/nouveau_fbo.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_fbo.c | 2 +-
src/mesa/main/fbobject.c | 7 ++++---
src/mesa/main/fbobject.h | 7 ++++---
src/mesa/state_tracker/st_cb_fbo.c | 2 +-
src/mesa/swrast/s_texrender.c | 2 +-
8 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 0d094ddf4e6..71c1a763912 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -172,7 +172,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer;
driver->RenderTexture = _swrast_render_texture;
driver->FinishRenderTexture = _swrast_finish_render_texture;
- driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
+ driver->FramebufferRenderbuffer = _mesa_FramebufferRenderbuffer_sw;
driver->ValidateFramebuffer = _mesa_validate_framebuffer;
driver->BlitFramebuffer = _swrast_BlitFramebuffer;
diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c b/src/mesa/drivers/dri/i915/intel_fbo.c
index 24c318049c4..a5d5c5832fb 100644
--- a/src/mesa/drivers/dri/i915/intel_fbo.c
+++ b/src/mesa/drivers/dri/i915/intel_fbo.c
@@ -427,7 +427,7 @@ intel_framebuffer_renderbuffer(struct gl_context * ctx,
{
DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0);
- _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ _mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
intel_draw_buffer(ctx);
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index 6c479f5f0c6..c78d4baa124 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -242,7 +242,7 @@ static void
nouveau_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment, struct gl_renderbuffer *rb)
{
- _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ _mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
context_dirty(ctx, FRAMEBUFFER);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 97022f95953..ef62d097bae 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -723,7 +723,7 @@ radeon_framebuffer_renderbuffer(struct gl_context * ctx,
"%s(%p, fb %p, rb %p) \n",
__func__, ctx, fb, rb);
- _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ _mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
radeon_draw_buffer(ctx, fb);
}
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index adadf3c980b..f1603649f4c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -521,9 +521,10 @@ set_renderbuffer_attachment(struct gl_context *ctx,
* Attach a renderbuffer object to a framebuffer object.
*/
void
-_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
- struct gl_framebuffer *fb,
- GLenum attachment, struct gl_renderbuffer *rb)
+_mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb)
{
struct gl_renderbuffer_attachment *att;
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 6ac16fca241..0c0bc0e4a66 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -82,9 +82,10 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
struct gl_renderbuffer_attachment *att);
extern void
-_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
- struct gl_framebuffer *fb,
- GLenum attachment, struct gl_renderbuffer *rb);
+_mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb);
extern void
_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 296ea1e0d29..0399eef7204 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -842,7 +842,7 @@ void st_init_fbo_functions(struct dd_function_table *functions)
functions->NewFramebuffer = st_new_framebuffer;
functions->NewRenderbuffer = st_new_renderbuffer;
functions->BindFramebuffer = st_bind_framebuffer;
- functions->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
+ functions->FramebufferRenderbuffer = _mesa_FramebufferRenderbuffer_sw;
functions->RenderTexture = st_render_texture;
functions->FinishRenderTexture = st_finish_render_texture;
functions->ValidateFramebuffer = st_validate_framebuffer;
diff --git a/src/mesa/swrast/s_texrender.c b/src/mesa/swrast/s_texrender.c
index fa853c9197f..4e41b3b72a8 100644
--- a/src/mesa/swrast/s_texrender.c
+++ b/src/mesa/swrast/s_texrender.c
@@ -72,7 +72,7 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
* \param fb the framebuffer object the texture is being bound to
* \param att the fb attachment point of the texture
*
- * \sa _mesa_framebuffer_renderbuffer
+ * \sa _mesa_FramebufferRenderbuffer_sw
*/
void
_swrast_render_texture(struct gl_context *ctx,
From a29318bf0a0385fa4fdedbdc3fb6e1f6f0d87884 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 27 Feb 2015 17:27:30 -0800
Subject: [PATCH 066/834] main: Add entry point for
NamedFramebufferRenderbuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: - Remove the DummyRenderbuffer checks now that they are
done in _mesa_lookup_renderbuffer_err.
- Fix the name in error messages.
- Make the error message in _mesa_framebuffer_renderbuffer
reflect that might not be the bound framebuffer.
- Remove EXT suffixes from GL tokens.]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 7 +
src/mesa/main/fbobject.c | 129 ++++++++++++------
src/mesa/main/fbobject.h | 12 ++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 105 insertions(+), 44 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 7801ef45bb2..f228a5286a7 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -159,6 +159,13 @@
+
+
+
+
+
+
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f1603649f4c..ea6e273fda3 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2896,71 +2896,37 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
}
-void GLAPIENTRY
-_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
- GLenum renderbufferTarget,
- GLuint renderbuffer)
+void
+_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb,
+ const char *func)
{
struct gl_renderbuffer_attachment *att;
- struct gl_framebuffer *fb;
- struct gl_renderbuffer *rb;
- GET_CURRENT_CONTEXT(ctx);
-
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbuffer(target)");
- return;
- }
-
- if (renderbufferTarget != GL_RENDERBUFFER_EXT) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbuffer(renderbufferTarget)");
- return;
- }
if (_mesa_is_winsys_fbo(fb)) {
/* Can't attach new renderbuffers to a window system framebuffer */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbuffer");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(window-system framebuffer)", func);
return;
}
att = get_attachment(ctx, fb, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbuffer(invalid attachment %s)",
+ "%s(invalid attachment %s)", func,
_mesa_lookup_enum_by_nr(attachment));
return;
}
- if (renderbuffer) {
- rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
- if (!rb) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferRenderbuffer(non-existant"
- " renderbuffer %u)", renderbuffer);
- return;
- }
- else if (rb == &DummyRenderbuffer) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferRenderbuffer(renderbuffer %u)",
- renderbuffer);
- return;
- }
- }
- else {
- /* remove renderbuffer attachment */
- rb = NULL;
- }
-
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT &&
rb && rb->Format != MESA_FORMAT_NONE) {
/* make sure the renderbuffer is a depth/stencil format */
const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
if (baseFormat != GL_DEPTH_STENCIL) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferRenderbuffer(renderbuffer"
- " is not DEPTH_STENCIL format)");
+ "%s(renderbuffer is not DEPTH_STENCIL format)", func);
return;
}
}
@@ -2977,6 +2943,81 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
}
+void GLAPIENTRY
+_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer)
+{
+ struct gl_framebuffer *fb;
+ struct gl_renderbuffer *rb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbuffer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ if (renderbuffertarget != GL_RENDERBUFFER) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbuffer(renderbuffertarget is not "
+ "GL_RENDERBUFFER)");
+ return;
+ }
+
+ if (renderbuffer) {
+ rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer,
+ "glFramebufferRenderbuffer");
+ if (!rb)
+ return;
+ }
+ else {
+ /* remove renderbuffer attachment */
+ rb = NULL;
+ }
+
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
+ "glFramebufferRenderbuffer");
+}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer)
+{
+ struct gl_framebuffer *fb;
+ struct gl_renderbuffer *rb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferRenderbuffer");
+
+ if (renderbuffertarget != GL_RENDERBUFFER) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glNamedFramebufferRenderbuffer(renderbuffertarget is not "
+ "GL_RENDERBUFFER)");
+ return;
+ }
+
+ if (renderbuffer) {
+ rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer,
+ "glNamedFramebufferRenderbuffer");
+ if (!rb)
+ return;
+ }
+ else {
+ /* remove renderbuffer attachment */
+ rb = NULL;
+ }
+
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
+ "glNamedFramebufferRenderbuffer");
+}
+
+
void GLAPIENTRY
_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
GLenum pname, GLint *params)
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 0c0bc0e4a66..63b76f1ed49 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -87,6 +87,13 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
GLenum attachment,
struct gl_renderbuffer *rb);
+extern void
+_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb,
+ const char *func);
+
extern void
_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
@@ -206,6 +213,11 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
GLuint renderbuffer);
+extern void GLAPIENTRY
+_mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer);
+
extern void GLAPIENTRY
_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
GLenum pname, GLint *params);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 6e1293d98e5..32b082bcb28 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -981,6 +981,7 @@ const struct function gl_core_functions_possible[] = {
{ "glGetNamedBufferPointerv", 45, -1 },
{ "glGetNamedBufferSubData", 45, -1 },
{ "glCreateFramebuffers", 45, -1 },
+ { "glNamedFramebufferRenderbuffer", 45, -1 },
{ "glCreateRenderbuffers", 45, -1 },
{ "glNamedRenderbufferStorage", 45, -1 },
{ "glNamedRenderbufferStorageMultisample", 45, -1 },
From 8f78c6889d508d40c82229ea3fa09a78b4ea2e17 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 27 Jan 2015 14:11:13 -0800
Subject: [PATCH 067/834] main: Fix the indentation in framebuffer_texture
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index ea6e273fda3..9486ded05a0 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2731,7 +2731,8 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
BUFFER_DEPTH);
} else {
set_texture_attachment(ctx, fb, att, texObj, textarget,
- level, zoffset, layered);
+ level, zoffset, layered);
+
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
/* Above we created a new renderbuffer and attached it to the
* depth attachment point. Now attach it to the stencil attachment
From f9f5c822845698482d0d81eaa64bc13c2fd8852a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Thu, 7 May 2015 20:28:23 +0200
Subject: [PATCH 068/834] main: Require that the texture exists in
framebuffer_texture
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Generate GL_INVALID_OPERATION if the texture hasn't been created.
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
Cc: "10.4 10.5"
---
src/mesa/main/fbobject.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 9486ded05a0..4524e51e4c0 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2603,7 +2603,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
GLboolean err = GL_TRUE;
texObj = _mesa_lookup_texture(ctx, texture);
- if (texObj != NULL) {
+ if (texObj != NULL && texObj->Target != 0) {
if (textarget == 0) {
if (layered) {
/* We're being called by glFramebufferTexture() and textarget
From 8ba7ad8abc7d71131e17970203c991ccb1befbe6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sat, 9 May 2015 15:31:45 +0200
Subject: [PATCH 069/834] mesa: Generate GL_INVALID_VALUE in
framebuffer_texture when layer < 0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
Cc: "10.4 10.5"
---
src/mesa/main/fbobject.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4524e51e4c0..20a4e86007c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2668,6 +2668,18 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
return;
}
+ /* Page 306 (page 328 of the PDF) of the OpenGL 4.5 (Core Profile)
+ * spec says:
+ *
+ * "An INVALID_VALUE error is generated if texture is non-zero
+ * and layer is negative."
+ */
+ if (zoffset < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glFramebufferTexture%s(layer %u < 0)", caller, zoffset);
+ return;
+ }
+
if (texObj->Target == GL_TEXTURE_3D) {
const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
if (zoffset >= maxSize) {
From 69bdc9dcb8e5d3648e8d96029d5988b8971de8dc Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 20 Apr 2015 17:21:20 +0200
Subject: [PATCH 070/834] main: Fix an error generated by FramebufferTexture
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
gl*FramebufferTexture should generate GL_INVALID_VALUE when the
texture doesn't exist.
[Fredrik: Split this change out from the next commit]
Signed-off-by: Fredrik Höglund
Reviewed-by: Fredrik Höglund
Reviewed-by: Adam Jackson
Cc: "10.4 10.5"
---
src/mesa/main/fbobject.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 20a4e86007c..09dbf338a51 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2654,10 +2654,19 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
}
}
else {
- /* can't render to a non-existant texture */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture%s(non existant texture)",
- caller);
+ /* Can't render to a non-existent texture object.
+ *
+ * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
+ * Managing Framebuffer Objects specifies a different error
+ * depending upon the calling function (PDF pages 325-328).
+ * *FramebufferTexture (where layered = GL_TRUE) throws invalid
+ * value, while the other commands throw invalid operation (where
+ * layered = GL_FALSE).
+ */
+ const GLenum error = layered ? GL_INVALID_VALUE :
+ GL_INVALID_OPERATION;
+ _mesa_error(ctx, error,
+ "%s(non-existent texture %u)", caller, texture);
return;
}
From a245e3bdeb1cf38b56df4f208a7e20d0f0de6045 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 27 Jan 2015 16:11:52 -0800
Subject: [PATCH 071/834] main: Split framebuffer_texture.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Split apart utility function framebuffer_texture to better prepare for
implementing NamedFramebufferTexture and NamedFramebufferTextureLayer. This
should also pave the way for some future cleanup work.
[Fredrik: - Mention which limit was exceeded when is out of range.
- Update a comment to reflect that might not be the bound
framebuffer.
- Make it clear that the error message in glFramebufferTexture*D
refers to the parameter.
- Remove EXT suffixes.]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 265 ++++++++++++++++++++++++++++-----------
src/mesa/main/fbobject.h | 8 ++
2 files changed, 198 insertions(+), 75 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 09dbf338a51..553a32b2a4d 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2562,39 +2562,31 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb,
/**
- * Common code called by glFramebufferTexture1D/2D/3D() and
- * glFramebufferTextureLayer().
+ * Common code called by gl*FramebufferTexture*() to retrieve the correct
+ * texture object pointer and check for associated errors.
*
* \param textarget is the textarget that was passed to the
* glFramebufferTexture...() function, or 0 if the corresponding function
* doesn't have a textarget parameter.
*
* \param layered is true if this function was called from
- * glFramebufferTexture(), false otherwise.
+ * gl*FramebufferTexture(), false otherwise.
+ *
+ * \param texObj where the pointer to the texture object is returned. Note
+ * that a successful call may return texObj = NULL.
+ *
+ * \return true if no errors, false if errors
*/
-static void
-framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
- GLenum attachment, GLenum textarget, GLuint texture,
- GLint level, GLuint zoffset, GLboolean layered)
+static bool
+get_texture_for_framebuffer(struct gl_context *ctx,
+ GLuint texture, GLenum textarget,
+ GLint level, GLuint zoffset, GLboolean *layered,
+ const char *caller,
+ struct gl_texture_object **texObj)
{
- struct gl_renderbuffer_attachment *att;
- struct gl_texture_object *texObj = NULL;
- struct gl_framebuffer *fb;
GLenum maxLevelsTarget;
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferTexture%s(target=0x%x)", caller, target);
- return;
- }
-
- /* check framebuffer binding */
- if (_mesa_is_winsys_fbo(fb)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture%s", caller);
- return;
- }
+ *texObj = NULL; /* This will get returned if texture = 0. */
/* The textarget, level, and zoffset parameters are only validated if
* texture is non-zero.
@@ -2602,14 +2594,14 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
if (texture) {
GLboolean err = GL_TRUE;
- texObj = _mesa_lookup_texture(ctx, texture);
- if (texObj != NULL && texObj->Target != 0) {
+ *texObj = _mesa_lookup_texture(ctx, texture);
+ if (*texObj != NULL && (*texObj)->Target != 0) {
if (textarget == 0) {
- if (layered) {
- /* We're being called by glFramebufferTexture() and textarget
+ if (*layered) {
+ /* We're being called by gl*FramebufferTexture() and textarget
* is not used.
*/
- switch (texObj->Target) {
+ switch ((*texObj)->Target) {
case GL_TEXTURE_3D:
case GL_TEXTURE_1D_ARRAY_EXT:
case GL_TEXTURE_2D_ARRAY_EXT:
@@ -2627,8 +2619,8 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
* is equivalent to calling glFramebufferTexture{1D,2D}().
*/
err = false;
- layered = false;
- textarget = texObj->Target;
+ *layered = false;
+ textarget = (*texObj)->Target;
break;
default:
err = true;
@@ -2639,18 +2631,18 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
* textarget is not used. The only legal texture types for
* that function are 3D and 1D/2D arrays textures.
*/
- err = (texObj->Target != GL_TEXTURE_3D) &&
- (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
- (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
- (texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
- (texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
+ err = ((*texObj)->Target != GL_TEXTURE_3D) &&
+ ((*texObj)->Target != GL_TEXTURE_1D_ARRAY) &&
+ ((*texObj)->Target != GL_TEXTURE_2D_ARRAY) &&
+ ((*texObj)->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
+ ((*texObj)->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
}
}
else {
/* Make sure textarget is consistent with the texture's type */
- err = (texObj->Target == GL_TEXTURE_CUBE_MAP)
+ err = ((*texObj)->Target == GL_TEXTURE_CUBE_MAP)
? !_mesa_is_cube_face(textarget)
- : (texObj->Target != textarget);
+ : ((*texObj)->Target != textarget);
}
}
else {
@@ -2659,22 +2651,21 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
* The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
* Managing Framebuffer Objects specifies a different error
* depending upon the calling function (PDF pages 325-328).
- * *FramebufferTexture (where layered = GL_TRUE) throws invalid
+ * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
* value, while the other commands throw invalid operation (where
- * layered = GL_FALSE).
+ * *layered = GL_FALSE).
*/
- const GLenum error = layered ? GL_INVALID_VALUE :
+ const GLenum error = *layered ? GL_INVALID_VALUE :
GL_INVALID_OPERATION;
_mesa_error(ctx, error,
"%s(non-existent texture %u)", caller, texture);
- return;
+ return false;
}
if (err) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture%s(texture target mismatch)",
- caller);
- return;
+ "%s(invalid or mismatched texture target)", caller);
+ return false;
}
/* Page 306 (page 328 of the PDF) of the OpenGL 4.5 (Core Profile)
@@ -2685,42 +2676,64 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
*/
if (zoffset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFramebufferTexture%s(layer %u < 0)", caller, zoffset);
- return;
+ "%s(layer %u < 0)", caller, zoffset);
+ return false;
}
- if (texObj->Target == GL_TEXTURE_3D) {
+ if ((*texObj)->Target == GL_TEXTURE_3D) {
const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
if (zoffset >= maxSize) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFramebufferTexture%s(zoffset)", caller);
- return;
+ "%s(invalid zoffset %u)", caller, zoffset);
+ return false;
}
}
- else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) ||
- (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT) ||
- (texObj->Target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
- (texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
+ else if (((*texObj)->Target == GL_TEXTURE_1D_ARRAY) ||
+ ((*texObj)->Target == GL_TEXTURE_2D_ARRAY) ||
+ ((*texObj)->Target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
+ ((*texObj)->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
if (zoffset >= ctx->Const.MaxArrayTextureLayers) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFramebufferTexture%s(layer)", caller);
- return;
+ "%s(layer %u >= GL_MAX_ARRAY_TEXTURE_LAYERS)",
+ caller, zoffset);
+ return false;
}
}
- maxLevelsTarget = textarget ? textarget : texObj->Target;
+ maxLevelsTarget = textarget ? textarget : (*texObj)->Target;
if ((level < 0) ||
(level >= _mesa_max_texture_levels(ctx, maxLevelsTarget))) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFramebufferTexture%s(level)", caller);
- return;
+ "%s(invalid level %d)", caller, level);
+ return false;
}
}
+ return true;
+}
+
+
+void
+_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_texture_object *texObj, GLenum textarget,
+ GLint level, GLuint zoffset, GLboolean layered,
+ const char *caller)
+{
+ struct gl_renderbuffer_attachment *att;
+
+ /* The window-system framebuffer object is immutable */
+ if (_mesa_is_winsys_fbo(fb)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(window-system framebuffer)",
+ caller);
+ return;
+ }
+
+ /* Not a hash lookup, so we can afford to get the attachment here. */
att = get_attachment(ctx, fb, attachment);
if (att == NULL) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferTexture%s(attachment)", caller);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
+ _mesa_lookup_enum_by_nr(attachment));
return;
}
@@ -2794,6 +2807,9 @@ _mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered = GL_FALSE;
if (texture != 0) {
GLboolean error;
@@ -2811,14 +2827,31 @@ _mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
if (error) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture1D(textarget=%s)",
+ "glFramebufferTexture1D(invalid textarget %s)",
_mesa_lookup_enum_by_nr(textarget));
return;
}
}
- framebuffer_texture(ctx, "1D", target, attachment, textarget, texture,
- level, 0, GL_FALSE);
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture1D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, textarget, level, 0,
+ &layered, "glFramebufferTexture1D",
+ &texObj)) {
+ /* Error already recorded */
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
+ 0, layered, "glFramebufferTexture1D");
}
@@ -2827,6 +2860,9 @@ _mesa_FramebufferTexture2D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered = GL_FALSE;
if (texture != 0) {
GLboolean error;
@@ -2862,14 +2898,31 @@ _mesa_FramebufferTexture2D(GLenum target, GLenum attachment,
if (error) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture2D(textarget=%s)",
+ "glFramebufferTexture2D(invalid textarget %s)",
_mesa_lookup_enum_by_nr(textarget));
return;
}
}
- framebuffer_texture(ctx, "2D", target, attachment, textarget, texture,
- level, 0, GL_FALSE);
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture2D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, textarget, level, 0,
+ &layered, "glFramebufferTexture2D",
+ &texObj)) {
+ /* Error already recorded */
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
+ 0, layered, "glFramebufferTexture2D");
}
@@ -2879,15 +2932,36 @@ _mesa_FramebufferTexture3D(GLenum target, GLenum attachment,
GLint level, GLint zoffset)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered = GL_FALSE;
if ((texture != 0) && (textarget != GL_TEXTURE_3D)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture3D(textarget)");
+ "glFramebufferTexture3D(invalid textarget %s)",
+ _mesa_lookup_enum_by_nr(textarget));
return;
}
- framebuffer_texture(ctx, "3D", target, attachment, textarget, texture,
- level, zoffset, GL_FALSE);
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture3D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, textarget, level, zoffset,
+ &layered, "glFramebufferTexture3D",
+ &texObj)) {
+ /* Error already recorded */
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
+ zoffset, layered, "glFramebufferTexture3D");
}
@@ -2896,9 +2970,29 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
GLuint texture, GLint level, GLint layer)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered = GL_FALSE;
- framebuffer_texture(ctx, "Layer", target, attachment, 0, texture,
- level, layer, GL_FALSE);
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTextureLayer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, 0, level, layer,
+ &layered, "glFramebufferTextureLayer",
+ &texObj)) {
+ /* Error already recorded */
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ layer, layered, "glFramebufferTextureLayer");
}
@@ -2907,14 +3001,35 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
GLuint texture, GLint level)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered = GL_TRUE;
- if (_mesa_has_geometry_shaders(ctx)) {
- framebuffer_texture(ctx, "", target, attachment, 0, texture,
- level, 0, GL_TRUE);
- } else {
+ if (!_mesa_has_geometry_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"unsupported function (glFramebufferTexture) called");
+ return;
}
+
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, 0, level, 0,
+ &layered, "glFramebufferTexture",
+ &texObj)) {
+ /* Error already recorded */
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ 0, layered, "glFramebufferTexture");
}
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 63b76f1ed49..974cd568f27 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -115,6 +115,14 @@ _mesa_detach_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
const void *att);
+extern void
+_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_texture_object *texObj, GLenum textarget,
+ GLint level, GLuint zoffset, GLboolean layered,
+ const char *caller);
+
+
extern GLboolean GLAPIENTRY
_mesa_IsRenderbuffer(GLuint renderbuffer);
From a9f73f7f42081594d0ba9ff6cb7a0a743c3cad93 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 2 Mar 2015 13:41:13 -0800
Subject: [PATCH 072/834] main: Refactor get_texture_for_framebuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This moves a few blocks around so that the control flow is more obvious. If
the texture is 0, just return true at the beginning of the function.
Likewise, if the texObj is NULL, return true at the beginning of the function
as well.
[Fredrik: Fix the texObj NULL check]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 43 ++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 553a32b2a4d..f1c0780318c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2585,17 +2585,34 @@ get_texture_for_framebuffer(struct gl_context *ctx,
struct gl_texture_object **texObj)
{
GLenum maxLevelsTarget;
+ GLboolean err = GL_TRUE;
*texObj = NULL; /* This will get returned if texture = 0. */
/* The textarget, level, and zoffset parameters are only validated if
* texture is non-zero.
*/
- if (texture) {
- GLboolean err = GL_TRUE;
+ if (!texture)
+ return true;
+
+ *texObj = _mesa_lookup_texture(ctx, texture);
+ if (*texObj == NULL || (*texObj)->Target == 0) {
+ /* Can't render to a non-existent texture object.
+ *
+ * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
+ * Managing Framebuffer Objects specifies a different error
+ * depending upon the calling function (PDF pages 325-328).
+ * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
+ * value, while the other commands throw invalid operation (where
+ * *layered = GL_FALSE).
+ */
+ const GLenum error = *layered ? GL_INVALID_VALUE :
+ GL_INVALID_OPERATION;
+ _mesa_error(ctx, error,
+ "%s(non-existent texture %u)", caller, texture);
+ return false;
+ }
- *texObj = _mesa_lookup_texture(ctx, texture);
- if (*texObj != NULL && (*texObj)->Target != 0) {
if (textarget == 0) {
if (*layered) {
/* We're being called by gl*FramebufferTexture() and textarget
@@ -2644,23 +2661,6 @@ get_texture_for_framebuffer(struct gl_context *ctx,
? !_mesa_is_cube_face(textarget)
: ((*texObj)->Target != textarget);
}
- }
- else {
- /* Can't render to a non-existent texture object.
- *
- * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
- * Managing Framebuffer Objects specifies a different error
- * depending upon the calling function (PDF pages 325-328).
- * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
- * value, while the other commands throw invalid operation (where
- * *layered = GL_FALSE).
- */
- const GLenum error = *layered ? GL_INVALID_VALUE :
- GL_INVALID_OPERATION;
- _mesa_error(ctx, error,
- "%s(non-existent texture %u)", caller, texture);
- return false;
- }
if (err) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -2707,7 +2707,6 @@ get_texture_for_framebuffer(struct gl_context *ctx,
"%s(invalid level %d)", caller, level);
return false;
}
- }
return true;
}
From a602b21f94ded038f9781cc02ab46cdaab868f14 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 2 Mar 2015 13:43:09 -0800
Subject: [PATCH 073/834] main: Fix indentation in get_texture_for_framebuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 170 +++++++++++++++++++--------------------
1 file changed, 85 insertions(+), 85 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f1c0780318c..dc730c8695c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2613,100 +2613,100 @@ get_texture_for_framebuffer(struct gl_context *ctx,
return false;
}
- if (textarget == 0) {
- if (*layered) {
- /* We're being called by gl*FramebufferTexture() and textarget
- * is not used.
- */
- switch ((*texObj)->Target) {
- case GL_TEXTURE_3D:
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- err = false;
- break;
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_RECTANGLE:
- case GL_TEXTURE_2D_MULTISAMPLE:
- /* These texture types are valid to pass to
- * glFramebufferTexture(), but since they aren't layered, it
- * is equivalent to calling glFramebufferTexture{1D,2D}().
- */
- err = false;
- *layered = false;
- textarget = (*texObj)->Target;
- break;
- default:
- err = true;
- break;
- }
- } else {
- /* We're being called by glFramebufferTextureLayer() and
- * textarget is not used. The only legal texture types for
- * that function are 3D and 1D/2D arrays textures.
- */
- err = ((*texObj)->Target != GL_TEXTURE_3D) &&
- ((*texObj)->Target != GL_TEXTURE_1D_ARRAY) &&
- ((*texObj)->Target != GL_TEXTURE_2D_ARRAY) &&
- ((*texObj)->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
- ((*texObj)->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
- }
+ if (textarget == 0) {
+ if (*layered) {
+ /* We're being called by gl*FramebufferTexture() and textarget
+ * is not used.
+ */
+ switch ((*texObj)->Target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ err = false;
+ break;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ /* These texture types are valid to pass to
+ * glFramebufferTexture(), but since they aren't layered, it
+ * is equivalent to calling glFramebufferTexture{1D,2D}().
+ */
+ err = false;
+ *layered = false;
+ textarget = (*texObj)->Target;
+ break;
+ default:
+ err = true;
+ break;
}
- else {
- /* Make sure textarget is consistent with the texture's type */
- err = ((*texObj)->Target == GL_TEXTURE_CUBE_MAP)
- ? !_mesa_is_cube_face(textarget)
- : ((*texObj)->Target != textarget);
- }
-
- if (err) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid or mismatched texture target)", caller);
- return false;
+ } else {
+ /* We're being called by glFramebufferTextureLayer() and
+ * textarget is not used. The only legal texture types for
+ * that function are 3D and 1D/2D arrays textures.
+ */
+ err = ((*texObj)->Target != GL_TEXTURE_3D) &&
+ ((*texObj)->Target != GL_TEXTURE_1D_ARRAY) &&
+ ((*texObj)->Target != GL_TEXTURE_2D_ARRAY) &&
+ ((*texObj)->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
+ ((*texObj)->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
}
+ }
+ else {
+ /* Make sure textarget is consistent with the texture's type */
+ err = ((*texObj)->Target == GL_TEXTURE_CUBE_MAP)
+ ? !_mesa_is_cube_face(textarget)
+ : ((*texObj)->Target != textarget);
+ }
- /* Page 306 (page 328 of the PDF) of the OpenGL 4.5 (Core Profile)
- * spec says:
- *
- * "An INVALID_VALUE error is generated if texture is non-zero
- * and layer is negative."
- */
- if (zoffset < 0) {
+ if (err) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid or mismatched texture target)", caller);
+ return false;
+ }
+
+ /* Page 306 (page 328 of the PDF) of the OpenGL 4.5 (Core Profile)
+ * spec says:
+ *
+ * "An INVALID_VALUE error is generated if texture is non-zero
+ * and layer is negative."
+ */
+ if (zoffset < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(layer %u < 0)", caller, zoffset);
+ return false;
+ }
+
+ if ((*texObj)->Target == GL_TEXTURE_3D) {
+ const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
+ if (zoffset >= maxSize) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "%s(layer %u < 0)", caller, zoffset);
+ "%s(invalid zoffset %u)", caller, zoffset);
return false;
}
-
- if ((*texObj)->Target == GL_TEXTURE_3D) {
- const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
- if (zoffset >= maxSize) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(invalid zoffset %u)", caller, zoffset);
- return false;
- }
- }
- else if (((*texObj)->Target == GL_TEXTURE_1D_ARRAY) ||
- ((*texObj)->Target == GL_TEXTURE_2D_ARRAY) ||
- ((*texObj)->Target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
- ((*texObj)->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
- if (zoffset >= ctx->Const.MaxArrayTextureLayers) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(layer %u >= GL_MAX_ARRAY_TEXTURE_LAYERS)",
- caller, zoffset);
- return false;
- }
- }
-
- maxLevelsTarget = textarget ? textarget : (*texObj)->Target;
- if ((level < 0) ||
- (level >= _mesa_max_texture_levels(ctx, maxLevelsTarget))) {
+ }
+ else if (((*texObj)->Target == GL_TEXTURE_1D_ARRAY) ||
+ ((*texObj)->Target == GL_TEXTURE_2D_ARRAY) ||
+ ((*texObj)->Target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
+ ((*texObj)->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
+ if (zoffset >= ctx->Const.MaxArrayTextureLayers) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "%s(invalid level %d)", caller, level);
+ "%s(layer %u >= GL_MAX_ARRAY_TEXTURE_LAYERS)",
+ caller, zoffset);
return false;
}
+ }
+
+ maxLevelsTarget = textarget ? textarget : (*texObj)->Target;
+ if ((level < 0) ||
+ (level >= _mesa_max_texture_levels(ctx, maxLevelsTarget))) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(invalid level %d)", caller, level);
+ return false;
+ }
return true;
}
From d78c831a147e8af6f6fc1a610f4c2e490e75fad1 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Wed, 28 Jan 2015 13:19:57 -0800
Subject: [PATCH 074/834] main: Add entry points for
glNamedFramebufferTexture[Layer].
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 15 +++++
src/mesa/main/fbobject.c | 64 +++++++++++++++++++
src/mesa/main/fbobject.h | 8 +++
src/mesa/main/tests/dispatch_sanity.cpp | 2 +
4 files changed, 89 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index f228a5286a7..b8e90aadd45 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -166,6 +166,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index dc730c8695c..8f759fba809 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2995,6 +2995,36 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
}
+void GLAPIENTRY
+_mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level, GLint layer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered = GL_FALSE;
+
+ /* Get the framebuffer object */
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferTextureLayer");
+ if (!fb)
+ return;
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, 0, level, layer,
+ &layered,
+ "glNamedFramebufferTextureLayer",
+ &texObj)) {
+ /* Error already recorded */
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ layer, layered,
+ "glNamedFramebufferTextureLayer");
+}
+
+
void GLAPIENTRY
_mesa_FramebufferTexture(GLenum target, GLenum attachment,
GLuint texture, GLint level)
@@ -3032,6 +3062,40 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
}
+void GLAPIENTRY
+_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered = GL_TRUE;
+
+ if (!_mesa_has_geometry_shaders(ctx)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "unsupported function (glNamedFramebufferTexture) called");
+ return;
+ }
+
+ /* Get the framebuffer object */
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferTexture");
+ if (!fb)
+ return;
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, 0, level, 0,
+ &layered, "glNamedFramebufferTexture",
+ &texObj)) {
+ /* Error already recorded */
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ 0, layered, "glNamedFramebufferTexture");
+}
+
+
void
_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 974cd568f27..81159d0efa9 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -212,10 +212,18 @@ extern void GLAPIENTRY
_mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
GLuint texture, GLint level, GLint layer);
+extern void GLAPIENTRY
+_mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level, GLint layer);
+
extern void GLAPIENTRY
_mesa_FramebufferTexture(GLenum target, GLenum attachment,
GLuint texture, GLint level);
+extern void GLAPIENTRY
+_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level);
+
extern void GLAPIENTRY
_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 32b082bcb28..0994d437e24 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -982,6 +982,8 @@ const struct function gl_core_functions_possible[] = {
{ "glGetNamedBufferSubData", 45, -1 },
{ "glCreateFramebuffers", 45, -1 },
{ "glNamedFramebufferRenderbuffer", 45, -1 },
+ { "glNamedFramebufferTexture", 45, -1 },
+ { "glNamedFramebufferTextureLayer", 45, -1 },
{ "glCreateRenderbuffers", 45, -1 },
{ "glNamedRenderbufferStorage", 45, -1 },
{ "glNamedRenderbufferStorageMultisample", 45, -1 },
From 085c67dc77ab3c00d3f68ba52f8343f8ff0cab53 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 2 Mar 2015 16:48:59 -0800
Subject: [PATCH 075/834] main: Major refactor of get_texture_for_framebuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This splits off the (still) rather large chunk that is
get_texture_for_framebuffer into lots of smaller functions specialized to
service the wide variety of unique needs of *FramebufferTexture* entry points.
The result is much cleaner because, rather than having a pile of branches and
confusing conditions (like the boolean layered), the uniqueness is baked into
the entry points. The entry points know whether or not they are layered or use
a textarget.
[Fredrik: - Mention the value of in the error message.
- Rename check_zoffset to check_layer, and zoffset to layer.
The zoffset parameter was renamed to layer in
ARB_framebuffer_object.
- Make layered a GLboolean since the value is visible to the API.
- Remove EXT suffixes in refactored code.
- Whitespace fixes.]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mapi/glapi/gen/ARB_framebuffer_object.xml | 2 +-
src/mesa/main/fbobject.c | 494 ++++++++++--------
src/mesa/main/fbobject.h | 4 +-
3 files changed, 270 insertions(+), 230 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_framebuffer_object.xml b/src/mapi/glapi/gen/ARB_framebuffer_object.xml
index 7c547c16742..999a8ef13ad 100644
--- a/src/mapi/glapi/gen/ARB_framebuffer_object.xml
+++ b/src/mapi/glapi/gen/ARB_framebuffer_object.xml
@@ -247,7 +247,7 @@
-
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8f759fba809..807b629507b 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -465,7 +465,7 @@ set_texture_attachment(struct gl_context *ctx,
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att,
struct gl_texture_object *texObj,
- GLenum texTarget, GLuint level, GLuint zoffset,
+ GLenum texTarget, GLuint level, GLuint layer,
GLboolean layered)
{
struct gl_renderbuffer *rb = att->Renderbuffer;
@@ -489,7 +489,7 @@ set_texture_attachment(struct gl_context *ctx,
/* always update these fields */
att->TextureLevel = level;
att->CubeMapFace = _mesa_tex_target_to_face(texTarget);
- att->Zoffset = zoffset;
+ att->Zoffset = layer;
att->Layered = layered;
att->Complete = GL_FALSE;
@@ -2563,14 +2563,7 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb,
/**
* Common code called by gl*FramebufferTexture*() to retrieve the correct
- * texture object pointer and check for associated errors.
- *
- * \param textarget is the textarget that was passed to the
- * glFramebufferTexture...() function, or 0 if the corresponding function
- * doesn't have a textarget parameter.
- *
- * \param layered is true if this function was called from
- * gl*FramebufferTexture(), false otherwise.
+ * texture object pointer.
*
* \param texObj where the pointer to the texture object is returned. Note
* that a successful call may return texObj = NULL.
@@ -2578,20 +2571,12 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb,
* \return true if no errors, false if errors
*/
static bool
-get_texture_for_framebuffer(struct gl_context *ctx,
- GLuint texture, GLenum textarget,
- GLint level, GLuint zoffset, GLboolean *layered,
- const char *caller,
+get_texture_for_framebuffer(struct gl_context *ctx, GLuint texture,
+ bool layered, const char *caller,
struct gl_texture_object **texObj)
{
- GLenum maxLevelsTarget;
- GLboolean err = GL_TRUE;
-
*texObj = NULL; /* This will get returned if texture = 0. */
- /* The textarget, level, and zoffset parameters are only validated if
- * texture is non-zero.
- */
if (!texture)
return true;
@@ -2602,31 +2587,45 @@ get_texture_for_framebuffer(struct gl_context *ctx,
* The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
* Managing Framebuffer Objects specifies a different error
* depending upon the calling function (PDF pages 325-328).
- * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
+ * *FramebufferTexture (where layered = GL_TRUE) throws invalid
* value, while the other commands throw invalid operation (where
- * *layered = GL_FALSE).
+ * layered = GL_FALSE).
*/
- const GLenum error = *layered ? GL_INVALID_VALUE :
+ const GLenum error = layered ? GL_INVALID_VALUE :
GL_INVALID_OPERATION;
_mesa_error(ctx, error,
"%s(non-existent texture %u)", caller, texture);
return false;
}
- if (textarget == 0) {
- if (*layered) {
- /* We're being called by gl*FramebufferTexture() and textarget
- * is not used.
- */
- switch ((*texObj)->Target) {
+ return true;
+}
+
+
+/**
+ * Common code called by gl*FramebufferTexture() to verify the texture target
+ * and decide whether or not the attachment should truly be considered
+ * layered.
+ *
+ * \param layered true if attachment should be considered layered, false if
+ * not
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_layered_texture_target(struct gl_context *ctx, GLenum target,
+ const char *caller, GLboolean *layered)
+{
+ *layered = GL_TRUE;
+
+ switch (target) {
case GL_TEXTURE_3D:
case GL_TEXTURE_1D_ARRAY_EXT:
case GL_TEXTURE_2D_ARRAY_EXT:
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_CUBE_MAP_ARRAY:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- err = false;
- break;
+ return true;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_RECTANGLE:
@@ -2635,74 +2634,187 @@ get_texture_for_framebuffer(struct gl_context *ctx,
* glFramebufferTexture(), but since they aren't layered, it
* is equivalent to calling glFramebufferTexture{1D,2D}().
*/
- err = false;
- *layered = false;
- textarget = (*texObj)->Target;
- break;
- default:
- err = true;
- break;
+ *layered = GL_FALSE;
+ return true;
}
- } else {
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid texture target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
+ return false;
+}
+
+
+/**
+ * Common code called by gl*FramebufferTextureLayer() to verify the texture
+ * target.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_texture_target(struct gl_context *ctx, GLenum target,
+ const char *caller)
+{
/* We're being called by glFramebufferTextureLayer() and
* textarget is not used. The only legal texture types for
* that function are 3D and 1D/2D arrays textures.
*/
- err = ((*texObj)->Target != GL_TEXTURE_3D) &&
- ((*texObj)->Target != GL_TEXTURE_1D_ARRAY) &&
- ((*texObj)->Target != GL_TEXTURE_2D_ARRAY) &&
- ((*texObj)->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
- ((*texObj)->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
+ switch (target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return true;
+ }
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid texture target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
+ return false;
+}
+
+
+/**
+ * Common code called by glFramebufferTexture*D() to verify the texture
+ * target.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_textarget(struct gl_context *ctx, int dims, GLenum target,
+ GLenum textarget, const char *caller)
+{
+ bool err = false;
+
+ switch (dims) {
+ case 1:
+ switch (textarget) {
+ case GL_TEXTURE_1D:
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ err = !ctx->Extensions.EXT_texture_array;
+ break;
+ default:
+ err = true;
}
- }
- else {
- /* Make sure textarget is consistent with the texture's type */
- err = ((*texObj)->Target == GL_TEXTURE_CUBE_MAP)
- ? !_mesa_is_cube_face(textarget)
- : ((*texObj)->Target != textarget);
+ break;
+ case 2:
+ switch (textarget) {
+ case GL_TEXTURE_2D:
+ break;
+ case GL_TEXTURE_RECTANGLE:
+ err = _mesa_is_gles(ctx)
+ || !ctx->Extensions.NV_texture_rectangle;
+ break;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ err = !ctx->Extensions.ARB_texture_cube_map;
+ break;
+ case GL_TEXTURE_2D_ARRAY:
+ err = (_mesa_is_gles(ctx) && ctx->Version < 30)
+ || !ctx->Extensions.EXT_texture_array;
+ break;
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ err = _mesa_is_gles(ctx)
+ || !ctx->Extensions.ARB_texture_multisample;
+ break;
+ default:
+ err = true;
+ }
+ break;
+ case 3:
+ if (textarget != GL_TEXTURE_3D)
+ err = true;
+ break;
+ default:
+ err = true;
}
if (err) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid or mismatched texture target)", caller);
+ "%s(invalid textarget %s)",
+ caller, _mesa_lookup_enum_by_nr(textarget));
return false;
}
+ /* Make sure textarget is consistent with the texture's type */
+ err = (target == GL_TEXTURE_CUBE_MAP) ?
+ !_mesa_is_cube_face(textarget): (target != textarget);
+
+ if (err) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(mismatched texture target)", caller);
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * Common code called by gl*FramebufferTextureLayer() and
+ * glFramebufferTexture3D() to validate the layer.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_layer(struct gl_context *ctx, GLenum target, GLint layer,
+ const char *caller)
+{
/* Page 306 (page 328 of the PDF) of the OpenGL 4.5 (Core Profile)
* spec says:
*
* "An INVALID_VALUE error is generated if texture is non-zero
* and layer is negative."
*/
- if (zoffset < 0) {
+ if (layer < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "%s(layer %u < 0)", caller, zoffset);
+ "%s(layer %u < 0)", caller, layer);
return false;
}
- if ((*texObj)->Target == GL_TEXTURE_3D) {
+ if (target == GL_TEXTURE_3D) {
const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
- if (zoffset >= maxSize) {
+ if (layer >= maxSize) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "%s(invalid zoffset %u)", caller, zoffset);
+ "%s(invalid layer %u)", caller, layer);
return false;
}
}
- else if (((*texObj)->Target == GL_TEXTURE_1D_ARRAY) ||
- ((*texObj)->Target == GL_TEXTURE_2D_ARRAY) ||
- ((*texObj)->Target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
- ((*texObj)->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
- if (zoffset >= ctx->Const.MaxArrayTextureLayers) {
+ else if ((target == GL_TEXTURE_1D_ARRAY) ||
+ (target == GL_TEXTURE_2D_ARRAY) ||
+ (target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
+ (target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
+ if (layer >= ctx->Const.MaxArrayTextureLayers) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(layer %u >= GL_MAX_ARRAY_TEXTURE_LAYERS)",
- caller, zoffset);
+ caller, layer);
return false;
}
}
- maxLevelsTarget = textarget ? textarget : (*texObj)->Target;
+ return true;
+}
+
+
+/**
+ * Common code called by all gl*FramebufferTexture*() entry points to verify
+ * the level.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_level(struct gl_context *ctx, GLenum target, GLint level,
+ const char *caller)
+{
if ((level < 0) ||
- (level >= _mesa_max_texture_levels(ctx, maxLevelsTarget))) {
+ (level >= _mesa_max_texture_levels(ctx, target))) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(invalid level %d)", caller, level);
return false;
@@ -2716,7 +2828,7 @@ void
_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment,
struct gl_texture_object *texObj, GLenum textarget,
- GLint level, GLuint zoffset, GLboolean layered,
+ GLint level, GLuint layer, GLboolean layered,
const char *caller)
{
struct gl_renderbuffer_attachment *att;
@@ -2745,7 +2857,7 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
level == fb->Attachment[BUFFER_STENCIL].TextureLevel &&
_mesa_tex_target_to_face(textarget) ==
fb->Attachment[BUFFER_STENCIL].CubeMapFace &&
- zoffset == fb->Attachment[BUFFER_STENCIL].Zoffset) {
+ layer == fb->Attachment[BUFFER_STENCIL].Zoffset) {
/* The texture object is already attached to the stencil attachment
* point. Don't create a new renderbuffer; just reuse the stencil
* attachment's. This is required to prevent a GL error in
@@ -2758,13 +2870,13 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
level == fb->Attachment[BUFFER_DEPTH].TextureLevel &&
_mesa_tex_target_to_face(textarget) ==
fb->Attachment[BUFFER_DEPTH].CubeMapFace &&
- zoffset == fb->Attachment[BUFFER_DEPTH].Zoffset) {
+ layer == fb->Attachment[BUFFER_DEPTH].Zoffset) {
/* As above, but with depth and stencil transposed. */
reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL,
BUFFER_DEPTH);
} else {
set_texture_attachment(ctx, fb, att, texObj, textarget,
- level, zoffset, layered);
+ level, layer, layered);
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
/* Above we created a new renderbuffer and attached it to the
@@ -2801,56 +2913,50 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
}
-void GLAPIENTRY
-_mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture, GLint level)
+static void
+framebuffer_texture_with_dims(int dims, GLenum target,
+ GLenum attachment, GLenum textarget,
+ GLuint texture, GLint level, GLint layer,
+ const char *caller)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
- GLboolean layered = GL_FALSE;
-
- if (texture != 0) {
- GLboolean error;
-
- switch (textarget) {
- case GL_TEXTURE_1D:
- error = GL_FALSE;
- break;
- case GL_TEXTURE_1D_ARRAY:
- error = !ctx->Extensions.EXT_texture_array;
- break;
- default:
- error = GL_TRUE;
- }
-
- if (error) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture1D(invalid textarget %s)",
- _mesa_lookup_enum_by_nr(textarget));
- return;
- }
- }
/* Get the framebuffer object */
fb = get_framebuffer_target(ctx, target);
if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferTexture1D(invalid target %s)",
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller,
_mesa_lookup_enum_by_nr(target));
return;
}
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, textarget, level, 0,
- &layered, "glFramebufferTexture1D",
- &texObj)) {
- /* Error already recorded */
+ if (!get_texture_for_framebuffer(ctx, texture, false, caller, &texObj))
return;
+
+ if (texObj) {
+ if (!check_textarget(ctx, dims, texObj->Target, textarget, caller))
+ return;
+
+ if ((dims == 3) && !check_layer(ctx, texObj->Target, layer, caller))
+ return;
}
+ if (!check_level(ctx, textarget, level, caller))
+ return;
+
_mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
- 0, layered, "glFramebufferTexture1D");
+ layer, GL_FALSE, caller);
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture, GLint level)
+{
+ framebuffer_texture_with_dims(1, target, attachment, textarget, texture,
+ level, 0, "glFramebufferTexture1D");
}
@@ -2858,109 +2964,18 @@ void GLAPIENTRY
_mesa_FramebufferTexture2D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_framebuffer *fb;
- struct gl_texture_object *texObj;
- GLboolean layered = GL_FALSE;
-
- if (texture != 0) {
- GLboolean error;
-
- switch (textarget) {
- case GL_TEXTURE_2D:
- error = GL_FALSE;
- break;
- case GL_TEXTURE_RECTANGLE:
- error = _mesa_is_gles(ctx)
- || !ctx->Extensions.NV_texture_rectangle;
- break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- error = !ctx->Extensions.ARB_texture_cube_map;
- break;
- case GL_TEXTURE_2D_ARRAY:
- error = (_mesa_is_gles(ctx) && ctx->Version < 30)
- || !ctx->Extensions.EXT_texture_array;
- break;
- case GL_TEXTURE_2D_MULTISAMPLE:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- error = _mesa_is_gles(ctx)
- || !ctx->Extensions.ARB_texture_multisample;
- break;
- default:
- error = GL_TRUE;
- }
-
- if (error) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture2D(invalid textarget %s)",
- _mesa_lookup_enum_by_nr(textarget));
- return;
- }
- }
-
- /* Get the framebuffer object */
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferTexture2D(invalid target %s)",
- _mesa_lookup_enum_by_nr(target));
- return;
- }
-
- /* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, textarget, level, 0,
- &layered, "glFramebufferTexture2D",
- &texObj)) {
- /* Error already recorded */
- return;
- }
-
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
- 0, layered, "glFramebufferTexture2D");
+ framebuffer_texture_with_dims(2, target, attachment, textarget, texture,
+ level, 0, "glFramebufferTexture2D");
}
void GLAPIENTRY
_mesa_FramebufferTexture3D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
- GLint level, GLint zoffset)
+ GLint level, GLint layer)
{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_framebuffer *fb;
- struct gl_texture_object *texObj;
- GLboolean layered = GL_FALSE;
-
- if ((texture != 0) && (textarget != GL_TEXTURE_3D)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture3D(invalid textarget %s)",
- _mesa_lookup_enum_by_nr(textarget));
- return;
- }
-
- /* Get the framebuffer object */
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferTexture3D(invalid target %s)",
- _mesa_lookup_enum_by_nr(target));
- return;
- }
-
- /* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, textarget, level, zoffset,
- &layered, "glFramebufferTexture3D",
- &texObj)) {
- /* Error already recorded */
- return;
- }
-
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
- zoffset, layered, "glFramebufferTexture3D");
+ framebuffer_texture_with_dims(3, target, attachment, textarget, texture,
+ level, layer, "glFramebufferTexture3D");
}
@@ -2971,7 +2986,8 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
- GLboolean layered = GL_FALSE;
+
+ const char *func = "glFramebufferTextureLayer";
/* Get the framebuffer object */
fb = get_framebuffer_target(ctx, target);
@@ -2983,15 +2999,22 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
}
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, 0, level, layer,
- &layered, "glFramebufferTextureLayer",
- &texObj)) {
- /* Error already recorded */
+ if (!get_texture_for_framebuffer(ctx, texture, false, func, &texObj))
return;
+
+ if (texObj) {
+ if (!check_texture_target(ctx, texObj->Target, func))
+ return;
+
+ if (!check_layer(ctx, texObj->Target, layer, func))
+ return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
}
_mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
- layer, layered, "glFramebufferTextureLayer");
+ layer, GL_FALSE, func);
}
@@ -3002,26 +3025,31 @@ _mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
- GLboolean layered = GL_FALSE;
+
+ const char *func = "glNamedFramebufferTextureLayer";
/* Get the framebuffer object */
- fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
- "glNamedFramebufferTextureLayer");
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
if (!fb)
return;
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, 0, level, layer,
- &layered,
- "glNamedFramebufferTextureLayer",
- &texObj)) {
- /* Error already recorded */
+ if (!get_texture_for_framebuffer(ctx, texture, false, func, &texObj))
return;
+
+ if (texObj) {
+ if (!check_texture_target(ctx, texObj->Target, func))
+ return;
+
+ if (!check_layer(ctx, texObj->Target, layer, func))
+ return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
}
_mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
- layer, layered,
- "glNamedFramebufferTextureLayer");
+ layer, GL_FALSE, func);
}
@@ -3032,7 +3060,9 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
- GLboolean layered = GL_TRUE;
+ GLboolean layered;
+
+ const char *func = "FramebufferTexture";
if (!_mesa_has_geometry_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -3050,15 +3080,19 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
}
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, 0, level, 0,
- &layered, "glFramebufferTexture",
- &texObj)) {
- /* Error already recorded */
+ if (!get_texture_for_framebuffer(ctx, texture, true, func, &texObj))
return;
+
+ if (texObj) {
+ if (!check_layered_texture_target(ctx, texObj->Target, func, &layered))
+ return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
}
_mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
- 0, layered, "glFramebufferTexture");
+ 0, layered, func);
}
@@ -3069,7 +3103,9 @@ _mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
- GLboolean layered = GL_TRUE;
+ GLboolean layered;
+
+ const char *func = "glNamedFramebufferTexture";
if (!_mesa_has_geometry_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -3078,21 +3114,25 @@ _mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
}
/* Get the framebuffer object */
- fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
- "glNamedFramebufferTexture");
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
if (!fb)
return;
/* Get the texture object */
- if (!get_texture_for_framebuffer(ctx, texture, 0, level, 0,
- &layered, "glNamedFramebufferTexture",
- &texObj)) {
- /* Error already recorded */
+ if (!get_texture_for_framebuffer(ctx, texture, true, func, &texObj))
return;
+
+ if (texObj) {
+ if (!check_layered_texture_target(ctx, texObj->Target, func,
+ &layered))
+ return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
}
_mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
- 0, layered, "glNamedFramebufferTexture");
+ 0, layered, func);
}
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 81159d0efa9..e68762b429e 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -119,7 +119,7 @@ extern void
_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum attachment,
struct gl_texture_object *texObj, GLenum textarget,
- GLint level, GLuint zoffset, GLboolean layered,
+ GLint level, GLuint layer, GLboolean layered,
const char *caller);
@@ -206,7 +206,7 @@ _mesa_FramebufferTexture2D(GLenum target, GLenum attachment,
extern void GLAPIENTRY
_mesa_FramebufferTexture3D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
- GLint level, GLint zoffset);
+ GLint level, GLint layer);
extern void GLAPIENTRY
_mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
From 80e9bf2641d3bc2504fc12977c3e6a1ab7a3f49f Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 2 Mar 2015 16:52:55 -0800
Subject: [PATCH 076/834] main: Fix indents in former
get_texture_for_framebuffer functions.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 78 ++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 807b629507b..4da77a33706 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2618,30 +2618,30 @@ check_layered_texture_target(struct gl_context *ctx, GLenum target,
{
*layered = GL_TRUE;
- switch (target) {
- case GL_TEXTURE_3D:
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- return true;
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_RECTANGLE:
- case GL_TEXTURE_2D_MULTISAMPLE:
- /* These texture types are valid to pass to
- * glFramebufferTexture(), but since they aren't layered, it
- * is equivalent to calling glFramebufferTexture{1D,2D}().
- */
- *layered = GL_FALSE;
- return true;
- }
+ switch (target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return true;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ /* These texture types are valid to pass to
+ * glFramebufferTexture(), but since they aren't layered, it
+ * is equivalent to calling glFramebufferTexture{1D,2D}().
+ */
+ *layered = GL_FALSE;
+ return true;
+ }
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid texture target %s)", caller,
- _mesa_lookup_enum_by_nr(target));
- return false;
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid texture target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
+ return false;
}
@@ -2655,23 +2655,23 @@ static bool
check_texture_target(struct gl_context *ctx, GLenum target,
const char *caller)
{
- /* We're being called by glFramebufferTextureLayer() and
- * textarget is not used. The only legal texture types for
- * that function are 3D and 1D/2D arrays textures.
- */
- switch (target) {
- case GL_TEXTURE_3D:
- case GL_TEXTURE_1D_ARRAY:
- case GL_TEXTURE_2D_ARRAY:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- return true;
- }
+ /* We're being called by glFramebufferTextureLayer() and
+ * textarget is not used. The only legal texture types for
+ * that function are 3D and 1D/2D arrays textures.
+ */
+ switch (target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return true;
+ }
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid texture target %s)", caller,
- _mesa_lookup_enum_by_nr(target));
- return false;
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid texture target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
+ return false;
}
From f93f95928d39b13e6c263b480b3e4bfdfa218df8 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 29 Jan 2015 13:15:37 -0800
Subject: [PATCH 077/834] main: Add entry point for
CheckNamedFramebufferStatus.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: - Retain the debugging code in CheckFramebufferStatus.
- Whitespace fixes.]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 6 ++
src/mesa/main/fbobject.c | 79 +++++++++++++++----
src/mesa/main/fbobject.h | 7 ++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 78 insertions(+), 15 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index b8e90aadd45..1748950d120 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -181,6 +181,12 @@
+
+
+
+
+
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4da77a33706..ad7a85ccd9b 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2499,24 +2499,12 @@ _mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers)
}
-GLenum GLAPIENTRY
-_mesa_CheckFramebufferStatus(GLenum target)
+GLenum
+_mesa_check_framebuffer_status(struct gl_context *ctx,
+ struct gl_framebuffer *buffer)
{
- struct gl_framebuffer *buffer;
- GET_CURRENT_CONTEXT(ctx);
-
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glCheckFramebufferStatus(%s)\n",
- _mesa_lookup_enum_by_nr(target));
-
- buffer = get_framebuffer_target(ctx, target);
- if (!buffer) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)");
- return 0;
- }
-
if (_mesa_is_winsys_fbo(buffer)) {
/* EGL_KHR_surfaceless_context allows the winsys FBO to be incomplete. */
if (buffer != &IncompleteFramebuffer) {
@@ -2536,6 +2524,67 @@ _mesa_CheckFramebufferStatus(GLenum target)
}
+GLenum GLAPIENTRY
+_mesa_CheckFramebufferStatus(GLenum target)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCheckFramebufferStatus(%s)\n",
+ _mesa_lookup_enum_by_nr(target));
+
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCheckFramebufferStatus(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return 0;
+ }
+
+ return _mesa_check_framebuffer_status(ctx, fb);
+}
+
+
+GLenum GLAPIENTRY
+_mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* Validate the target (for conformance's sake) and grab a reference to the
+ * default framebuffer in case framebuffer = 0.
+ * Section 9.4 Framebuffer Completeness of the OpenGL 4.5 core spec
+ * (30.10.2014, PDF page 336) says:
+ * "If framebuffer is zero, then the status of the default read or
+ * draw framebuffer (as determined by target) is returned."
+ */
+ switch (target) {
+ case GL_DRAW_FRAMEBUFFER:
+ case GL_FRAMEBUFFER:
+ fb = ctx->WinSysDrawBuffer;
+ break;
+ case GL_READ_FRAMEBUFFER:
+ fb = ctx->WinSysReadBuffer;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCheckNamedFramebufferStatus(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return 0;
+ }
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glCheckNamedFramebufferStatus");
+ if (!fb)
+ return 0;
+ }
+
+ return _mesa_check_framebuffer_status(ctx, fb);
+}
+
+
/**
* Replicate the src attachment point. Used by framebuffer_texture() when
* the same texture is attached at GL_DEPTH_ATTACHMENT and
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index e68762b429e..871a2cc280e 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -122,6 +122,10 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
GLint level, GLuint layer, GLboolean layered,
const char *caller);
+extern GLenum
+_mesa_check_framebuffer_status(struct gl_context *ctx,
+ struct gl_framebuffer *fb);
+
extern GLboolean GLAPIENTRY
_mesa_IsRenderbuffer(GLuint renderbuffer);
@@ -195,6 +199,9 @@ _mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers);
extern GLenum GLAPIENTRY
_mesa_CheckFramebufferStatus(GLenum target);
+extern GLenum GLAPIENTRY
+_mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target);
+
extern void GLAPIENTRY
_mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 0994d437e24..fdfad348a6e 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -984,6 +984,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferRenderbuffer", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
+ { "glCheckNamedFramebufferStatus", 45, -1 },
{ "glCreateRenderbuffers", 45, -1 },
{ "glNamedRenderbufferStorage", 45, -1 },
{ "glNamedRenderbufferStorageMultisample", 45, -1 },
From f22fa307de780723e182d62a03c2c4c4f8a937f7 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 29 Jan 2015 17:11:37 -0800
Subject: [PATCH 078/834] main: Add entry point
GetNamedFramebufferAttachmentParameteriv.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: - Update one of the error messages to reflect that the
framebuffer might not be the bound framebuffer.
- Whitespace fixes.]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 7 +
src/mesa/main/fbobject.c | 124 ++++++++++++------
src/mesa/main/fbobject.h | 10 ++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 101 insertions(+), 41 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 1748950d120..beb6249a6f7 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -187,6 +187,13 @@
+
+
+
+
+
+
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index ad7a85ccd9b..15878d327c6 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3307,25 +3307,18 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
}
-void GLAPIENTRY
-_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
- GLenum pname, GLint *params)
+void
+_mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
+ struct gl_framebuffer *buffer,
+ GLenum attachment, GLenum pname,
+ GLint *params, const char *caller)
{
const struct gl_renderbuffer_attachment *att;
- struct gl_framebuffer *buffer;
GLenum err;
- GET_CURRENT_CONTEXT(ctx);
/* The error differs in GL and GLES. */
err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
- buffer = get_framebuffer_target(ctx, target);
- if (!buffer) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(target)");
- return;
- }
-
if (_mesa_is_winsys_fbo(buffer)) {
/* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec
* says:
@@ -3341,14 +3334,15 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
!ctx->Extensions.ARB_framebuffer_object)
&& !_mesa_is_gles3(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv(bound FBO = 0)");
+ "%s(window-system framebuffer)", caller);
return;
}
if (_mesa_is_gles3(ctx) && attachment != GL_BACK &&
attachment != GL_DEPTH && attachment != GL_STENCIL) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(attachment)");
+ "%s(invalid attachment %s)", caller,
+ _mesa_lookup_enum_by_nr(attachment));
return;
}
/* the default / window-system FBO */
@@ -3360,8 +3354,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
}
if (att == NULL) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(attachment)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
+ _mesa_lookup_enum_by_nr(attachment));
return;
}
@@ -3375,9 +3369,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
* attachment, since it does not have a single format."
*/
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv("
- "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
- " is invalid for depth+stencil attachment)");
+ "%s(GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
+ " is invalid for depth+stencil attachment)", caller);
return;
}
/* the depth and stencil attachments must point to the same buffer */
@@ -3385,8 +3378,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
stencilAtt = get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT);
if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv(DEPTH/STENCIL"
- " attachments differ)");
+ "%s(DEPTH/STENCIL attachments differ)", caller);
return;
}
}
@@ -3419,8 +3411,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
*params = att->TextureLevel;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
goto invalid_pname_enum;
@@ -3436,8 +3428,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
}
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
goto invalid_pname_enum;
@@ -3447,8 +3439,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
if (ctx->API == API_OPENGLES) {
goto invalid_pname_enum;
} else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
} else if (att->Type == GL_TEXTURE) {
if (att->Texture && (att->Texture->Target == GL_TEXTURE_3D ||
att->Texture->Target == GL_TEXTURE_2D_ARRAY)) {
@@ -3469,8 +3461,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
goto invalid_pname_enum;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
if (ctx->Extensions.EXT_framebuffer_sRGB) {
@@ -3492,8 +3484,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
goto invalid_pname_enum;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
mesa_format format = att->Renderbuffer->Format;
@@ -3508,9 +3500,9 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
if (_mesa_is_gles3(ctx) &&
attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv(cannot query "
+ "%s(cannot query "
"GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE of "
- "GL_DEPTH_STENCIL_ATTACHMENT");
+ "GL_DEPTH_STENCIL_ATTACHMENT)", caller);
return;
}
@@ -3544,8 +3536,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
goto invalid_pname_enum;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else if (att->Texture) {
const struct gl_texture_image *texImage =
@@ -3564,8 +3556,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
att->Renderbuffer->Format);
}
else {
- _mesa_problem(ctx, "glGetFramebufferAttachmentParameterivEXT:"
- " invalid FBO attachment structure");
+ _mesa_problem(ctx, "%s: invalid FBO attachment structure", caller);
}
return;
case GL_FRAMEBUFFER_ATTACHMENT_LAYERED:
@@ -3574,8 +3565,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
} else if (att->Type == GL_TEXTURE) {
*params = att->Layered;
} else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
} else {
goto invalid_pname_enum;
}
@@ -3587,12 +3578,63 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
return;
invalid_pname_enum:
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
return;
}
+void GLAPIENTRY
+_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
+ GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *buffer;
+
+ buffer = get_framebuffer_target(ctx, target);
+ if (!buffer) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameteriv(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ _mesa_get_framebuffer_attachment_parameter(ctx, buffer, attachment, pname,
+ params,
+ "glGetFramebufferAttachmentParameteriv");
+}
+
+
+void GLAPIENTRY
+_mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
+ GLenum attachment,
+ GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *buffer;
+
+ if (framebuffer) {
+ buffer = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glGetNamedFramebufferAttachmentParameteriv");
+ if (!buffer)
+ return;
+ }
+ else {
+ /*
+ * Section 9.2 Binding and Managing Framebuffer Objects of the OpenGL
+ * 4.5 core spec (30.10.2014, PDF page 314):
+ * "If framebuffer is zero, then the default draw framebuffer is
+ * queried."
+ */
+ buffer = ctx->WinSysDrawBuffer;
+ }
+
+ _mesa_get_framebuffer_attachment_parameter(ctx, buffer, attachment, pname,
+ params,
+ "glGetNamedFramebufferAttachmentParameteriv");
+}
+
+
static void
invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 871a2cc280e..71392037119 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -126,6 +126,12 @@ extern GLenum
_mesa_check_framebuffer_status(struct gl_context *ctx,
struct gl_framebuffer *fb);
+extern void
+_mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
+ struct gl_framebuffer *buffer,
+ GLenum attachment, GLenum pname,
+ GLint *params, const char *caller);
+
extern GLboolean GLAPIENTRY
_mesa_IsRenderbuffer(GLuint renderbuffer);
@@ -244,6 +250,10 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
extern void GLAPIENTRY
_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
GLenum pname, GLint *params);
+extern void GLAPIENTRY
+_mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
+ GLenum attachment,
+ GLenum pname, GLint *params);
extern void GLAPIENTRY
_mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index fdfad348a6e..f3aff5f9fa8 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -985,6 +985,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
+ { "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
{ "glCreateRenderbuffers", 45, -1 },
{ "glNamedRenderbufferStorage", 45, -1 },
{ "glNamedRenderbufferStorageMultisample", 45, -1 },
From df032ef7e04977112871edc1f1e82e35e6dbac76 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 2 Feb 2015 16:18:11 -0800
Subject: [PATCH 079/834] main: Fix whitespace in blit.c
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/blit.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index 0694466eb75..da875e2310e 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -306,7 +306,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* ignored."
*/
if ((readRb == NULL) || (drawRb == NULL)) {
- mask &= ~GL_STENCIL_BUFFER_BIT;
+ mask &= ~GL_STENCIL_BUFFER_BIT;
}
else {
int read_z_bits, draw_z_bits;
@@ -360,7 +360,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* ignored."
*/
if ((readRb == NULL) || (drawRb == NULL)) {
- mask &= ~GL_DEPTH_BUFFER_BIT;
+ mask &= ~GL_DEPTH_BUFFER_BIT;
}
else {
int read_s_bit, draw_s_bit;
@@ -458,23 +458,23 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLuint i = 0;
printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d,"
- " 0x%x, 0x%x)\n",
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1,
- mask, filter);
+ " 0x%x, 0x%x)\n",
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
if (colorReadRb) {
const struct gl_renderbuffer_attachment *att;
att = find_attachment(readFb, colorReadRb);
printf(" Src FBO %u RB %u (%dx%d) ",
- readFb->Name, colorReadRb->Name,
- colorReadRb->Width, colorReadRb->Height);
+ readFb->Name, colorReadRb->Name,
+ colorReadRb->Width, colorReadRb->Height);
if (att && att->Texture) {
printf("Tex %u tgt 0x%x level %u face %u",
- att->Texture->Name,
- att->Texture->Target,
- att->TextureLevel,
- att->CubeMapFace);
+ att->Texture->Name,
+ att->Texture->Target,
+ att->TextureLevel,
+ att->CubeMapFace);
}
printf("\n");
@@ -486,14 +486,14 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
att = find_attachment(drawFb, colorDrawRb);
printf(" Dst FBO %u RB %u (%dx%d) ",
- drawFb->Name, colorDrawRb->Name,
- colorDrawRb->Width, colorDrawRb->Height);
+ drawFb->Name, colorDrawRb->Name,
+ colorDrawRb->Width, colorDrawRb->Height);
if (att && att->Texture) {
printf("Tex %u tgt 0x%x level %u face %u",
- att->Texture->Name,
- att->Texture->Target,
- att->TextureLevel,
- att->CubeMapFace);
+ att->Texture->Name,
+ att->Texture->Target,
+ att->TextureLevel,
+ att->CubeMapFace);
}
printf("\n");
}
From 1a314f3c51bf1884cc3bf880e32461f304d5030b Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 2 Feb 2015 16:17:47 -0800
Subject: [PATCH 080/834] main: Refactor glBlitFramebuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/blit.c | 120 ++++++++++++++++++++++++-------------------
src/mesa/main/blit.h | 7 +++
2 files changed, 74 insertions(+), 53 deletions(-)
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index da875e2310e..6c78686a59a 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -148,39 +148,24 @@ is_valid_blit_filter(const struct gl_context *ctx, GLenum filter)
}
-/**
- * Blit rectangular region, optionally from one framebuffer to another.
- *
- * Note, if the src buffer is multisampled and the dest is not, this is
- * when the samples must be resolved to a single color.
- */
-void GLAPIENTRY
-_mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
+void
+_mesa_blit_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter, const char *func)
{
const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
- const struct gl_framebuffer *readFb, *drawFb;
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx,
- "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)\n",
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1,
- mask, _mesa_lookup_enum_by_nr(filter));
-
if (ctx->NewState) {
_mesa_update_state(ctx);
}
- readFb = ctx->ReadBuffer;
- drawFb = ctx->DrawBuffer;
-
if (!readFb || !drawFb) {
/* This will normally never happen but someday we may want to
* support MakeCurrent() with no drawables.
@@ -192,12 +177,12 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT ||
readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
- "glBlitFramebufferEXT(incomplete draw/read buffers)");
+ "%s(incomplete draw/read buffers)", func);
return;
}
if (!is_valid_blit_filter(ctx, filter)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(%s)",
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid filter %s)", func,
_mesa_lookup_enum_by_nr(filter));
return;
}
@@ -205,13 +190,13 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if ((filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
filter == GL_SCALED_RESOLVE_NICEST_EXT) &&
(readFb->Visual.samples == 0 || drawFb->Visual.samples > 0)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(%s)",
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(%s: invalid samples)", func,
_mesa_lookup_enum_by_nr(filter));
return;
}
if (mask & ~legalMaskBits) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid mask bits set)", func);
return;
}
@@ -219,13 +204,13 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT))
&& filter != GL_NEAREST) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)");
+ "%s(depth/stencil requires GL_NEAREST filter)", func);
return;
}
/* get color read/draw renderbuffers */
if (mask & GL_COLOR_BUFFER_BIT) {
- const GLuint numColorDrawBuffers = ctx->DrawBuffer->_NumColorDrawBuffers;
+ const GLuint numColorDrawBuffers = drawFb->_NumColorDrawBuffers;
const struct gl_renderbuffer *colorReadRb = readFb->_ColorReadBuffer;
const struct gl_renderbuffer *colorDrawRb = NULL;
GLuint i;
@@ -241,7 +226,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
}
else {
for (i = 0; i < numColorDrawBuffers; i++) {
- colorDrawRb = ctx->DrawBuffer->_ColorDrawBuffers[i];
+ colorDrawRb = drawFb->_ColorDrawBuffers[i];
if (!colorDrawRb)
continue;
@@ -257,15 +242,15 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
*/
if (_mesa_is_gles3(ctx) && (colorDrawRb == colorReadRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(source and destination color "
- "buffer cannot be the same)");
+ "%s(source and destination color "
+ "buffer cannot be the same)", func);
return;
}
if (!compatible_color_datatypes(colorReadRb->Format,
colorDrawRb->Format)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(color buffer datatypes mismatch)");
+ "%s(color buffer datatypes mismatch)", func);
return;
}
/* extra checks for multisample copies... */
@@ -273,7 +258,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
/* color formats must match */
if (!compatible_resolve_formats(colorReadRb, colorDrawRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(bad src/dst multisample pixel formats)");
+ "%s(bad src/dst multisample pixel formats)", func);
return;
}
}
@@ -286,7 +271,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLenum type = _mesa_get_format_datatype(colorReadRb->Format);
if (type == GL_INT || type == GL_UNSIGNED_INT) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(integer color type)");
+ "%s(integer color type)", func);
return;
}
}
@@ -313,8 +298,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(source and destination stencil "
- "buffer cannot be the same)");
+ "%s(source and destination stencil "
+ "buffer cannot be the same)", func);
return;
}
@@ -324,7 +309,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* there is only one: GL_UNSIGNED_INT.
*/
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(stencil attachment format mismatch)");
+ "%s(stencil attachment format mismatch)", func);
return;
}
@@ -340,8 +325,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
_mesa_get_format_datatype(readRb->Format) !=
_mesa_get_format_datatype(drawRb->Format))) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebuffer"
- "(stencil attachment depth format mismatch)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(stencil attachment depth format mismatch)", func);
return;
}
}
@@ -367,8 +352,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(source and destination depth "
- "buffer cannot be the same)");
+ "%s(source and destination depth "
+ "buffer cannot be the same)", func);
return;
}
@@ -377,7 +362,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
(_mesa_get_format_datatype(readRb->Format) !=
_mesa_get_format_datatype(drawRb->Format))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(depth attachment format mismatch)");
+ "%s(depth attachment format mismatch)", func);
return;
}
@@ -389,8 +374,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* we should ignore the stencil format check.
*/
if (read_s_bit > 0 && draw_s_bit > 0 && read_s_bit != draw_s_bit) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebuffer"
- "(depth attachment stencil bits mismatch)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(depth attachment stencil bits mismatch)", func);
return;
}
}
@@ -406,7 +391,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
*/
if (drawFb->Visual.samples > 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(destination samples must be 0)");
+ "%s(destination samples must be 0)", func);
return;
}
@@ -426,7 +411,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
&& (srcX0 != dstX0 || srcY0 != dstY0
|| srcX1 != dstX1 || srcY1 != dstY1)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(bad src/dst multisample region)");
+ "%s(bad src/dst multisample region)", func);
return;
}
} else {
@@ -434,7 +419,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
drawFb->Visual.samples > 0 &&
readFb->Visual.samples != drawFb->Visual.samples) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(mismatched samples)");
+ "%s(mismatched samples)", func);
return;
}
@@ -445,7 +430,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if (abs(srcX1 - srcX0) != abs(dstX1 - dstX0) ||
abs(srcY1 - srcY0) != abs(dstY1 - dstY0)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(bad src/dst multisample region sizes)");
+ "%s(bad src/dst multisample region sizes)", func);
return;
}
}
@@ -457,11 +442,12 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
const struct gl_renderbuffer *colorDrawRb = NULL;
GLuint i = 0;
- printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d,"
- " 0x%x, 0x%x)\n",
+ printf("%s(%d, %d, %d, %d, %d, %d, %d, %d,"
+ " 0x%x, 0x%x)\n", func,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
mask, filter);
+
if (colorReadRb) {
const struct gl_renderbuffer_attachment *att;
@@ -479,8 +465,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
printf("\n");
/* Print all active color render buffers */
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- colorDrawRb = ctx->DrawBuffer->_ColorDrawBuffers[i];
+ for (i = 0; i < drawFb->_NumColorDrawBuffers; i++) {
+ colorDrawRb = drawFb->_ColorDrawBuffers[i];
if (!colorDrawRb)
continue;
@@ -507,8 +493,36 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
}
assert(ctx->Driver.BlitFramebuffer);
- ctx->Driver.BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
+ ctx->Driver.BlitFramebuffer(ctx, readFb, drawFb,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
mask, filter);
}
+
+
+/**
+ * Blit rectangular region, optionally from one framebuffer to another.
+ *
+ * Note, if the src buffer is multisampled and the dest is not, this is
+ * when the samples must be resolved to a single color.
+ */
+void GLAPIENTRY
+_mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx,
+ "glBlitFramebuffer(%d, %d, %d, %d, "
+ " %d, %d, %d, %d, 0x%x, %s)\n",
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, _mesa_lookup_enum_by_nr(filter));
+
+ _mesa_blit_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter, "glBlitFramebuffer");
+}
diff --git a/src/mesa/main/blit.h b/src/mesa/main/blit.h
index 01a958af5a2..b854f5f84c6 100644
--- a/src/mesa/main/blit.h
+++ b/src/mesa/main/blit.h
@@ -28,6 +28,13 @@
#include "glheader.h"
+extern void
+_mesa_blit_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter, const char *func);
extern void GLAPIENTRY
_mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
From 9036a6c0aa0637a1cd756836006dc8565b15a478 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 3 Feb 2015 11:03:01 -0800
Subject: [PATCH 081/834] main: Refactor _mesa_update_framebuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
_mesa_update_framebuffer now operates on arbitrary read and draw framebuffers.
This allows BlitNamedFramebuffer to update the state of its arbitrary read and
draw framebuffers.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/drivers/dri/i915/i830_vtbl.c | 2 +-
src/mesa/drivers/dri/i915/i915_vtbl.c | 2 +-
src/mesa/drivers/dri/r200/r200_state.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_common.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_state.c | 2 +-
src/mesa/main/framebuffer.c | 11 ++++-------
src/mesa/main/framebuffer.h | 4 +++-
src/mesa/main/state.c | 2 +-
8 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c
index 91da977acee..4fff29ee88a 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -730,7 +730,7 @@ i830_update_draw_buffer(struct intel_context *intel)
*/
if (ctx->NewState & _NEW_BUFFERS) {
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
_mesa_update_draw_buffer_bounds(ctx);
}
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 97bf81ed759..02ff312c2e6 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -732,7 +732,7 @@ i915_update_draw_buffer(struct intel_context *intel)
*/
if (ctx->NewState & _NEW_BUFFERS) {
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
_mesa_update_draw_buffer_bounds(ctx);
}
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index b0a6bd573b6..de5296d8e2f 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -2215,7 +2215,7 @@ GLboolean r200ValidateState( struct gl_context *ctx )
GLuint new_state = rmesa->radeon.NewGLState;
if (new_state & _NEW_BUFFERS) {
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
_mesa_update_draw_buffer_bounds(ctx);
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c
index 0ca526d2a02..12502d5f9a3 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -220,7 +220,7 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
*/
if (ctx->NewState & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
_mesa_update_draw_buffer_bounds(ctx);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index c45bb513dca..7bff1d46c05 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1994,7 +1994,7 @@ GLboolean radeonValidateState( struct gl_context *ctx )
GLuint new_state = rmesa->radeon.NewGLState;
if (new_state & _NEW_BUFFERS) {
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
_mesa_update_draw_buffer_bounds(ctx);
RADEON_STATECHANGE(rmesa, ctx);
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 4f7736a64d0..74e5739e6fd 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -678,17 +678,14 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
/**
- * Update state related to the current draw/read framebuffers.
+ * Update state related to the draw/read framebuffers.
*/
void
-_mesa_update_framebuffer(struct gl_context *ctx)
+_mesa_update_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb)
{
- struct gl_framebuffer *drawFb;
- struct gl_framebuffer *readFb;
-
assert(ctx);
- drawFb = ctx->DrawBuffer;
- readFb = ctx->ReadBuffer;
update_framebuffer(ctx, drawFb);
if (readFb != drawFb)
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index a4274216ec2..d3b7e584ca4 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -84,7 +84,9 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
struct gl_framebuffer *fb);
extern void
-_mesa_update_framebuffer(struct gl_context *ctx);
+_mesa_update_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb);
extern GLboolean
_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format);
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 99db37bafd7..3688736cb79 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -389,7 +389,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
update_frontbit( ctx );
if (new_state & _NEW_BUFFERS)
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
_mesa_update_draw_buffer_bounds( ctx );
From c1fe8d841c4746a6371dde569c6c88c6c2bad4e6 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 3 Feb 2015 11:42:17 -0800
Subject: [PATCH 082/834] main: Refactor _mesa_[update|get]_clamp_vertex_color.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/blend.c | 13 ++++++++-----
src/mesa/main/blend.h | 7 +++++--
src/mesa/main/framebuffer.c | 2 +-
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 774fc888ec4..ee76b475943 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -769,7 +769,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
}
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.ClampVertexColor = clamp;
- _mesa_update_clamp_vertex_color(ctx);
+ _mesa_update_clamp_vertex_color(ctx, ctx->DrawBuffer);
break;
case GL_CLAMP_FRAGMENT_COLOR_ARB:
if (ctx->API == API_OPENGL_CORE &&
@@ -814,9 +814,10 @@ _mesa_get_clamp_fragment_color(const struct gl_context *ctx)
}
GLboolean
-_mesa_get_clamp_vertex_color(const struct gl_context *ctx)
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- return get_clamp_color(ctx->DrawBuffer, ctx->Light.ClampVertexColor);
+ return get_clamp_color(drawFb, ctx->Light.ClampVertexColor);
}
GLboolean
@@ -848,9 +849,11 @@ _mesa_update_clamp_fragment_color(struct gl_context *ctx)
* Update the ctx->Color._ClampVertexColor field
*/
void
-_mesa_update_clamp_vertex_color(struct gl_context *ctx)
+_mesa_update_clamp_vertex_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- ctx->Light._ClampVertexColor = _mesa_get_clamp_vertex_color(ctx);
+ ctx->Light._ClampVertexColor =
+ _mesa_get_clamp_vertex_color(ctx, drawFb);
}
/**
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index fe31a7440f0..9c1ef7e8592 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -37,6 +37,7 @@
#include "formats.h"
struct gl_context;
+struct gl_framebuffer;
extern void GLAPIENTRY
@@ -104,7 +105,8 @@ extern GLboolean
_mesa_get_clamp_fragment_color(const struct gl_context *ctx);
extern GLboolean
-_mesa_get_clamp_vertex_color(const struct gl_context *ctx);
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern GLboolean
_mesa_get_clamp_read_color(const struct gl_context *ctx);
@@ -113,7 +115,8 @@ extern void
_mesa_update_clamp_fragment_color(struct gl_context *ctx);
extern void
-_mesa_update_clamp_vertex_color(struct gl_context *ctx);
+_mesa_update_clamp_vertex_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern mesa_format
_mesa_get_render_format(const struct gl_context *ctx, mesa_format format);
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 74e5739e6fd..36a953988eb 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -691,7 +691,7 @@ _mesa_update_framebuffer(struct gl_context *ctx,
if (readFb != drawFb)
update_framebuffer(ctx, readFb);
- _mesa_update_clamp_vertex_color(ctx);
+ _mesa_update_clamp_vertex_color(ctx, drawFb);
_mesa_update_clamp_fragment_color(ctx);
}
From 2cabfd9636a55f6adee04f4199ba83a39598d51c Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 3 Mar 2015 14:03:33 -0800
Subject: [PATCH 083/834] main: Refactor
_mesa_[update|get]_clamp_fragment_color.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/blend.c | 19 ++++++++++---------
src/mesa/main/blend.h | 6 ++++--
src/mesa/main/framebuffer.c | 2 +-
src/mesa/main/get.c | 8 ++++----
src/mesa/main/texenv.c | 2 +-
src/mesa/main/texparam.c | 2 +-
src/mesa/program/prog_statevars.c | 4 ++--
7 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index ee76b475943..2342555a95d 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -778,7 +778,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
}
FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP);
ctx->Color.ClampFragmentColor = clamp;
- _mesa_update_clamp_fragment_color(ctx);
+ _mesa_update_clamp_fragment_color(ctx, ctx->DrawBuffer);
break;
case GL_CLAMP_READ_COLOR_ARB:
ctx->Color.ClampReadColor = clamp;
@@ -807,10 +807,10 @@ get_clamp_color(const struct gl_framebuffer *fb, GLenum clamp)
}
GLboolean
-_mesa_get_clamp_fragment_color(const struct gl_context *ctx)
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- return get_clamp_color(ctx->DrawBuffer,
- ctx->Color.ClampFragmentColor);
+ return get_clamp_color(drawFb, ctx->Color.ClampFragmentColor);
}
GLboolean
@@ -830,19 +830,20 @@ _mesa_get_clamp_read_color(const struct gl_context *ctx)
* Update the ctx->Color._ClampFragmentColor field
*/
void
-_mesa_update_clamp_fragment_color(struct gl_context *ctx)
+_mesa_update_clamp_fragment_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- struct gl_framebuffer *fb = ctx->DrawBuffer;
-
/* Don't clamp if:
* - there is no colorbuffer
* - all colorbuffers are unsigned normalized, so clamping has no effect
* - there is an integer colorbuffer
*/
- if (!fb || !fb->_HasSNormOrFloatColorBuffer || fb->_IntegerColor)
+ if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
+ drawFb->_IntegerColor)
ctx->Color._ClampFragmentColor = GL_FALSE;
else
- ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx);
+ ctx->Color._ClampFragmentColor =
+ _mesa_get_clamp_fragment_color(ctx, drawFb);
}
/**
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index 9c1ef7e8592..58e66736ddc 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -102,7 +102,8 @@ extern void GLAPIENTRY
_mesa_ClampColor(GLenum target, GLenum clamp);
extern GLboolean
-_mesa_get_clamp_fragment_color(const struct gl_context *ctx);
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern GLboolean
_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
@@ -112,7 +113,8 @@ extern GLboolean
_mesa_get_clamp_read_color(const struct gl_context *ctx);
extern void
-_mesa_update_clamp_fragment_color(struct gl_context *ctx);
+_mesa_update_clamp_fragment_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern void
_mesa_update_clamp_vertex_color(struct gl_context *ctx,
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 36a953988eb..5c409db2572 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -692,7 +692,7 @@ _mesa_update_framebuffer(struct gl_context *ctx,
update_framebuffer(ctx, readFb);
_mesa_update_clamp_vertex_color(ctx, drawFb);
- _mesa_update_clamp_fragment_color(ctx);
+ _mesa_update_clamp_fragment_color(ctx, drawFb);
}
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 09be715f911..8a6c81aff87 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -909,13 +909,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
case GL_FOG_COLOR:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4FV(v->value_float_4, ctx->Fog.Color);
else
COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped);
break;
case GL_COLOR_CLEAR_VALUE:
- if (_mesa_get_clamp_fragment_color(ctx)) {
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F);
v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F);
v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F);
@@ -924,13 +924,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f);
break;
case GL_BLEND_COLOR_EXT:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4FV(v->value_float_4, ctx->Color.BlendColor);
else
COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped);
break;
case GL_ALPHA_TEST_REF:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
v->value_float = ctx->Color.AlphaRef;
else
v->value_float = ctx->Color.AlphaRefUnclamped;
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index ec521e6c6e5..3edafc0f776 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -646,7 +646,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
if (pname == GL_TEXTURE_ENV_COLOR) {
if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
_mesa_update_state(ctx);
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4FV( params, texUnit->EnvColor );
else
COPY_4FV( params, texUnit->EnvColorUnclamped );
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index b5d42d3047f..d74134f41b1 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1709,7 +1709,7 @@ get_tex_parameterfv(struct gl_context *ctx,
if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
_mesa_update_state_locked(ctx);
- if (_mesa_get_clamp_fragment_color(ctx)) {
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index 0c0c87faa28..bdb335e4ba3 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -244,14 +244,14 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
{
/* state[1] is the texture unit */
const GLuint unit = (GLuint) state[1];
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
else
COPY_4V(value, ctx->Texture.Unit[unit].EnvColorUnclamped);
}
return;
case STATE_FOG_COLOR:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4V(value, ctx->Fog.Color);
else
COPY_4V(value, ctx->Fog.ColorUnclamped);
From 39be0c5f6c1922e2e2f3c4243dd8257c2e7deef8 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 3 Mar 2015 15:05:16 -0800
Subject: [PATCH 084/834] main: Refactor _mesa_get_clamp_read_color.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This wasn't neccessary for ARB_direct_state_access, but felt like a good idea
for the sake of completeness.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/blend.c | 5 +++--
src/mesa/main/blend.h | 3 ++-
src/mesa/main/readpix.c | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 2342555a95d..d869fa2aa09 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -821,9 +821,10 @@ _mesa_get_clamp_vertex_color(const struct gl_context *ctx,
}
GLboolean
-_mesa_get_clamp_read_color(const struct gl_context *ctx)
+_mesa_get_clamp_read_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *readFb)
{
- return get_clamp_color(ctx->ReadBuffer, ctx->Color.ClampReadColor);
+ return get_clamp_color(readFb, ctx->Color.ClampReadColor);
}
/**
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index 58e66736ddc..8ab9e02fc13 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -110,7 +110,8 @@ _mesa_get_clamp_vertex_color(const struct gl_context *ctx,
const struct gl_framebuffer *drawFb);
extern GLboolean
-_mesa_get_clamp_read_color(const struct gl_context *ctx);
+_mesa_get_clamp_read_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *readFb);
extern void
_mesa_update_clamp_fragment_color(struct gl_context *ctx,
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index ed0104c9e46..df46f8361b9 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -83,7 +83,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, mesa_format texFormat,
if (uses_blit) {
/* For blit-based ReadPixels packing, the clamping is done automatically
* unless the type is float. */
- if (_mesa_get_clamp_read_color(ctx) &&
+ if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) &&
(type == GL_FLOAT || type == GL_HALF_FLOAT)) {
transferOps |= IMAGE_CLAMP_BIT;
}
@@ -91,7 +91,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, mesa_format texFormat,
else {
/* For CPU-based ReadPixels packing, the clamping must always be done
* for non-float types, */
- if (_mesa_get_clamp_read_color(ctx) ||
+ if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) ||
(type != GL_FLOAT && type != GL_HALF_FLOAT)) {
transferOps |= IMAGE_CLAMP_BIT;
}
From b590c617256720e82fff0428a5e0e4a64115fac2 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 3 Feb 2015 14:41:26 -0800
Subject: [PATCH 085/834] main: Refactor _mesa_update_draw_buffer_bounds.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/drivers/dri/i915/i830_vtbl.c | 2 +-
src/mesa/drivers/dri/i915/i915_vtbl.c | 2 +-
src/mesa/drivers/dri/r200/r200_state.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_common.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_state.c | 2 +-
src/mesa/main/framebuffer.c | 6 +++---
src/mesa/main/framebuffer.h | 3 ++-
src/mesa/main/state.c | 2 +-
8 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c
index 4fff29ee88a..8ed8ff555ba 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -732,7 +732,7 @@ i830_update_draw_buffer(struct intel_context *intel)
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
}
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 02ff312c2e6..80bd249fa7b 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -734,7 +734,7 @@ i915_update_draw_buffer(struct intel_context *intel)
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
}
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index de5296d8e2f..6fe70b5c9d0 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -2217,7 +2217,7 @@ GLboolean r200ValidateState( struct gl_context *ctx )
if (new_state & _NEW_BUFFERS) {
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
R200_STATECHANGE(rmesa, ctx);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c
index 12502d5f9a3..2a8bd6c9edc 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -222,7 +222,7 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
}
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index 7bff1d46c05..cba3d9c9689 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1996,7 +1996,7 @@ GLboolean radeonValidateState( struct gl_context *ctx )
if (new_state & _NEW_BUFFERS) {
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
RADEON_STATECHANGE(rmesa, ctx);
}
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 5c409db2572..0a0f73ba423 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -312,7 +312,7 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
if (ctx) {
/* update scissor / window bounds */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
/* Signal new buffer state so that swrast will update its clipping
* info (the CLIP_BIT flag).
*/
@@ -413,9 +413,9 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
* \param ctx the GL context.
*/
void
-_mesa_update_draw_buffer_bounds(struct gl_context *ctx)
+_mesa_update_draw_buffer_bounds(struct gl_context *ctx,
+ struct gl_framebuffer *buffer)
{
- struct gl_framebuffer *buffer = ctx->DrawBuffer;
int bbox[4];
if (!buffer)
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index d3b7e584ca4..d02b86f20d9 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -77,7 +77,8 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
unsigned idx, int *bbox);
extern void
-_mesa_update_draw_buffer_bounds(struct gl_context *ctx);
+_mesa_update_draw_buffer_bounds(struct gl_context *ctx,
+ struct gl_framebuffer *drawFb);
extern void
_mesa_update_framebuffer_visual(struct gl_context *ctx,
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 3688736cb79..2657c532f88 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -392,7 +392,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
- _mesa_update_draw_buffer_bounds( ctx );
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
if (new_state & _NEW_LIGHT)
_mesa_update_lighting( ctx );
From 47b910d27587f738dd81cdb9a879726785c0bc54 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 2 Feb 2015 16:27:46 -0800
Subject: [PATCH 086/834] main: Add entry point for BlitNamedFramebuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 15 ++++++
src/mesa/main/blit.c | 51 +++++++++++++++++++
src/mesa/main/blit.h | 6 +++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 73 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index beb6249a6f7..7ee2000d86e 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -181,6 +181,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index 6c78686a59a..baf3165ff9d 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -526,3 +526,54 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
dstX0, dstY0, dstX1, dstY1,
mask, filter, "glBlitFramebuffer");
}
+
+
+void GLAPIENTRY
+_mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *readFb, *drawFb;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx,
+ "glBlitNamedFramebuffer(%u %u %d, %d, %d, %d, "
+ " %d, %d, %d, %d, 0x%x, %s)\n",
+ readFramebuffer, drawFramebuffer,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, _mesa_lookup_enum_by_nr(filter));
+
+ /*
+ * According to PDF page 533 of the OpenGL 4.5 core spec (30.10.2014,
+ * Section 18.3 Copying Pixels):
+ * "... if readFramebuffer or drawFramebuffer is zero (for
+ * BlitNamedFramebuffer), then the default read or draw framebuffer is
+ * used as the corresponding source or destination framebuffer,
+ * respectively."
+ */
+ if (readFramebuffer) {
+ readFb = _mesa_lookup_framebuffer_err(ctx, readFramebuffer,
+ "glBlitNamedFramebuffer");
+ if (!readFb)
+ return;
+ }
+ else
+ readFb = ctx->WinSysReadBuffer;
+
+ if (drawFramebuffer) {
+ drawFb = _mesa_lookup_framebuffer_err(ctx, drawFramebuffer,
+ "glBlitNamedFramebuffer");
+ if (!drawFb)
+ return;
+ }
+ else
+ drawFb = ctx->WinSysDrawBuffer;
+
+ _mesa_blit_framebuffer(ctx, readFb, drawFb,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter, "glBlitNamedFramebuffer");
+}
diff --git a/src/mesa/main/blit.h b/src/mesa/main/blit.h
index b854f5f84c6..54b946e3192 100644
--- a/src/mesa/main/blit.h
+++ b/src/mesa/main/blit.h
@@ -41,5 +41,11 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
+extern void GLAPIENTRY
+_mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter);
+
#endif /* BLIT_H */
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index f3aff5f9fa8..ec3c9927162 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -984,6 +984,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferRenderbuffer", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
+ { "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
{ "glCreateRenderbuffers", 45, -1 },
From 6b284f08ab399154ad10e2166440b44cbbdcb2c5 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Tue, 3 Feb 2015 14:47:00 -0800
Subject: [PATCH 087/834] main: _mesa_blit_framebuffer updates its arbitrary
framebuffers.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Previously, we used _mesa_update_state to update the currently bound
framebuffers prior to performing a blit. Now that _mesa_blit_framebuffer
uses arbitrary framebuffers, _mesa_update_state is not specific enough.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/blit.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index baf3165ff9d..db8fee5a414 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -34,6 +34,7 @@
#include "enums.h"
#include "blit.h"
#include "fbobject.h"
+#include "framebuffer.h"
#include "glformats.h"
#include "mtypes.h"
#include "state.h"
@@ -162,9 +163,11 @@ _mesa_blit_framebuffer(struct gl_context *ctx,
FLUSH_VERTICES(ctx, 0);
- if (ctx->NewState) {
- _mesa_update_state(ctx);
- }
+ /* Update completeness status of readFb and drawFb. */
+ _mesa_update_framebuffer(ctx, readFb, drawFb);
+
+ /* Make sure drawFb has an initialized bounding box. */
+ _mesa_update_draw_buffer_bounds(ctx, drawFb);
if (!readFb || !drawFb) {
/* This will normally never happen but someday we may want to
From b4368ac09db75cea412121ada6c12af1414feb50 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Wed, 4 Feb 2015 14:21:17 -0800
Subject: [PATCH 088/834] main: Complete error conditions for
glInvalidate*Framebuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Fredrik Höglund
Reviewed-by: Adam Jackson
Cc: "10.4 10.5"
---
src/mesa/main/fbobject.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 15878d327c6..7ba72558830 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3650,12 +3650,29 @@ invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
return;
}
+ /* Section 17.4 Whole Framebuffer Operations of the OpenGL 4.5 Core
+ * Spec (2.2.2015, PDF page 522) says:
+ * "An INVALID_VALUE error is generated if numAttachments, width, or
+ * height is negative."
+ */
if (numAttachments < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(numAttachments < 0)", name);
return;
}
+ if (width < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(width < 0)", name);
+ return;
+ }
+
+ if (height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(height < 0)", name);
+ return;
+ }
+
/* The GL_ARB_invalidate_subdata spec says:
*
* "If an attachment is specified that does not exist in the
@@ -3748,7 +3765,8 @@ invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
return;
invalid_enum:
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(attachment)", name);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", name,
+ _mesa_lookup_enum_by_nr(attachments[i]));
return;
}
From 65d4a20f1c1923498220637f9474d2ae399df52d Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Wed, 4 Feb 2015 09:49:58 -0800
Subject: [PATCH 089/834] main: Refactor invalidate_framebuffer_storage.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/fbobject.c | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 7ba72558830..4a32f1f568b 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3636,19 +3636,13 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
static void
-invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
+invalidate_framebuffer_storage(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height, const char *name)
{
int i;
- struct gl_framebuffer *fb;
- GET_CURRENT_CONTEXT(ctx);
-
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", name);
- return;
- }
/* Section 17.4 Whole Framebuffer Operations of the OpenGL 4.5 Core
* Spec (2.2.2015, PDF page 522) says:
@@ -3776,7 +3770,18 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height)
{
- invalidate_framebuffer_storage(target, numAttachments, attachments,
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glInvalidateSubFramebuffer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
x, y, width, height,
"glInvalidateSubFramebuffer");
}
@@ -3786,6 +3791,17 @@ void GLAPIENTRY
_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments)
{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glInvalidateFramebuffer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
/* The GL_ARB_invalidate_subdata spec says:
*
* "The command
@@ -3798,7 +3814,7 @@ _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
* , equal to 0, 0, ,
* respectively."
*/
- invalidate_framebuffer_storage(target, numAttachments, attachments,
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
0, 0,
MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT,
"glInvalidateFramebuffer");
From d890fc710f6d3472ea3837e074fafc100d41e01f Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Wed, 4 Feb 2015 14:21:48 -0800
Subject: [PATCH 090/834] main: Add entry points for
InvalidateNamedFramebuffer[Sub]Data.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 16 +++++
src/mesa/main/fbobject.c | 69 +++++++++++++++++++
src/mesa/main/fbobject.h | 12 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 2 +
4 files changed, 99 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 7ee2000d86e..de7742088e1 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -181,6 +181,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4a32f1f568b..dc1e1a67321 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3787,6 +3787,35 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
}
+void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferSubData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
+ * Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
+ * default draw framebuffer is affected."
+ */
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glInvalidateNamedFramebufferSubData");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
+ x, y, width, height,
+ "glInvalidateNamedFramebufferSubData");
+}
+
+
void GLAPIENTRY
_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments)
@@ -3821,6 +3850,46 @@ _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
}
+void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
+ * Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
+ * default draw framebuffer is affected."
+ */
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glInvalidateNamedFramebufferData");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ /* The GL_ARB_invalidate_subdata spec says:
+ *
+ * "The command
+ *
+ * void InvalidateFramebuffer(enum target,
+ * sizei numAttachments,
+ * const enum *attachments);
+ *
+ * is equivalent to the command InvalidateSubFramebuffer with , ,
+ * , equal to 0, 0, ,
+ * respectively."
+ */
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
+ 0, 0,
+ MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT,
+ "glInvalidateNamedFramebufferData");
+}
+
+
void GLAPIENTRY
_mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
const GLenum *attachments)
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 71392037119..22cb139ec9a 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -260,10 +260,22 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height);
+extern void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferSubData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height);
+
extern void GLAPIENTRY
_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments);
+extern void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments);
+
extern void GLAPIENTRY
_mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
const GLenum *attachments);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index ec3c9927162..e375260ff1f 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -984,6 +984,8 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferRenderbuffer", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
+ { "glInvalidateNamedFramebufferSubData", 45, -1 },
+ { "glInvalidateNamedFramebufferData", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
From 6236c477990d67499f494b3c95844217fbd9a3dd Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 5 Feb 2015 13:24:43 -0800
Subject: [PATCH 091/834] main: Fake entry point for glClearNamedFramebufferiv.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model. Moreover, the OpenGL spec for ClearBuffer is also very
complicated. At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 7 +++++++
src/mesa/main/clear.c | 20 +++++++++++++++++++
src/mesa/main/clear.h | 4 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 32 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index de7742088e1..c793c9e9c70 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -197,6 +197,13 @@
+
+
+
+
+
+
+
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 8d707bc34a1..4e029cf258f 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -34,6 +34,8 @@
#include "clear.h"
#include "context.h"
#include "enums.h"
+#include "fbobject.h"
+#include "get.h"
#include "macros.h"
#include "mtypes.h"
#include "state.h"
@@ -399,6 +401,24 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
}
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLint *value)
+{
+ GLint oldfb;
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferiv(buffer, drawbuffer, value);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
+
/**
* New in GL 3.0
* Clear unsigned integer color buffer (not depth, not stencil).
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index 96ce47b929e..d0b61335356 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -51,6 +51,10 @@ _mesa_Clear( GLbitfield mask );
extern void GLAPIENTRY
_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value);
+extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLint *value);
+
extern void GLAPIENTRY
_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index e375260ff1f..149c8b456b2 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -986,6 +986,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
+ { "glClearNamedFramebufferiv", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
From 43db4b8465c203f9748cd2a7e08d8242573116f1 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 5 Feb 2015 13:30:50 -0800
Subject: [PATCH 092/834] main: Fake entry point for
glClearNamedFramebufferuiv.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model. Moreover, the OpenGL spec for ClearBuffer is also very
complicated. At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++++++
src/mesa/main/clear.c | 18 ++++++++++++++++++
src/mesa/main/clear.h | 4 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 30 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index c793c9e9c70..95fda9676fd 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -204,6 +204,13 @@
+
+
+
+
+
+
+
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 4e029cf258f..05bbf1564be 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -491,6 +491,24 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
}
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLuint *value)
+{
+ GLint oldfb;
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferuiv(buffer, drawbuffer, value);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
+
/**
* New in GL 3.0
* Clear fixed-pt or float color buffer or depth buffer (not stencil).
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index d0b61335356..b74c2275cb0 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -58,6 +58,10 @@ _mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
extern void GLAPIENTRY
_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value);
+extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLuint *value);
+
extern void GLAPIENTRY
_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 149c8b456b2..60d0fe9a118 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -987,6 +987,7 @@ const struct function gl_core_functions_possible[] = {
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
+ { "glClearNamedFramebufferuiv", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
From bbd9c55d0217c697cbe090057bfbf830b551ed36 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 5 Feb 2015 13:38:39 -0800
Subject: [PATCH 093/834] main: Fake entry point for glClearNamedFramebufferfv.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model. Moreover, the OpenGL spec for ClearBuffer is also very
complicated. At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++++++
src/mesa/main/clear.c | 18 ++++++++++++++++++
src/mesa/main/clear.h | 4 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 30 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 95fda9676fd..2bb3c716087 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -211,6 +211,13 @@
+
+
+
+
+
+
+
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 05bbf1564be..81e255e5ee7 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -602,6 +602,24 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
}
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLfloat *value)
+{
+ GLint oldfb;
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferfv(buffer, drawbuffer, value);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
+
/**
* New in GL 3.0
* Clear depth/stencil buffer only.
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index b74c2275cb0..582159fea0f 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -65,6 +65,10 @@ _mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
extern void GLAPIENTRY
_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value);
+extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLfloat *value);
+
extern void GLAPIENTRY
_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
GLfloat depth, GLint stencil);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 60d0fe9a118..1f25869d1ee 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -988,6 +988,7 @@ const struct function gl_core_functions_possible[] = {
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
{ "glClearNamedFramebufferuiv", 45, -1 },
+ { "glClearNamedFramebufferfv", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
From a0329c7b40de3db22d22c74793a7c268e8904e53 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 5 Feb 2015 13:43:12 -0800
Subject: [PATCH 094/834] main: Fake entry point for glClearNamedFramebufferfi.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model. Moreover, the OpenGL spec for ClearBuffer is also very
complicated. At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mapi/glapi/gen/ARB_direct_state_access.xml | 7 +++++++
src/mesa/main/clear.c | 18 ++++++++++++++++++
src/mesa/main/clear.h | 4 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 30 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 2bb3c716087..8bafe3f0bb0 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -218,6 +218,13 @@
+
+
+
+
+
+
+
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 81e255e5ee7..426caea4709 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -682,3 +682,21 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
ctx->Stencil.Clear = clearStencilSave;
}
}
+
+
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
+ GLfloat depth, GLint stencil)
+{
+ GLint oldfb;
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferfi(buffer, 0, depth, stencil);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index 582159fea0f..c29850676ca 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -73,4 +73,8 @@ extern void GLAPIENTRY
_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
GLfloat depth, GLint stencil);
+extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
+ GLfloat depth, GLint stencil);
+
#endif
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 1f25869d1ee..a119d0874a6 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -989,6 +989,7 @@ const struct function gl_core_functions_possible[] = {
{ "glClearNamedFramebufferiv", 45, -1 },
{ "glClearNamedFramebufferuiv", 45, -1 },
{ "glClearNamedFramebufferfv", 45, -1 },
+ { "glClearNamedFramebufferfi", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
From 9f1db78a83feebefb9e1ef889b3b6b0532482c14 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Thu, 5 Feb 2015 16:38:11 -0800
Subject: [PATCH 095/834] main: Add stubs for
[Get]NamedFramebufferParameteri[v].
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The ARB_direct_state_access specification says (as of 2015.02.05):
"Interactions with OpenGL 4.3 or ARB_framebuffer_no_attachments
If neither OpenGL 4.3 nor ARB_framebuffer_no_attachments are supported,
ignore the support for NamedFramebufferParameteri and
GetNamedFramebufferParameteriv."
This commit adds stubs for these entry points.
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 12 +++++++
src/mesa/main/fbobject.c | 32 +++++++++++++++++++
src/mesa/main/fbobject.h | 8 +++++
src/mesa/main/tests/dispatch_sanity.cpp | 2 ++
4 files changed, 54 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 8bafe3f0bb0..3617e48a19c 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -166,6 +166,12 @@
+
+
+
+
+
+
@@ -246,6 +252,12 @@
+
+
+
+
+
+
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index dc1e1a67321..971dc688a04 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3635,6 +3635,38 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
}
+void GLAPIENTRY
+_mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
+ GLint param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ (void) framebuffer;
+ (void) pname;
+ (void) param;
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferParameteri not supported "
+ "(ARB_framebuffer_no_attachments not implemented)");
+}
+
+
+void GLAPIENTRY
+_mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
+ GLint *param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ (void) framebuffer;
+ (void) pname;
+ (void) param;
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedFramebufferParameteriv not supported "
+ "(ARB_framebuffer_no_attachments not implemented)");
+}
+
+
static void
invalidate_framebuffer_storage(struct gl_context *ctx,
struct gl_framebuffer *fb,
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 22cb139ec9a..9f570db3a26 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -255,6 +255,14 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
GLenum attachment,
GLenum pname, GLint *params);
+extern void GLAPIENTRY
+_mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
+ GLint param);
+
+extern void GLAPIENTRY
+_mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
+ GLint *param);
+
extern void GLAPIENTRY
_mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index a119d0874a6..23ddabd169d 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -982,6 +982,7 @@ const struct function gl_core_functions_possible[] = {
{ "glGetNamedBufferSubData", 45, -1 },
{ "glCreateFramebuffers", 45, -1 },
{ "glNamedFramebufferRenderbuffer", 45, -1 },
+ { "glNamedFramebufferParameteri", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
@@ -992,6 +993,7 @@ const struct function gl_core_functions_possible[] = {
{ "glClearNamedFramebufferfi", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
+ { "glGetNamedFramebufferParameteriv", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
{ "glCreateRenderbuffers", 45, -1 },
{ "glNamedRenderbufferStorage", 45, -1 },
From f8fd8dfee8647a3bd2215fce49626953ecdbdbec Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 6 Feb 2015 10:34:24 -0800
Subject: [PATCH 096/834] main: Refactor _mesa_drawbuffers.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: Whitespace fix]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/drivers/common/meta.c | 3 ++-
src/mesa/main/buffers.c | 26 ++++++++++++--------------
src/mesa/main/buffers.h | 4 +++-
src/mesa/main/context.c | 3 ++-
src/mesa/main/framebuffer.c | 2 +-
5 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index d2ab7b8ded9..214a68a9129 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1211,7 +1211,8 @@ _mesa_meta_end(struct gl_context *ctx)
_mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
if (state & MESA_META_DRAW_BUFFERS) {
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, save->ColorDrawBuffers, NULL);
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, ctx->Const.MaxDrawBuffers,
+ save->ColorDrawBuffers, NULL);
}
ctx->Meta->SaveStackDepth--;
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 37a9790923b..a338013fed5 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -277,7 +277,7 @@ _mesa_DrawBuffer(GLenum buffer)
}
/* if we get here, there's no error so set new state */
- _mesa_drawbuffers(ctx, 1, &buffer, &destMask);
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer, &destMask);
/*
* Call device driver function.
@@ -440,7 +440,7 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
}
/* OK, if we get here, there were no errors so set the new state */
- _mesa_drawbuffers(ctx, n, buffers, destMask);
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, n, buffers, destMask);
/*
* Call device driver function. Note that n can be equal to 0,
@@ -459,13 +459,11 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* actual change.
*/
static void
-updated_drawbuffers(struct gl_context *ctx)
+updated_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb)
{
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
if (ctx->API == API_OPENGL_COMPAT && !ctx->Extensions.ARB_ES2_compatibility) {
- struct gl_framebuffer *fb = ctx->DrawBuffer;
-
/* Flag the FBO as requiring validation. */
if (_mesa_is_user_fbo(fb)) {
fb->_Status = 0;
@@ -482,6 +480,7 @@ updated_drawbuffers(struct gl_context *ctx)
* so nothing should go wrong at this point.
*
* \param ctx current context
+ * \param fb the desired draw buffer
* \param n number of color outputs to set
* \param buffers array[n] of colorbuffer names, like GL_LEFT.
* \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the
@@ -489,10 +488,9 @@ updated_drawbuffers(struct gl_context *ctx)
* BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
*/
void
-_mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
- const GLbitfield *destMask)
+_mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint n, const GLenum *buffers, const GLbitfield *destMask)
{
- struct gl_framebuffer *fb = ctx->DrawBuffer;
GLbitfield mask[MAX_DRAW_BUFFERS];
GLuint buf;
@@ -518,7 +516,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
while (destMask0) {
GLint bufIndex = ffs(destMask0) - 1;
if (fb->_ColorDrawBufferIndexes[count] != bufIndex) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[count] = bufIndex;
}
count++;
@@ -535,14 +533,14 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
/* only one bit should be set in the destMask[buf] field */
assert(_mesa_bitcount(destMask[buf]) == 1);
if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = bufIndex;
}
count = buf + 1;
}
else {
if (fb->_ColorDrawBufferIndexes[buf] != -1) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = -1;
}
}
@@ -554,7 +552,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
/* set remaining outputs to -1 (GL_NONE) */
for (buf = fb->_NumColorDrawBuffers; buf < ctx->Const.MaxDrawBuffers; buf++) {
if (fb->_ColorDrawBufferIndexes[buf] != -1) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = -1;
}
}
@@ -566,7 +564,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
/* also set context drawbuffer state */
for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf];
}
}
@@ -585,7 +583,7 @@ _mesa_update_draw_buffers(struct gl_context *ctx)
/* should be a window system FBO */
assert(_mesa_is_winsys_fbo(ctx->DrawBuffer));
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, ctx->Const.MaxDrawBuffers,
ctx->Color.DrawBuffer, NULL);
}
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index ebcfa1c1e74..bc6d74a867e 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -36,6 +36,7 @@
#include "glheader.h"
struct gl_context;
+struct gl_framebuffer;
extern void GLAPIENTRY
_mesa_DrawBuffer( GLenum mode );
@@ -44,7 +45,8 @@ extern void GLAPIENTRY
_mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
extern void
-_mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
+_mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint n, const GLenum *buffers,
const GLbitfield *destMask);
extern void
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 0a192de8c0a..279716a83d5 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1565,7 +1565,8 @@ handle_first_current(struct gl_context *ctx)
else
buffer = GL_FRONT;
- _mesa_drawbuffers(ctx, 1, &buffer, NULL /* destMask */);
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer,
+ NULL /* destMask */);
}
if (ctx->ReadBuffer != _mesa_get_incomplete_framebuffer()) {
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 0a0f73ba423..665a5ba1492 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -652,7 +652,7 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
* context state (GL_READ_BUFFER too).
*/
if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) {
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ _mesa_drawbuffers(ctx, fb, ctx->Const.MaxDrawBuffers,
ctx->Color.DrawBuffer, NULL);
}
}
From 2f32e4847d154a9d16869cf03ce66f719d37ec4a Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 6 Feb 2015 10:57:57 -0800
Subject: [PATCH 097/834] main: Refactor _mesa_DrawBuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This could have added a new DD table entry for DrawBuffer that takes an
arbitrary draw buffer, but, after looking at the existing DD functions,
Kenneth Graunke recommended that we just skip calling the DD functions in the
case of ARB_direct_state_access. The DD implementations for DrawBuffer(s)
have limited functionality, especially with respect to
ARB_direct_state_access.
[Fredrik: Call the driver function when fb is the bound draw buffer]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/buffers.c | 42 ++++++++++++++++++++++++-----------------
src/mesa/main/buffers.h | 4 ++++
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index a338013fed5..8b52a5392a8 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -242,16 +242,16 @@ read_buffer_enum_to_index(GLenum buffer)
*
* See the GL_EXT_framebuffer_object spec for more info.
*/
-void GLAPIENTRY
-_mesa_DrawBuffer(GLenum buffer)
+void
+_mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller)
{
GLbitfield destMask;
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API) {
- _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+ _mesa_debug(ctx, "%s %s\n", caller, _mesa_lookup_enum_by_nr(buffer));
}
if (buffer == GL_NONE) {
@@ -259,33 +259,41 @@ _mesa_DrawBuffer(GLenum buffer)
}
else {
const GLbitfield supportedMask
- = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
+ = supported_buffer_bitmask(ctx, fb);
destMask = draw_buffer_enum_to_bitmask(ctx, buffer);
if (destMask == BAD_MASK) {
/* totally bogus buffer */
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glDrawBuffer(buffer=0x%x)", buffer);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
return;
}
destMask &= supportedMask;
if (destMask == 0x0) {
/* none of the named color buffers exist! */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffer(buffer=0x%x)", buffer);
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffer));
return;
}
}
/* if we get here, there's no error so set new state */
- _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer, &destMask);
+ _mesa_drawbuffers(ctx, fb, 1, &buffer, &destMask);
- /*
- * Call device driver function.
- */
- if (ctx->Driver.DrawBuffers)
- ctx->Driver.DrawBuffers(ctx, 1, &buffer);
- else if (ctx->Driver.DrawBuffer)
- ctx->Driver.DrawBuffer(ctx, buffer);
+ /* Call device driver function only if fb is the bound draw buffer */
+ if (fb == ctx->DrawBuffer) {
+ if (ctx->Driver.DrawBuffers)
+ ctx->Driver.DrawBuffers(ctx, 1, &buffer);
+ else if (ctx->Driver.DrawBuffer)
+ ctx->Driver.DrawBuffer(ctx, buffer);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_DrawBuffer(GLenum buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_draw_buffer(ctx, ctx->DrawBuffer, buffer, "glDrawBuffer");
}
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index bc6d74a867e..4192afd3f13 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -38,6 +38,10 @@
struct gl_context;
struct gl_framebuffer;
+extern void
+_mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller);
+
extern void GLAPIENTRY
_mesa_DrawBuffer( GLenum mode );
From 642fb71277b6e4c5d57ad7a7d6f2d5aae9b746ef Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 6 Feb 2015 14:44:43 -0800
Subject: [PATCH 098/834] main: Add entry point for NamedFramebufferDrawBuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: Fix the name of the buf parameter in the XML file]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 5 +++++
src/mesa/main/buffers.c | 19 +++++++++++++++++++
src/mesa/main/buffers.h | 3 +++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 28 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 3617e48a19c..32e3c0afbeb 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -187,6 +187,11 @@
+
+
+
+
+
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 8b52a5392a8..9b66e38b1e1 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -297,6 +297,25 @@ _mesa_DrawBuffer(GLenum buffer)
}
+void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferDrawBuffer");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ _mesa_draw_buffer(ctx, fb, buf, "glNamedFramebufferDrawBuffer");
+}
+
+
/**
* Called by glDrawBuffersARB; specifies the destination color renderbuffers
* for N fragment program color outputs.
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 4192afd3f13..12d57430a39 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -45,6 +45,9 @@ _mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
extern void GLAPIENTRY
_mesa_DrawBuffer( GLenum mode );
+extern void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf);
+
extern void GLAPIENTRY
_mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 23ddabd169d..931eeceb212 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -985,6 +985,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferParameteri", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
+ { "glNamedFramebufferDrawBuffer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
From 7518c6b5b2ae8b2a6e931d4be1d5976d553983a0 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 6 Feb 2015 15:23:05 -0800
Subject: [PATCH 099/834] main: Refactor _mesa_ReadBuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This could have added a new DD table entry for ReadBuffer that takes an
arbitrary read buffer, but, after looking at the existing DD functions,
Kenneth Graunke recommended that we just skip calling the DD functions in the
case of ARB_direct_state_access. The DD implementations for ReadBuffer
have limited functionality, especially with respect to
ARB_direct_state_access.
[Fredrik: Call the driver function when fb is the bound read buffer]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/buffers.c | 47 ++++++++++++++++++++++-------------------
src/mesa/main/buffers.h | 7 +++++-
src/mesa/main/context.c | 2 +-
3 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 9b66e38b1e1..e1d1bafc367 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -623,11 +623,10 @@ _mesa_update_draw_buffers(struct gl_context *ctx)
* \param bufferIndex the numerical index corresponding to 'buffer'
*/
void
-_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex)
+_mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, GLint bufferIndex)
{
- struct gl_framebuffer *fb = ctx->ReadBuffer;
-
- if (_mesa_is_winsys_fbo(fb)) {
+ if ((fb == ctx->ReadBuffer) && _mesa_is_winsys_fbo(fb)) {
/* Only update the per-context READ_BUFFER state if we're bound to
* a window-system framebuffer.
*/
@@ -646,23 +645,17 @@ _mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex)
* Called by glReadBuffer to set the source renderbuffer for reading pixels.
* \param mode color buffer such as GL_FRONT, GL_BACK, etc.
*/
-void GLAPIENTRY
-_mesa_ReadBuffer(GLenum buffer)
+void
+_mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller)
{
- struct gl_framebuffer *fb;
GLbitfield supportedMask;
GLint srcBuffer;
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
-
- fb = ctx->ReadBuffer;
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+ _mesa_debug(ctx, "%s %s\n", caller, _mesa_lookup_enum_by_nr(buffer));
if (buffer == GL_NONE) {
/* This is legal--it means that no buffer should be bound for reading. */
@@ -673,24 +666,34 @@ _mesa_ReadBuffer(GLenum buffer)
srcBuffer = read_buffer_enum_to_index(buffer);
if (srcBuffer == -1) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glReadBuffer(buffer=0x%x)", buffer);
+ "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
return;
}
supportedMask = supported_buffer_bitmask(ctx, fb);
if (((1 << srcBuffer) & supportedMask) == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glReadBuffer(buffer=0x%x)", buffer);
+ "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
return;
}
}
/* OK, all error checking has been completed now */
- _mesa_readbuffer(ctx, buffer, srcBuffer);
+ _mesa_readbuffer(ctx, fb, buffer, srcBuffer);
- /*
- * Call device driver function.
- */
- if (ctx->Driver.ReadBuffer)
- (*ctx->Driver.ReadBuffer)(ctx, buffer);
+ /* Call the device driver function only if fb is the bound read buffer */
+ if (fb == ctx->ReadBuffer) {
+ if (ctx->Driver.ReadBuffer)
+ (*ctx->Driver.ReadBuffer)(ctx, buffer);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_ReadBuffer(GLenum buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_read_buffer(ctx, ctx->ReadBuffer, buffer, "glReadBuffer");
}
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 12d57430a39..ca7ad19235b 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -57,12 +57,17 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
const GLbitfield *destMask);
extern void
-_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex);
+_mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, GLint bufferIndex);
extern void
_mesa_update_draw_buffers(struct gl_context *ctx);
+extern void
+_mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller);
+
extern void GLAPIENTRY
_mesa_ReadBuffer( GLenum mode );
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 279716a83d5..544cc142fde 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1579,7 +1579,7 @@ handle_first_current(struct gl_context *ctx)
bufferIndex = BUFFER_FRONT_LEFT;
}
- _mesa_readbuffer(ctx, buffer, bufferIndex);
+ _mesa_readbuffer(ctx, ctx->ReadBuffer, buffer, bufferIndex);
}
}
From 1f0a5f32d328e54483dd623ad09bd3f6b119f7a6 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Fri, 6 Feb 2015 15:36:52 -0800
Subject: [PATCH 100/834] main: Add entry point for NamedFramebufferReadBuffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Fredrik: Fix the name of the buf parameter in the XML file]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 5 +++++
src/mesa/main/buffers.c | 19 +++++++++++++++++++
src/mesa/main/buffers.h | 3 +++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 28 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 32e3c0afbeb..6e5c4d30462 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -192,6 +192,11 @@
+
+
+
+
+
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index e1d1bafc367..d9979ad9ed5 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -697,3 +697,22 @@ _mesa_ReadBuffer(GLenum buffer)
GET_CURRENT_CONTEXT(ctx);
_mesa_read_buffer(ctx, ctx->ReadBuffer, buffer, "glReadBuffer");
}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferReadBuffer");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysReadBuffer;
+
+ _mesa_read_buffer(ctx, fb, src, "glNamedFramebufferReadBuffer");
+}
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index ca7ad19235b..52a23188194 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -71,5 +71,8 @@ _mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
extern void GLAPIENTRY
_mesa_ReadBuffer( GLenum mode );
+extern void GLAPIENTRY
+_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src);
+
#endif
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 931eeceb212..dcbb0c69e4c 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -986,6 +986,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glNamedFramebufferDrawBuffer", 45, -1 },
+ { "glNamedFramebufferReadBuffer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
From 68c6964b376df7ef2248fab83e0f8abc6df56d47 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 9 Feb 2015 13:33:13 -0800
Subject: [PATCH 101/834] main: Refactor DrawBuffers.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This could have added a new DD table entry for DrawBuffers that takes an
arbitrary draw buffer, but, after looking at the existing DD functions,
Kenneth Graunke recommended that we just skip calling the DD functions in the
case of ARB_direct_state_access. The DD implementations for DrawBuffer(s)
have limited functionality, especially with respect to
ARB_direct_state_access.
[Fredrik: Call the driver function when fb is the bound draw buffer]
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
src/mesa/main/buffers.c | 71 ++++++++++++++++++++++++++++-------------
src/mesa/main/buffers.h | 4 +++
2 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index d9979ad9ed5..0c6d379309f 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -325,13 +325,13 @@ _mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
* names cannot specify more than one buffer. For example,
* GL_FRONT_AND_BACK is illegal.
*/
-void GLAPIENTRY
-_mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
+void
+_mesa_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLsizei n, const GLenum *buffers, const char *caller)
{
GLuint output;
GLbitfield usedBufferMask, supportedMask;
GLbitfield destMask[MAX_DRAW_BUFFERS];
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
@@ -342,12 +342,18 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* "An INVALID_VALUE error is generated if n is greater than
* MAX_DRAW_BUFFERS."
*/
- if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)");
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", caller);
return;
}
- supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
+ if (n > (GLsizei) ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(n > maximum number of draw buffers)", caller);
+ return;
+ }
+
+ supportedMask = supported_buffer_bitmask(ctx, fb);
usedBufferMask = 0x0;
/* From the ES 3.0 specification, page 180:
@@ -355,9 +361,9 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* and the constant must be BACK or NONE."
* (same restriction applies with GL_EXT_draw_buffers specification)
*/
- if (ctx->API == API_OPENGLES2 && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
+ if (ctx->API == API_OPENGLES2 && _mesa_is_winsys_fbo(fb) &&
(n != 1 || (buffers[0] != GL_NONE && buffers[0] != GL_BACK))) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid buffers)", caller);
return;
}
@@ -389,9 +395,11 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* or equal to the value of MAX_COLOR_ATTACHMENTS, then the error
* INVALID_OPERATION results."
*/
- if (_mesa_is_user_fbo(ctx->DrawBuffer) && buffers[output] >=
+ if (_mesa_is_user_fbo(fb) && buffers[output] >=
GL_COLOR_ATTACHMENT0 + ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffersARB(buffer)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(buffers[%d] >= maximum number of draw buffers)",
+ caller, output);
return;
}
@@ -402,9 +410,10 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* 4.5 or 4.6. Otherwise, an INVALID_ENUM error is generated.
*/
if (destMask[output] == BAD_MASK) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
- }
+ }
/* From the OpenGL 4.0 specification, page 256:
* "For both the default framebuffer and framebuffer objects, the
@@ -417,7 +426,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* but the Khronos conformance tests expect INVALID_ENUM.
*/
if (_mesa_bitcount(destMask[output]) > 1) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -434,7 +444,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
destMask[output] &= supportedMask;
if (destMask[output] == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffersARB(unsupported buffer)");
+ "%s(unsupported buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -443,10 +454,12 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* in bufs must be COLOR_ATTACHMENTi or NONE. [...] INVALID_OPERATION."
* (same restriction applies with GL_EXT_draw_buffers specification)
*/
- if (ctx->API == API_OPENGLES2 && _mesa_is_user_fbo(ctx->DrawBuffer) &&
+ if (ctx->API == API_OPENGLES2 && _mesa_is_user_fbo(fb) &&
buffers[output] != GL_NONE &&
buffers[output] != GL_COLOR_ATTACHMENT0 + output) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(unsupported buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -457,7 +470,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
*/
if (destMask[output] & usedBufferMask) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffersARB(duplicated buffer)");
+ "%s(duplicated buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -467,17 +481,28 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
}
/* OK, if we get here, there were no errors so set the new state */
- _mesa_drawbuffers(ctx, ctx->DrawBuffer, n, buffers, destMask);
+ _mesa_drawbuffers(ctx, fb, n, buffers, destMask);
/*
- * Call device driver function. Note that n can be equal to 0,
+ * Call device driver function if fb is the bound draw buffer.
+ * Note that n can be equal to 0,
* in which case we don't want to reference buffers[0], which
* may not be valid.
*/
- if (ctx->Driver.DrawBuffers)
- ctx->Driver.DrawBuffers(ctx, n, buffers);
- else if (ctx->Driver.DrawBuffer)
- ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE);
+ if (fb == ctx->DrawBuffer) {
+ if (ctx->Driver.DrawBuffers)
+ ctx->Driver.DrawBuffers(ctx, n, buffers);
+ else if (ctx->Driver.DrawBuffer)
+ ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_draw_buffers(ctx, ctx->DrawBuffer, n, buffers, "glDrawBuffers");
}
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 52a23188194..66871d70a09 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -48,6 +48,10 @@ _mesa_DrawBuffer( GLenum mode );
extern void GLAPIENTRY
_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf);
+extern void
+_mesa_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLsizei n, const GLenum *buffers, const char *caller);
+
extern void GLAPIENTRY
_mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
From 9de7a81626304dae5ced4e202a820e353f8fc1e9 Mon Sep 17 00:00:00 2001
From: Laura Ekstrand
Date: Mon, 9 Feb 2015 14:08:00 -0800
Subject: [PATCH 102/834] main: Add entry point for
NamedFramebufferDrawBuffers.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fredrik Höglund
Signed-off-by: Fredrik Höglund
---
.../glapi/gen/ARB_direct_state_access.xml | 6 ++++++
src/mesa/main/buffers.c | 20 +++++++++++++++++++
src/mesa/main/buffers.h | 4 ++++
src/mesa/main/tests/dispatch_sanity.cpp | 1 +
4 files changed, 31 insertions(+)
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 6e5c4d30462..bb9baf5a3d0 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -192,6 +192,12 @@
+
+
+
+
+
+
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 0c6d379309f..0536266d756 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -506,6 +506,26 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
}
+void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
+ const GLenum *bufs)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferDrawBuffers");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ _mesa_draw_buffers(ctx, fb, n, bufs, "glNamedFramebufferDrawBuffers");
+}
+
+
/**
* Performs necessary state updates when _mesa_drawbuffers makes an
* actual change.
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 66871d70a09..5aa79fda54b 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -55,6 +55,10 @@ _mesa_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
extern void GLAPIENTRY
_mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
+extern void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
+ const GLenum *bufs);
+
extern void
_mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
GLuint n, const GLenum *buffers,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index dcbb0c69e4c..77dc1401d19 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -986,6 +986,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glNamedFramebufferDrawBuffer", 45, -1 },
+ { "glNamedFramebufferDrawBuffers", 45, -1 },
{ "glNamedFramebufferReadBuffer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
From 30dcaaec356cc117d7227c6680620cd50ff534e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:34:03 +0200
Subject: [PATCH 103/834] mesa: Add an extension flag for
ARB_direct_state_access
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/extensions.c | 2 +-
src/mesa/main/mtypes.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index f7ce0642aef..c82416aa072 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -104,7 +104,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 },
{ "GL_ARB_depth_texture", o(ARB_depth_texture), GLL, 2001 },
{ "GL_ARB_derivative_control", o(ARB_derivative_control), GL, 2014 },
- { "GL_ARB_direct_state_access", o(dummy_false), GL, 2014 },
+ { "GL_ARB_direct_state_access", o(ARB_direct_state_access), GL, 2014 },
{ "GL_ARB_draw_buffers", o(dummy_true), GL, 2002 },
{ "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 },
{ "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 737f0be6d62..83425176a3f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3621,6 +3621,7 @@ struct gl_extensions
GLboolean ARB_depth_clamp;
GLboolean ARB_depth_texture;
GLboolean ARB_derivative_control;
+ GLboolean ARB_direct_state_access;
GLboolean ARB_draw_buffers_blend;
GLboolean ARB_draw_elements_base_vertex;
GLboolean ARB_draw_indirect;
From 03420eac0c53280beae5f72783e52950fd1e3fba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Wed, 29 Apr 2015 19:44:06 +0200
Subject: [PATCH 104/834] mesa: Make GL_TEXTURE_CUBE_MAP valid in
FramebufferTextureLayer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/fbobject.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 971dc688a04..c2bc081cf1a 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2704,9 +2704,9 @@ static bool
check_texture_target(struct gl_context *ctx, GLenum target,
const char *caller)
{
- /* We're being called by glFramebufferTextureLayer() and
- * textarget is not used. The only legal texture types for
- * that function are 3D and 1D/2D arrays textures.
+ /* We're being called by glFramebufferTextureLayer().
+ * The only legal texture types for that function are 3D,
+ * cube-map, and 1D/2D/cube-map array textures.
*/
switch (target) {
case GL_TEXTURE_3D:
@@ -2715,6 +2715,11 @@ check_texture_target(struct gl_context *ctx, GLenum target,
case GL_TEXTURE_CUBE_MAP_ARRAY:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
return true;
+ case GL_TEXTURE_CUBE_MAP:
+ /* This target is valid in TextureLayer when ARB_direct_state_access
+ * or OpenGL 4.5 is supported.
+ */
+ return ctx->Extensions.ARB_direct_state_access;
}
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -2847,6 +2852,13 @@ check_layer(struct gl_context *ctx, GLenum target, GLint layer,
return false;
}
}
+ else if (target == GL_TEXTURE_CUBE_MAP) {
+ if (layer >= 6) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(layer %u >= 6)", caller, layer);
+ return false;
+ }
+ }
return true;
}
@@ -3035,6 +3047,7 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
+ GLenum textarget = 0;
const char *func = "glFramebufferTextureLayer";
@@ -3060,9 +3073,15 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
if (!check_level(ctx, texObj->Target, level, func))
return;
+
+ if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
+ assert(layer >= 0 && layer < 6);
+ textarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
+ layer = 0;
+ }
}
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
layer, GL_FALSE, func);
}
@@ -3074,6 +3093,7 @@ _mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
struct gl_texture_object *texObj;
+ GLenum textarget = 0;
const char *func = "glNamedFramebufferTextureLayer";
@@ -3095,9 +3115,15 @@ _mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
if (!check_level(ctx, texObj->Target, level, func))
return;
+
+ if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
+ assert(layer >= 0 && layer < 6);
+ textarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
+ layer = 0;
+ }
}
- _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
layer, GL_FALSE, func);
}
From 7d212765a470972f4712e42caf6406b257220369 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:44:07 +0200
Subject: [PATCH 105/834] mesa: Add ARB_direct_state_access checks in XFB
functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/transformfeedback.c | 42 +++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 103011ce572..642fa96477a 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -706,6 +706,13 @@ _mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer)
struct gl_transform_feedback_object *obj;
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTransformFeedbackBufferBase(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glTransformFeedbackBufferBase");
if(!obj) {
@@ -729,6 +736,13 @@ _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
struct gl_transform_feedback_object *obj;
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTransformFeedbackBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glTransformFeedbackBufferRange");
if(!obj) {
@@ -1045,6 +1059,13 @@ _mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateTransformFeedbacks(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
create_transform_feedbacks(ctx, n, names, true);
}
@@ -1215,6 +1236,13 @@ _mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param)
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTransformFeedbackiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbackiv");
if(!obj) {
@@ -1241,6 +1269,13 @@ _mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index,
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTransformFeedbacki_v(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbacki_v");
if(!obj) {
@@ -1270,6 +1305,13 @@ _mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index,
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTransformFeedbacki64_v(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbacki64_v");
if(!obj) {
From 339ed0984d4f54fca91235a1df2ce3a850f6123f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:46:36 +0200
Subject: [PATCH 106/834] mesa: Add ARB_direct_state_access checks in buffer
object functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/bufferobj.c | 105 ++++++++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 66dee680258..660bc94892e 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1303,6 +1303,12 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa)
const char *func = dsa ? "glCreateBuffers" : "glGenBuffers";
+ if (dsa && !ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "%s(%d)\n", func, n);
@@ -1477,6 +1483,13 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedBufferStorage(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferStorage");
if (!bufObj)
return;
@@ -1603,6 +1616,13 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedBufferData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData");
if (!bufObj)
return;
@@ -1673,6 +1693,13 @@ _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData");
if (!bufObj)
return;
@@ -1710,6 +1737,13 @@ _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferSubData");
if (!bufObj)
@@ -1805,6 +1839,13 @@ _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedBufferData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glClearNamedBufferData");
if (!bufObj)
return;
@@ -1842,6 +1883,13 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glClearNamedBufferSubData");
if (!bufObj)
@@ -1930,6 +1978,13 @@ _mesa_UnmapNamedBuffer(GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glUnmapNamedBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return GL_FALSE;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glUnmapNamedBuffer");
if (!bufObj)
return GL_FALSE;
@@ -2039,6 +2094,13 @@ _mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params)
struct gl_buffer_object *bufObj;
GLint64 parameter;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferParameteriv");
if (!bufObj)
@@ -2059,6 +2121,13 @@ _mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
struct gl_buffer_object *bufObj;
GLint64 parameter;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferParameteri64v(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferParameteri64v");
if (!bufObj)
@@ -2098,6 +2167,13 @@ _mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferPointerv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (pname != GL_BUFFER_MAP_POINTER) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetNamedBufferPointerv(pname != "
"GL_BUFFER_MAP_POINTER)");
@@ -2212,6 +2288,13 @@ _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *src, *dst;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
src = _mesa_lookup_bufferobj_err(ctx, readBuffer,
"glCopyNamedBufferSubData");
if (!src)
@@ -2430,6 +2513,13 @@ _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glMapNamedBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return NULL;
+ }
+
if (!ctx->Extensions.ARB_map_buffer_range) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glMapNamedBufferRange("
@@ -2497,6 +2587,13 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access)
struct gl_buffer_object *bufObj;
GLbitfield accessFlags;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glMapNamedBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return NULL;
+ }
+
if (!get_map_buffer_access_flags(ctx, access, &accessFlags)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glMapNamedBuffer(invalid access)");
return NULL;
@@ -2587,6 +2684,14 @@ _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glFlushMappedNamedBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glFlushMappedNamedBufferRange");
if (!bufObj)
From 6ad0b7e07a0445e9e0f368e079c4f7b8a6757bb3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:48:11 +0200
Subject: [PATCH 107/834] mesa: Add ARB_direct_state_access checks in FBO
functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/blit.c | 7 +++++
src/mesa/main/buffers.c | 21 +++++++++++++
src/mesa/main/clear.c | 32 +++++++++++++++++++
src/mesa/main/fbobject.c | 67 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 127 insertions(+)
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index db8fee5a414..fac97245082 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -540,6 +540,13 @@ _mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *readFb, *drawFb;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBlitNamedFramebuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx,
"glBlitNamedFramebuffer(%u %u %d, %d, %d, %d, "
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 0536266d756..c83459addf7 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -303,6 +303,13 @@ _mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferDrawBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (framebuffer) {
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferDrawBuffer");
@@ -513,6 +520,13 @@ _mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferDrawBuffers(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (framebuffer) {
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferDrawBuffers");
@@ -750,6 +764,13 @@ _mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferReadBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (framebuffer) {
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferReadBuffer");
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 426caea4709..c6999f7fdb6 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -412,6 +412,14 @@ _mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferiv(buffer, drawbuffer, value);
@@ -502,6 +510,14 @@ _mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferuiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferuiv(buffer, drawbuffer, value);
@@ -613,6 +629,14 @@ _mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferfv(buffer, drawbuffer, value);
@@ -695,6 +719,14 @@ _mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
{
GLint oldfb;
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferfi(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
_mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
_mesa_ClearBufferfi(buffer, 0, depth, stencil);
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index c2bc081cf1a..65e194cb749 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2454,6 +2454,12 @@ create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa)
const char *func = dsa ? "glCreateFramebuffers" : "glGenFramebuffers";
+ if (dsa && !ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
+
if (n < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
return;
@@ -2552,6 +2558,13 @@ _mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target)
struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCheckNamedFramebufferStatus(GL_ARB_direct_state_access "
+ "is not supported)");
+ return 0;
+ }
+
/* Validate the target (for conformance's sake) and grab a reference to the
* default framebuffer in case framebuffer = 0.
* Section 9.4 Framebuffer Completeness of the OpenGL 4.5 core spec
@@ -3097,6 +3110,12 @@ _mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
const char *func = "glNamedFramebufferTextureLayer";
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
+
/* Get the framebuffer object */
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
if (!fb)
@@ -3182,6 +3201,12 @@ _mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
const char *func = "glNamedFramebufferTexture";
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
+
if (!_mesa_has_geometry_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"unsupported function (glNamedFramebufferTexture) called");
@@ -3307,6 +3332,13 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
struct gl_renderbuffer *rb;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferRenderbuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glNamedFramebufferRenderbuffer");
@@ -3639,6 +3671,13 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *buffer;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedFramebufferAttachmentParameteriv("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
if (framebuffer) {
buffer = _mesa_lookup_framebuffer_err(ctx, framebuffer,
"glGetNamedFramebufferAttachmentParameteriv");
@@ -3671,6 +3710,13 @@ _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
(void) pname;
(void) param;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferParameteri("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
_mesa_error(ctx, GL_INVALID_OPERATION,
"glNamedFramebufferParameteri not supported "
"(ARB_framebuffer_no_attachments not implemented)");
@@ -3687,6 +3733,13 @@ _mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
(void) pname;
(void) param;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferParameteriv("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetNamedFramebufferParameteriv not supported "
"(ARB_framebuffer_no_attachments not implemented)");
@@ -3855,6 +3908,13 @@ _mesa_InvalidateNamedFramebufferSubData(GLuint framebuffer,
struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glInvalidateNamedFramebufferSubData("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
/* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
* Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
* default draw framebuffer is affected."
@@ -3916,6 +3976,13 @@ _mesa_InvalidateNamedFramebufferData(GLuint framebuffer,
struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glInvalidateNamedFramebufferData("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
/* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
* Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
* default draw framebuffer is affected."
From cb49940766b581c6656473d89c221653c69fa0f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:49:15 +0200
Subject: [PATCH 108/834] mesa: Add ARB_direct_state_access checks in
renderbuffer functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/fbobject.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 65e194cb749..8db651ca2a1 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1489,6 +1489,14 @@ void GLAPIENTRY
_mesa_CreateRenderbuffers(GLsizei n, GLuint *renderbuffers)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateRenderbuffers(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
create_render_buffers(ctx, n, renderbuffers, true);
}
@@ -1929,6 +1937,12 @@ renderbuffer_storage_named(GLuint renderbuffer, GLenum internalFormat,
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
+
if (MESA_VERBOSE & VERBOSE_API) {
if (samples == NO_SAMPLES)
_mesa_debug(ctx, "%s(%u, %s, %d, %d)\n",
@@ -2183,6 +2197,13 @@ _mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname,
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedRenderbufferParameteriv("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
if (!rb || rb == &DummyRenderbuffer) {
/* ID was reserved, but no real renderbuffer object made yet */
From 8940957238e8584ce27295791cee4cc3d6f7cf1e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:52:49 +0200
Subject: [PATCH 109/834] mesa: Add ARB_direct_state_access checks in texture
functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/genmipmap.c | 7 ++++
src/mesa/main/texgetimage.c | 14 +++++++
src/mesa/main/teximage.c | 74 ++++++++++++++++++++++++++++++++
src/mesa/main/texobj.c | 14 +++++++
src/mesa/main/texparam.c | 84 +++++++++++++++++++++++++++++++++++++
src/mesa/main/texstorage.c | 7 ++++
6 files changed, 200 insertions(+)
diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c
index 9aef090194e..32b9460ad07 100644
--- a/src/mesa/main/genmipmap.c
+++ b/src/mesa/main/genmipmap.c
@@ -158,6 +158,13 @@ _mesa_GenerateTextureMipmap(GLuint texture)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGenerateTextureMipmap(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, "glGenerateTextureMipmap");
if (!texObj)
return;
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 92b4d6795c6..f582a7f78b0 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -1108,6 +1108,13 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format,
GLenum err;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureImage(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/*
* This has been moved here because a format/type mismatch can cause a NULL
* texImage object, which in turn causes the mismatch error to be
@@ -1344,6 +1351,13 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint level,
GLint image_stride;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetCompressedTextureImage(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetCompressedTextureImage");
if (!texObj)
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 7bc1da7f805..7616fd7cec9 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3624,6 +3624,13 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
_mesa_lookup_enum_by_nr(format),
_mesa_lookup_enum_by_nr(type), pixels);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureSubImage%uD(GL_ARB_direct_state_access "
+ "is not supported)", dims);
+ return;
+ }
+
/* Get the texture object by Name. */
texObj = _mesa_lookup_texture(ctx, texture);
if (!texObj) {
@@ -4183,6 +4190,12 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage1D";
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", self);
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4207,6 +4220,12 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage2D";
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", self);
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4234,6 +4253,12 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage3D";
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", self);
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4829,6 +4854,13 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTextureSubImage1D(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage1D");
if (!texObj)
@@ -4907,6 +4939,13 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTextureSubImage2D(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage2D");
if (!texObj)
@@ -4985,6 +5024,13 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTextureSubImage3D(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage3D");
if (!texObj)
@@ -5469,6 +5515,13 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTextureBuffer");
if (!bufObj)
@@ -5497,6 +5550,13 @@ _mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glTextureBufferRange");
@@ -5801,6 +5861,13 @@ _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage2DMultisample(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glTextureStorage2DMultisample");
if (!texObj)
@@ -5821,6 +5888,13 @@ _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage3DMultisample(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/* Get the texture object by Name. */
texObj = _mesa_lookup_texture_err(ctx, texture,
"glTextureStorage3DMultisample");
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index c563f1e7434..d51e6954ba0 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1317,6 +1317,13 @@ _mesa_CreateTextures(GLenum target, GLsizei n, GLuint *textures)
GLint targetIndex;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateTextures(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/*
* The 4.5 core profile spec (30.10.2014) doesn't specify what
* glCreateTextures should do with invalid targets, which was probably an
@@ -1808,6 +1815,13 @@ _mesa_BindTextureUnit(GLuint unit, GLuint texture)
_mesa_debug(ctx, "glBindTextureUnit %s %d\n",
_mesa_lookup_enum_by_nr(GL_TEXTURE0+unit), (GLint) texture);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindTextureUnit(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/* Section 8.1 (Texture Objects) of the OpenGL 4.5 core profile spec
* (20141030) says:
* "When texture is zero, each of the targets enumerated at the
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index d74134f41b1..1fa5830026a 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1108,6 +1108,13 @@ _mesa_TextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1124,6 +1131,13 @@ _mesa_TextureParameterf(GLuint texture, GLenum pname, GLfloat param)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterf(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1140,6 +1154,13 @@ _mesa_TextureParameteri(GLuint texture, GLenum pname, GLint param)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameteri(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1157,6 +1178,13 @@ _mesa_TextureParameteriv(GLuint texture, GLenum pname,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1174,6 +1202,13 @@ _mesa_TextureParameterIiv(GLuint texture, GLenum pname, const GLint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1191,6 +1226,13 @@ _mesa_TextureParameterIuiv(GLuint texture, GLenum pname, const GLuint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIuiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1650,6 +1692,13 @@ _mesa_GetTextureLevelParameterfv(GLuint texture, GLint level,
GLint iparam;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureLevelParameterfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetTextureLevelParameterfv");
if (!texObj)
@@ -1668,6 +1717,13 @@ _mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureLevelParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetTextureLevelParameteriv");
if (!texObj)
@@ -2227,6 +2283,13 @@ _mesa_GetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params)
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!obj) {
/* User passed a non-generated name. */
@@ -2244,6 +2307,13 @@ _mesa_GetTextureParameteriv(GLuint texture, GLenum pname, GLint *params)
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!obj) {
/* User passed a non-generated name. */
@@ -2261,6 +2331,13 @@ _mesa_GetTextureParameterIiv(GLuint texture, GLenum pname, GLint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterIiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -2279,6 +2356,13 @@ _mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterIuiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!texObj) {
/* User passed a non-generated name. */
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index 53cb2c091f8..dee74a825ea 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -507,6 +507,13 @@ texturestorage(GLuint dims, GLuint texture, GLsizei levels,
_mesa_lookup_enum_by_nr(internalformat),
width, height, depth);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage%uD(GL_ARB_direct_state_access "
+ "is not supported)", dims);
+ return;
+ }
+
/* Check the format to make sure it is sized. */
if (!_mesa_is_legal_tex_storage_format(ctx, internalformat)) {
_mesa_error(ctx, GL_INVALID_ENUM,
From 36b05793372b86b914d9b95d0188f5f387e01d68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:54:18 +0200
Subject: [PATCH 110/834] mesa: Add ARB_direct_state_access checks in VAO
functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/arrayobj.c | 22 ++++++++++++++
src/mesa/main/varray.c | 64 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 7c4004043de..320f435ea94 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -617,6 +617,14 @@ void GLAPIENTRY
_mesa_CreateVertexArrays(GLsizei n, GLuint *arrays)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateVertexArrays(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
gen_vertex_arrays(ctx, n, arrays, true, "glCreateVertexArrays");
}
@@ -659,6 +667,13 @@ _mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
struct gl_vertex_array_object *vao;
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayElementBuffer(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The GL_ARB_direct_state_access specification says:
@@ -695,6 +710,13 @@ _mesa_GetVertexArrayiv(GLuint vaobj, GLenum pname, GLint *param)
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexArrayiv(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
/* The GL_ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated if is not
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 7389037ae85..da6bbce52aa 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -777,6 +777,13 @@ _mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index)
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glEnableVertexArrayAttrib(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
@@ -830,6 +837,13 @@ _mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index)
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDisableVertexArrayAttrib(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
@@ -1094,6 +1108,13 @@ _mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexArrayIndexediv(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated if is not
@@ -1157,6 +1178,14 @@ _mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexArrayIndexed64iv(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated if is not
@@ -1745,6 +1774,13 @@ _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayVertexBuffer(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
@@ -1910,6 +1946,14 @@ _mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayVertexBuffers(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
@@ -2018,6 +2062,12 @@ vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size,
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported", func);
+ return;
+ }
+
ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The ARB_direct_state_access spec says:
@@ -2155,6 +2205,13 @@ _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, GLuint bindingI
GET_CURRENT_CONTEXT(ctx);
struct gl_vertex_array_object *vao;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayAttribBinding(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayAttribBinding
@@ -2229,6 +2286,13 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint diviso
struct gl_vertex_array_object *vao;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayBindingDivisor(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
/* The ARB_direct_state_access specification says:
*
* "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor
From 9e7149c8986348bf9567f049444783ef52775f4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:55:31 +0200
Subject: [PATCH 111/834] mesa: Add ARB_direct_state_access checks in sampler
object functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/samplerobj.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index a3aacc66aa3..60711a5b5e3 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -221,6 +221,13 @@ void GLAPIENTRY
_mesa_CreateSamplers(GLsizei count, GLuint *samplers)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glCreateSamplers("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
create_samplers(ctx, count, samplers, "glCreateSamplers");
}
From bebf3c6ab314bde05ac5a3b4d3e63fd36243c58e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:56:18 +0200
Subject: [PATCH 112/834] mesa: Add ARB_direct_state_access checks in program
pipeline functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/pipelineobj.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 0fefa7d568b..a33cdd139c8 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -553,6 +553,12 @@ _mesa_CreateProgramPipelines(GLsizei n, GLuint *pipelines)
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glCreateProgramPipelines("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
create_program_pipelines(ctx, n, pipelines, true);
}
From d3368e0c9e27ced6059eb2ecdf2aa999a00e90b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 20:57:29 +0200
Subject: [PATCH 113/834] mesa: Add ARB_direct_state_access checks in query
object functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/main/queryobj.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index 5ff1b953231..2784b4c0532 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -284,6 +284,13 @@ _mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids)
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateQueries(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
switch (target) {
case GL_SAMPLES_PASSED:
case GL_ANY_SAMPLES_PASSED:
From 121030eed8fc41789d2f4f7517bbc0dd6199667b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 21:04:22 +0200
Subject: [PATCH 114/834] i915: Enable ARB_direct_state_access
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This extension requires OpenGL 2.0, so enable it on gen3 and later.
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/drivers/dri/i915/intel_extensions.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/mesa/drivers/dri/i915/intel_extensions.c b/src/mesa/drivers/dri/i915/intel_extensions.c
index ab7820f1232..590c6efcccd 100644
--- a/src/mesa/drivers/dri/i915/intel_extensions.c
+++ b/src/mesa/drivers/dri/i915/intel_extensions.c
@@ -83,6 +83,7 @@ intelInitExtensions(struct gl_context *ctx)
if (intel->gen >= 3) {
ctx->Extensions.ARB_ES2_compatibility = true;
ctx->Extensions.ARB_depth_texture = true;
+ ctx->Extensions.ARB_direct_state_access = true;
ctx->Extensions.ARB_fragment_program = true;
ctx->Extensions.ARB_shadow = true;
ctx->Extensions.ARB_texture_non_power_of_two = true;
From a57feba0a35de35728269aeb26b039e4f2393d69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 21:05:11 +0200
Subject: [PATCH 115/834] i965: Enable ARB_direct_state_access
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c
index cafb77455d7..18b69a0fd8b 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -183,6 +183,7 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.ARB_depth_buffer_float = true;
ctx->Extensions.ARB_depth_clamp = true;
ctx->Extensions.ARB_depth_texture = true;
+ ctx->Extensions.ARB_direct_state_access = true;
ctx->Extensions.ARB_draw_elements_base_vertex = true;
ctx->Extensions.ARB_draw_instanced = true;
ctx->Extensions.ARB_ES2_compatibility = true;
From 357bf80caade9e0be20dcc88ec38884e34abc986 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Sun, 10 May 2015 21:06:52 +0200
Subject: [PATCH 116/834] st/mesa: Enable ARB_direct_state_access
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Assume that all drivers that advertise support for NPOT textures
are able to support GL 2.0.
v2: Add a comment.
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
src/mesa/state_tracker/st_extensions.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index b1057f3eadd..23a45883d9a 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -650,6 +650,12 @@ void st_init_extensions(struct pipe_screen *screen,
ARRAY_SIZE(vertex_mapping), PIPE_BUFFER,
PIPE_BIND_VERTEX_BUFFER);
+ /* ARB_direct_state_access requires OpenGL 2.0. Assume that all drivers
+ * that support NPOT textures are able to support GL 2.0.
+ */
+ if (extensions->ARB_texture_non_power_of_two)
+ extensions->ARB_direct_state_access = GL_TRUE;
+
if (extensions->ARB_stencil_texturing)
extensions->ARB_texture_stencil8 = GL_TRUE;
From d9109cc2111a765f09fbf54072b77528e35c156d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Thu, 7 May 2015 20:29:21 +0200
Subject: [PATCH 117/834] docs: Update the ARB_direct_state_access status
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
docs/GL3.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/GL3.txt b/docs/GL3.txt
index 5a15bc55f47..c7009308aba 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -192,10 +192,10 @@ GL 4.5, GLSL 4.50:
GL_ARB_conditional_render_inverted DONE (i965, nv50, nvc0, llvmpipe, softpipe)
GL_ARB_cull_distance not started
GL_ARB_derivative_control DONE (i965, nv50, nvc0, r600)
- GL_ARB_direct_state_access started
+ GL_ARB_direct_state_access DONE (all drivers)
- Transform Feedback object DONE
- Buffer object DONE
- - Framebuffer object started (Laura Ekstrand)
+ - Framebuffer object DONE
- Renderbuffer object DONE
- Texture object DONE
- Vertex array object DONE
From b9cb7c19806e8ec33a626c289788876499cd8a27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=B6glund?=
Date: Thu, 7 May 2015 20:29:46 +0200
Subject: [PATCH 118/834] docs/relnotes: Mark off ARB_direct_state_access for
10.6
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
v2: Make it clear that ARB_direct_state_access is only available on
drivers that support GL 2.0+
Signed-off-by: Fredrik Höglund
Reviewed-by: Adam Jackson
---
docs/relnotes/10.6.0.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/relnotes/10.6.0.html b/docs/relnotes/10.6.0.html
index 6d379868865..474a2c71fd0 100644
--- a/docs/relnotes/10.6.0.html
+++ b/docs/relnotes/10.6.0.html
@@ -48,6 +48,7 @@ Note: some of the new features are only available with certain drivers.
GL_ARB_clip_control on i965
GL_ARB_depth_buffer_float on freedreno
GL_ARB_depth_clamp on freedreno
+
GL_ARB_direct_state_access on all drivers that support GL 2.0+
GL_ARB_draw_indirect, GL_ARB_multi_draw_indirect on r600
GL_ARB_draw_instanced on freedreno
GL_ARB_gpu_shader_fp64 on nvc0, softpipe
From 48c84a36dd04774489ab655a583ecb9266476856 Mon Sep 17 00:00:00 2001
From: Samuel Pitoiset
Date: Mon, 11 May 2015 21:36:16 +0200
Subject: [PATCH 119/834] nvc0: do not expose MP counters for nvf0 (GK110+)
This fixes a crash when trying to monitor MP counters because compute
support is not implemented for nvf0.
Reported-by: Ilia Mirkin
Signed-off-by: Samuel Pitoiset
Reviewed-by: Ilia Mirkin