diff options
Diffstat (limited to 'mesalib/src')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_dump_state.c | 1416 | ||||
-rw-r--r-- | mesalib/src/mesa/main/enable.c | 27 | ||||
-rw-r--r-- | mesalib/src/mesa/main/get.c | 43 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texgetimage.c | 150 | ||||
-rw-r--r-- | mesalib/src/mesa/main/version.c | 25 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_atom_sampler.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_texture.c | 79 |
7 files changed, 905 insertions, 837 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_dump_state.c b/mesalib/src/gallium/auxiliary/util/u_dump_state.c index 54128e6f6..6bb369966 100644 --- a/mesalib/src/gallium/auxiliary/util/u_dump_state.c +++ b/mesalib/src/gallium/auxiliary/util/u_dump_state.c @@ -1,708 +1,708 @@ -/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "pipe/p_compiler.h"
-#include "os/os_stream.h"
-#include "util/u_memory.h"
-#include "util/u_string.h"
-#include "util/u_format.h"
-#include "tgsi/tgsi_dump.h"
-
-#include "u_dump.h"
-
-
-/*
- * Dump primitives
- */
-
-static INLINE void
-util_stream_writef(struct os_stream *stream, const char *format, ...)
-{
- static char buf[1024];
- unsigned len;
- va_list ap;
- va_start(ap, format);
- len = util_vsnprintf(buf, sizeof(buf), format, ap);
- va_end(ap);
- os_stream_write(stream, buf, len);
-}
-
-static void
-util_dump_bool(struct os_stream *stream, int value)
-{
- util_stream_writef(stream, "%c", value ? '1' : '0');
-}
-
-static void
-util_dump_int(struct os_stream *stream, long long int value)
-{
- util_stream_writef(stream, "%lli", value);
-}
-
-static void
-util_dump_uint(struct os_stream *stream, long long unsigned value)
-{
- util_stream_writef(stream, "%llu", value);
-}
-
-static void
-util_dump_float(struct os_stream *stream, double value)
-{
- util_stream_writef(stream, "%g", value);
-}
-
-static void
-util_dump_string(struct os_stream *stream, const char *str)
-{
- os_stream_write_str(stream, "\"");
- os_stream_write_str(stream, str);
- os_stream_write_str(stream, "\"");
-}
-
-static void
-util_dump_enum(struct os_stream *stream, const char *value)
-{
- os_stream_write_str(stream, value);
-}
-
-static void
-util_dump_array_begin(struct os_stream *stream)
-{
- os_stream_write_str(stream, "{");
-}
-
-static void
-util_dump_array_end(struct os_stream *stream)
-{
- os_stream_write_str(stream, "}");
-}
-
-static void
-util_dump_elem_begin(struct os_stream *stream)
-{
-}
-
-static void
-util_dump_elem_end(struct os_stream *stream)
-{
- os_stream_write_str(stream, ", ");
-}
-
-static void
-util_dump_struct_begin(struct os_stream *stream, const char *name)
-{
- os_stream_write_str(stream, "{");
-}
-
-static void
-util_dump_struct_end(struct os_stream *stream)
-{
- os_stream_write_str(stream, "}");
-}
-
-static void
-util_dump_member_begin(struct os_stream *stream, const char *name)
-{
- util_stream_writef(stream, "%s = ", name);
-}
-
-static void
-util_dump_member_end(struct os_stream *stream)
-{
- os_stream_write_str(stream, ", ");
-}
-
-static void
-util_dump_null(struct os_stream *stream)
-{
- os_stream_write_str(stream, "NULL");
-}
-
-static void
-util_dump_ptr(struct os_stream *stream, const void *value)
-{
- if(value)
- util_stream_writef(stream, "0x%08lx", (unsigned long)(uintptr_t)value);
- else
- util_dump_null(stream);
-}
-
-
-/*
- * Code saving macros.
- */
-
-#define util_dump_arg(_stream, _type, _arg) \
- do { \
- util_dump_arg_begin(_stream, #_arg); \
- util_dump_##_type(_stream, _arg); \
- util_dump_arg_end(_stream); \
- } while(0)
-
-#define util_dump_ret(_stream, _type, _arg) \
- do { \
- util_dump_ret_begin(_stream); \
- util_dump_##_type(_stream, _arg); \
- util_dump_ret_end(_stream); \
- } while(0)
-
-#define util_dump_array(_stream, _type, _obj, _size) \
- do { \
- size_t idx; \
- util_dump_array_begin(_stream); \
- for(idx = 0; idx < (_size); ++idx) { \
- util_dump_elem_begin(_stream); \
- util_dump_##_type(_stream, (_obj)[idx]); \
- util_dump_elem_end(_stream); \
- } \
- util_dump_array_end(_stream); \
- } while(0)
-
-#define util_dump_struct_array(_stream, _type, _obj, _size) \
- do { \
- size_t idx; \
- util_dump_array_begin(_stream); \
- for(idx = 0; idx < (_size); ++idx) { \
- util_dump_elem_begin(_stream); \
- util_dump_##_type(_stream, &(_obj)[idx]); \
- util_dump_elem_end(_stream); \
- } \
- util_dump_array_end(_stream); \
- } while(0)
-
-#define util_dump_member(_stream, _type, _obj, _member) \
- do { \
- util_dump_member_begin(_stream, #_member); \
- util_dump_##_type(_stream, (_obj)->_member); \
- util_dump_member_end(_stream); \
- } while(0)
-
-#define util_dump_arg_array(_stream, _type, _arg, _size) \
- do { \
- util_dump_arg_begin(_stream, #_arg); \
- util_dump_array(_stream, _type, _arg, _size); \
- util_dump_arg_end(_stream); \
- } while(0)
-
-#define util_dump_member_array(_stream, _type, _obj, _member) \
- do { \
- util_dump_member_begin(_stream, #_member); \
- util_dump_array(_stream, _type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
- util_dump_member_end(_stream); \
- } while(0)
-
-
-
-/*
- * Wrappers for enum -> string dumpers.
- */
-
-
-static void
-util_dump_format(struct os_stream *stream, enum pipe_format format)
-{
- util_dump_enum(stream, util_format_name(format));
-}
-
-
-static void
-util_dump_enum_blend_factor(struct os_stream *stream, unsigned value)
-{
- util_dump_enum(stream, util_dump_blend_factor(value, TRUE));
-}
-
-static void
-util_dump_enum_blend_func(struct os_stream *stream, unsigned value)
-{
- util_dump_enum(stream, util_dump_blend_func(value, TRUE));
-}
-
-static void
-util_dump_enum_func(struct os_stream *stream, unsigned value)
-{
- util_dump_enum(stream, util_dump_func(value, TRUE));
-}
-
-
-/*
- * Public functions
- */
-
-
-void
-util_dump_template(struct os_stream *stream, const struct pipe_resource *templat)
-{
- if(!templat) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_resource");
-
- util_dump_member(stream, int, templat, target);
- util_dump_member(stream, format, templat, format);
-
- util_dump_member_begin(stream, "width");
- util_dump_uint(stream, templat->width0);
- util_dump_member_end(stream);
-
- util_dump_member_begin(stream, "height");
- util_dump_uint(stream, templat->height0);
- util_dump_member_end(stream);
-
- util_dump_member_begin(stream, "depth");
- util_dump_uint(stream, templat->depth0);
- util_dump_member_end(stream);
-
- util_dump_member_begin(stream, "array_size");
- util_dump_uint(stream, templat->array_size);
- util_dump_member_end(stream);
-
- util_dump_member(stream, uint, templat, last_level);
- util_dump_member(stream, uint, templat, usage);
- util_dump_member(stream, uint, templat, bind);
- util_dump_member(stream, uint, templat, flags);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterizer_state *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_rasterizer_state");
-
- util_dump_member(stream, bool, state, flatshade);
- util_dump_member(stream, bool, state, light_twoside);
- util_dump_member(stream, uint, state, front_ccw);
- util_dump_member(stream, uint, state, cull_face);
- util_dump_member(stream, uint, state, fill_front);
- util_dump_member(stream, uint, state, fill_back);
- util_dump_member(stream, bool, state, offset_point);
- util_dump_member(stream, bool, state, offset_line);
- util_dump_member(stream, bool, state, offset_tri);
- util_dump_member(stream, bool, state, scissor);
- util_dump_member(stream, bool, state, poly_smooth);
- util_dump_member(stream, bool, state, poly_stipple_enable);
- util_dump_member(stream, bool, state, point_smooth);
- util_dump_member(stream, uint, state, sprite_coord_enable);
- util_dump_member(stream, bool, state, sprite_coord_mode);
- util_dump_member(stream, bool, state, point_quad_rasterization);
- util_dump_member(stream, bool, state, point_size_per_vertex);
- util_dump_member(stream, bool, state, multisample);
- util_dump_member(stream, bool, state, line_smooth);
- util_dump_member(stream, bool, state, line_stipple_enable);
- util_dump_member(stream, uint, state, line_stipple_factor);
- util_dump_member(stream, uint, state, line_stipple_pattern);
- util_dump_member(stream, bool, state, line_last_pixel);
- util_dump_member(stream, bool, state, flatshade_first);
- util_dump_member(stream, bool, state, gl_rasterization_rules);
-
- util_dump_member(stream, float, state, line_width);
- util_dump_member(stream, float, state, point_size);
- util_dump_member(stream, float, state, offset_units);
- util_dump_member(stream, float, state, offset_scale);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_poly_stipple(struct os_stream *stream, const struct pipe_poly_stipple *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_poly_stipple");
-
- util_dump_member_begin(stream, "stipple");
- util_dump_member_array(stream, uint, state, stipple);
- util_dump_member_end(stream);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_viewport_state(struct os_stream *stream, const struct pipe_viewport_state *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_viewport_state");
-
- util_dump_member_array(stream, float, state, scale);
- util_dump_member_array(stream, float, state, translate);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_scissor_state(struct os_stream *stream, const struct pipe_scissor_state *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_scissor_state");
-
- util_dump_member(stream, uint, state, minx);
- util_dump_member(stream, uint, state, miny);
- util_dump_member(stream, uint, state, maxx);
- util_dump_member(stream, uint, state, maxy);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_clip_state(struct os_stream *stream, const struct pipe_clip_state *state)
-{
- unsigned i;
-
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_clip_state");
-
- util_dump_member_begin(stream, "ucp");
- util_dump_array_begin(stream);
- for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
- util_dump_elem_begin(stream);
- util_dump_array(stream, float, state->ucp[i], 4);
- util_dump_elem_end(stream);
- }
- util_dump_array_end(stream);
- util_dump_member_end(stream);
-
- util_dump_member(stream, uint, state, nr);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_shader_state(struct os_stream *stream, const struct pipe_shader_state *state)
-{
- char str[8192];
-
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- tgsi_dump_str(state->tokens, 0, str, sizeof(str));
-
- util_dump_struct_begin(stream, "pipe_shader_state");
-
- util_dump_member_begin(stream, "tokens");
- util_dump_string(stream, str);
- util_dump_member_end(stream);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_depth_stencil_alpha_state(struct os_stream *stream, const struct pipe_depth_stencil_alpha_state *state)
-{
- unsigned i;
-
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_depth_stencil_alpha_state");
-
- util_dump_member_begin(stream, "depth");
- util_dump_struct_begin(stream, "pipe_depth_state");
- util_dump_member(stream, bool, &state->depth, enabled);
- if (state->depth.enabled) {
- util_dump_member(stream, bool, &state->depth, writemask);
- util_dump_member(stream, enum_func, &state->depth, func);
- }
- util_dump_struct_end(stream);
- util_dump_member_end(stream);
-
- util_dump_member_begin(stream, "stencil");
- util_dump_array_begin(stream);
- for(i = 0; i < Elements(state->stencil); ++i) {
- util_dump_elem_begin(stream);
- util_dump_struct_begin(stream, "pipe_stencil_state");
- util_dump_member(stream, bool, &state->stencil[i], enabled);
- if (state->stencil[i].enabled) {
- util_dump_member(stream, enum_func, &state->stencil[i], func);
- util_dump_member(stream, uint, &state->stencil[i], fail_op);
- util_dump_member(stream, uint, &state->stencil[i], zpass_op);
- util_dump_member(stream, uint, &state->stencil[i], zfail_op);
- util_dump_member(stream, uint, &state->stencil[i], valuemask);
- util_dump_member(stream, uint, &state->stencil[i], writemask);
- }
- util_dump_struct_end(stream);
- util_dump_elem_end(stream);
- }
- util_dump_array_end(stream);
- util_dump_member_end(stream);
-
- util_dump_member_begin(stream, "alpha");
- util_dump_struct_begin(stream, "pipe_alpha_state");
- util_dump_member(stream, bool, &state->alpha, enabled);
- if (state->alpha.enabled) {
- util_dump_member(stream, enum_func, &state->alpha, func);
- util_dump_member(stream, float, &state->alpha, ref_value);
- }
- util_dump_struct_end(stream);
- util_dump_member_end(stream);
-
- util_dump_struct_end(stream);
-}
-
-void
-util_dump_rt_blend_state(struct os_stream *stream, const struct pipe_rt_blend_state *state)
-{
- util_dump_struct_begin(stream, "pipe_rt_blend_state");
-
- util_dump_member(stream, uint, state, blend_enable);
- if (state->blend_enable) {
- util_dump_member(stream, enum_blend_func, state, rgb_func);
- util_dump_member(stream, enum_blend_factor, state, rgb_src_factor);
- util_dump_member(stream, enum_blend_factor, state, rgb_dst_factor);
-
- util_dump_member(stream, enum_blend_func, state, alpha_func);
- util_dump_member(stream, enum_blend_factor, state, alpha_src_factor);
- util_dump_member(stream, enum_blend_factor, state, alpha_dst_factor);
- }
-
- util_dump_member(stream, uint, state, colormask);
-
- util_dump_struct_end(stream);
-}
-
-void
-util_dump_blend_state(struct os_stream *stream, const struct pipe_blend_state *state)
-{
- unsigned valid_entries = 1;
-
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_blend_state");
-
- util_dump_member(stream, bool, state, dither);
-
- util_dump_member(stream, bool, state, logicop_enable);
- if (state->logicop_enable) {
- util_dump_member(stream, enum_func, state, logicop_func);
- }
- else {
- util_dump_member(stream, bool, state, independent_blend_enable);
-
- util_dump_member_begin(stream, "rt");
- if (state->independent_blend_enable)
- valid_entries = PIPE_MAX_COLOR_BUFS;
- util_dump_struct_array(stream, rt_blend_state, state->rt, valid_entries);
- util_dump_member_end(stream);
- }
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_blend_color(struct os_stream *stream, const struct pipe_blend_color *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_blend_color");
-
- util_dump_member_array(stream, float, state, color);
-
- util_dump_struct_end(stream);
-}
-
-void
-util_dump_stencil_ref(struct os_stream *stream, const struct pipe_stencil_ref *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_stencil_ref");
-
- util_dump_member_array(stream, uint, state, ref_value);
-
- util_dump_struct_end(stream);
-}
-
-void
-util_dump_framebuffer_state(struct os_stream *stream, const struct pipe_framebuffer_state *state)
-{
- util_dump_struct_begin(stream, "pipe_framebuffer_state");
-
- util_dump_member(stream, uint, state, width);
- util_dump_member(stream, uint, state, height);
- util_dump_member(stream, uint, state, nr_cbufs);
- util_dump_member_array(stream, ptr, state, cbufs);
- util_dump_member(stream, ptr, state, zsbuf);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_sampler_state(struct os_stream *stream, const struct pipe_sampler_state *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_sampler_state");
-
- util_dump_member(stream, uint, state, wrap_s);
- util_dump_member(stream, uint, state, wrap_t);
- util_dump_member(stream, uint, state, wrap_r);
- util_dump_member(stream, uint, state, min_img_filter);
- util_dump_member(stream, uint, state, min_mip_filter);
- util_dump_member(stream, uint, state, mag_img_filter);
- util_dump_member(stream, uint, state, compare_mode);
- util_dump_member(stream, enum_func, state, compare_func);
- util_dump_member(stream, bool, state, normalized_coords);
- util_dump_member(stream, uint, state, max_anisotropy);
- util_dump_member(stream, float, state, lod_bias);
- util_dump_member(stream, float, state, min_lod);
- util_dump_member(stream, float, state, max_lod);
- util_dump_member_array(stream, float, state, border_color);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_surface(struct os_stream *stream, const struct pipe_surface *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_surface");
-
- util_dump_member(stream, format, state, format);
- util_dump_member(stream, uint, state, width);
- util_dump_member(stream, uint, state, height);
-
- util_dump_member(stream, uint, state, usage);
-
- util_dump_member(stream, ptr, state, texture);
- util_dump_member(stream, uint, state, u.tex.level);
- util_dump_member(stream, uint, state, u.tex.first_layer);
- util_dump_member(stream, uint, state, u.tex.last_layer);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_transfer");
-
- util_dump_member(stream, ptr, state, resource);
- /*util_dump_member(stream, uint, state, box);*/
-
- util_dump_member(stream, uint, state, stride);
- util_dump_member(stream, uint, state, layer_stride);
-
- /*util_dump_member(stream, ptr, state, data);*/
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_vertex_buffer(struct os_stream *stream, const struct pipe_vertex_buffer *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_vertex_buffer");
-
- util_dump_member(stream, uint, state, stride);
- util_dump_member(stream, uint, state, buffer_offset);
- util_dump_member(stream, ptr, state, buffer);
-
- util_dump_struct_end(stream);
-}
-
-
-void
-util_dump_vertex_element(struct os_stream *stream, const struct pipe_vertex_element *state)
-{
- if(!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_vertex_element");
-
- util_dump_member(stream, uint, state, src_offset);
-
- util_dump_member(stream, uint, state, vertex_buffer_index);
-
- util_dump_member(stream, format, state, src_format);
-
- util_dump_struct_end(stream);
-}
+/************************************************************************** + * + * Copyright 2008-2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "pipe/p_compiler.h" +#include "os/os_stream.h" +#include "util/u_memory.h" +#include "util/u_string.h" +#include "util/u_format.h" +#include "tgsi/tgsi_dump.h" + +#include "u_dump.h" + + +/* + * Dump primitives + */ + +static INLINE void +util_stream_writef(struct os_stream *stream, const char *format, ...) +{ + static char buf[1024]; + unsigned len; + va_list ap; + va_start(ap, format); + len = util_vsnprintf(buf, sizeof(buf), format, ap); + va_end(ap); + os_stream_write(stream, buf, len); +} + +static void +util_dump_bool(struct os_stream *stream, int value) +{ + util_stream_writef(stream, "%c", value ? '1' : '0'); +} + +static void +util_dump_int(struct os_stream *stream, long long int value) +{ + util_stream_writef(stream, "%lli", value); +} + +static void +util_dump_uint(struct os_stream *stream, long long unsigned value) +{ + util_stream_writef(stream, "%llu", value); +} + +static void +util_dump_float(struct os_stream *stream, double value) +{ + util_stream_writef(stream, "%g", value); +} + +static void +util_dump_string(struct os_stream *stream, const char *str) +{ + os_stream_write_str(stream, "\""); + os_stream_write_str(stream, str); + os_stream_write_str(stream, "\""); +} + +static void +util_dump_enum(struct os_stream *stream, const char *value) +{ + os_stream_write_str(stream, value); +} + +static void +util_dump_array_begin(struct os_stream *stream) +{ + os_stream_write_str(stream, "{"); +} + +static void +util_dump_array_end(struct os_stream *stream) +{ + os_stream_write_str(stream, "}"); +} + +static void +util_dump_elem_begin(struct os_stream *stream) +{ +} + +static void +util_dump_elem_end(struct os_stream *stream) +{ + os_stream_write_str(stream, ", "); +} + +static void +util_dump_struct_begin(struct os_stream *stream, const char *name) +{ + os_stream_write_str(stream, "{"); +} + +static void +util_dump_struct_end(struct os_stream *stream) +{ + os_stream_write_str(stream, "}"); +} + +static void +util_dump_member_begin(struct os_stream *stream, const char *name) +{ + util_stream_writef(stream, "%s = ", name); +} + +static void +util_dump_member_end(struct os_stream *stream) +{ + os_stream_write_str(stream, ", "); +} + +static void +util_dump_null(struct os_stream *stream) +{ + os_stream_write_str(stream, "NULL"); +} + +static void +util_dump_ptr(struct os_stream *stream, const void *value) +{ + if(value) + util_stream_writef(stream, "0x%08lx", (unsigned long)(uintptr_t)value); + else + util_dump_null(stream); +} + + +/* + * Code saving macros. + */ + +#define util_dump_arg(_stream, _type, _arg) \ + do { \ + util_dump_arg_begin(_stream, #_arg); \ + util_dump_##_type(_stream, _arg); \ + util_dump_arg_end(_stream); \ + } while(0) + +#define util_dump_ret(_stream, _type, _arg) \ + do { \ + util_dump_ret_begin(_stream); \ + util_dump_##_type(_stream, _arg); \ + util_dump_ret_end(_stream); \ + } while(0) + +#define util_dump_array(_stream, _type, _obj, _size) \ + do { \ + size_t idx; \ + util_dump_array_begin(_stream); \ + for(idx = 0; idx < (_size); ++idx) { \ + util_dump_elem_begin(_stream); \ + util_dump_##_type(_stream, (_obj)[idx]); \ + util_dump_elem_end(_stream); \ + } \ + util_dump_array_end(_stream); \ + } while(0) + +#define util_dump_struct_array(_stream, _type, _obj, _size) \ + do { \ + size_t idx; \ + util_dump_array_begin(_stream); \ + for(idx = 0; idx < (_size); ++idx) { \ + util_dump_elem_begin(_stream); \ + util_dump_##_type(_stream, &(_obj)[idx]); \ + util_dump_elem_end(_stream); \ + } \ + util_dump_array_end(_stream); \ + } while(0) + +#define util_dump_member(_stream, _type, _obj, _member) \ + do { \ + util_dump_member_begin(_stream, #_member); \ + util_dump_##_type(_stream, (_obj)->_member); \ + util_dump_member_end(_stream); \ + } while(0) + +#define util_dump_arg_array(_stream, _type, _arg, _size) \ + do { \ + util_dump_arg_begin(_stream, #_arg); \ + util_dump_array(_stream, _type, _arg, _size); \ + util_dump_arg_end(_stream); \ + } while(0) + +#define util_dump_member_array(_stream, _type, _obj, _member) \ + do { \ + util_dump_member_begin(_stream, #_member); \ + util_dump_array(_stream, _type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \ + util_dump_member_end(_stream); \ + } while(0) + + + +/* + * Wrappers for enum -> string dumpers. + */ + + +static void +util_dump_format(struct os_stream *stream, enum pipe_format format) +{ + util_dump_enum(stream, util_format_name(format)); +} + + +static void +util_dump_enum_blend_factor(struct os_stream *stream, unsigned value) +{ + util_dump_enum(stream, util_dump_blend_factor(value, TRUE)); +} + +static void +util_dump_enum_blend_func(struct os_stream *stream, unsigned value) +{ + util_dump_enum(stream, util_dump_blend_func(value, TRUE)); +} + +static void +util_dump_enum_func(struct os_stream *stream, unsigned value) +{ + util_dump_enum(stream, util_dump_func(value, TRUE)); +} + + +/* + * Public functions + */ + + +void +util_dump_template(struct os_stream *stream, const struct pipe_resource *templat) +{ + if(!templat) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_resource"); + + util_dump_member(stream, int, templat, target); + util_dump_member(stream, format, templat, format); + + util_dump_member_begin(stream, "width"); + util_dump_uint(stream, templat->width0); + util_dump_member_end(stream); + + util_dump_member_begin(stream, "height"); + util_dump_uint(stream, templat->height0); + util_dump_member_end(stream); + + util_dump_member_begin(stream, "depth"); + util_dump_uint(stream, templat->depth0); + util_dump_member_end(stream); + + util_dump_member_begin(stream, "array_size"); + util_dump_uint(stream, templat->array_size); + util_dump_member_end(stream); + + util_dump_member(stream, uint, templat, last_level); + util_dump_member(stream, uint, templat, usage); + util_dump_member(stream, uint, templat, bind); + util_dump_member(stream, uint, templat, flags); + + util_dump_struct_end(stream); +} + + +void +util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterizer_state *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_rasterizer_state"); + + util_dump_member(stream, bool, state, flatshade); + util_dump_member(stream, bool, state, light_twoside); + util_dump_member(stream, uint, state, front_ccw); + util_dump_member(stream, uint, state, cull_face); + util_dump_member(stream, uint, state, fill_front); + util_dump_member(stream, uint, state, fill_back); + util_dump_member(stream, bool, state, offset_point); + util_dump_member(stream, bool, state, offset_line); + util_dump_member(stream, bool, state, offset_tri); + util_dump_member(stream, bool, state, scissor); + util_dump_member(stream, bool, state, poly_smooth); + util_dump_member(stream, bool, state, poly_stipple_enable); + util_dump_member(stream, bool, state, point_smooth); + util_dump_member(stream, uint, state, sprite_coord_enable); + util_dump_member(stream, bool, state, sprite_coord_mode); + util_dump_member(stream, bool, state, point_quad_rasterization); + util_dump_member(stream, bool, state, point_size_per_vertex); + util_dump_member(stream, bool, state, multisample); + util_dump_member(stream, bool, state, line_smooth); + util_dump_member(stream, bool, state, line_stipple_enable); + util_dump_member(stream, uint, state, line_stipple_factor); + util_dump_member(stream, uint, state, line_stipple_pattern); + util_dump_member(stream, bool, state, line_last_pixel); + util_dump_member(stream, bool, state, flatshade_first); + util_dump_member(stream, bool, state, gl_rasterization_rules); + + util_dump_member(stream, float, state, line_width); + util_dump_member(stream, float, state, point_size); + util_dump_member(stream, float, state, offset_units); + util_dump_member(stream, float, state, offset_scale); + + util_dump_struct_end(stream); +} + + +void +util_dump_poly_stipple(struct os_stream *stream, const struct pipe_poly_stipple *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_poly_stipple"); + + util_dump_member_begin(stream, "stipple"); + util_dump_member_array(stream, uint, state, stipple); + util_dump_member_end(stream); + + util_dump_struct_end(stream); +} + + +void +util_dump_viewport_state(struct os_stream *stream, const struct pipe_viewport_state *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_viewport_state"); + + util_dump_member_array(stream, float, state, scale); + util_dump_member_array(stream, float, state, translate); + + util_dump_struct_end(stream); +} + + +void +util_dump_scissor_state(struct os_stream *stream, const struct pipe_scissor_state *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_scissor_state"); + + util_dump_member(stream, uint, state, minx); + util_dump_member(stream, uint, state, miny); + util_dump_member(stream, uint, state, maxx); + util_dump_member(stream, uint, state, maxy); + + util_dump_struct_end(stream); +} + + +void +util_dump_clip_state(struct os_stream *stream, const struct pipe_clip_state *state) +{ + unsigned i; + + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_clip_state"); + + util_dump_member_begin(stream, "ucp"); + util_dump_array_begin(stream); + for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) { + util_dump_elem_begin(stream); + util_dump_array(stream, float, state->ucp[i], 4); + util_dump_elem_end(stream); + } + util_dump_array_end(stream); + util_dump_member_end(stream); + + util_dump_member(stream, uint, state, nr); + + util_dump_struct_end(stream); +} + + +void +util_dump_shader_state(struct os_stream *stream, const struct pipe_shader_state *state) +{ + char str[8192]; + + if(!state) { + util_dump_null(stream); + return; + } + + tgsi_dump_str(state->tokens, 0, str, sizeof(str)); + + util_dump_struct_begin(stream, "pipe_shader_state"); + + util_dump_member_begin(stream, "tokens"); + util_dump_string(stream, str); + util_dump_member_end(stream); + + util_dump_struct_end(stream); +} + + +void +util_dump_depth_stencil_alpha_state(struct os_stream *stream, const struct pipe_depth_stencil_alpha_state *state) +{ + unsigned i; + + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_depth_stencil_alpha_state"); + + util_dump_member_begin(stream, "depth"); + util_dump_struct_begin(stream, "pipe_depth_state"); + util_dump_member(stream, bool, &state->depth, enabled); + if (state->depth.enabled) { + util_dump_member(stream, bool, &state->depth, writemask); + util_dump_member(stream, enum_func, &state->depth, func); + } + util_dump_struct_end(stream); + util_dump_member_end(stream); + + util_dump_member_begin(stream, "stencil"); + util_dump_array_begin(stream); + for(i = 0; i < Elements(state->stencil); ++i) { + util_dump_elem_begin(stream); + util_dump_struct_begin(stream, "pipe_stencil_state"); + util_dump_member(stream, bool, &state->stencil[i], enabled); + if (state->stencil[i].enabled) { + util_dump_member(stream, enum_func, &state->stencil[i], func); + util_dump_member(stream, uint, &state->stencil[i], fail_op); + util_dump_member(stream, uint, &state->stencil[i], zpass_op); + util_dump_member(stream, uint, &state->stencil[i], zfail_op); + util_dump_member(stream, uint, &state->stencil[i], valuemask); + util_dump_member(stream, uint, &state->stencil[i], writemask); + } + util_dump_struct_end(stream); + util_dump_elem_end(stream); + } + util_dump_array_end(stream); + util_dump_member_end(stream); + + util_dump_member_begin(stream, "alpha"); + util_dump_struct_begin(stream, "pipe_alpha_state"); + util_dump_member(stream, bool, &state->alpha, enabled); + if (state->alpha.enabled) { + util_dump_member(stream, enum_func, &state->alpha, func); + util_dump_member(stream, float, &state->alpha, ref_value); + } + util_dump_struct_end(stream); + util_dump_member_end(stream); + + util_dump_struct_end(stream); +} + +void +util_dump_rt_blend_state(struct os_stream *stream, const struct pipe_rt_blend_state *state) +{ + util_dump_struct_begin(stream, "pipe_rt_blend_state"); + + util_dump_member(stream, uint, state, blend_enable); + if (state->blend_enable) { + util_dump_member(stream, enum_blend_func, state, rgb_func); + util_dump_member(stream, enum_blend_factor, state, rgb_src_factor); + util_dump_member(stream, enum_blend_factor, state, rgb_dst_factor); + + util_dump_member(stream, enum_blend_func, state, alpha_func); + util_dump_member(stream, enum_blend_factor, state, alpha_src_factor); + util_dump_member(stream, enum_blend_factor, state, alpha_dst_factor); + } + + util_dump_member(stream, uint, state, colormask); + + util_dump_struct_end(stream); +} + +void +util_dump_blend_state(struct os_stream *stream, const struct pipe_blend_state *state) +{ + unsigned valid_entries = 1; + + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_blend_state"); + + util_dump_member(stream, bool, state, dither); + + util_dump_member(stream, bool, state, logicop_enable); + if (state->logicop_enable) { + util_dump_member(stream, enum_func, state, logicop_func); + } + else { + util_dump_member(stream, bool, state, independent_blend_enable); + + util_dump_member_begin(stream, "rt"); + if (state->independent_blend_enable) + valid_entries = PIPE_MAX_COLOR_BUFS; + util_dump_struct_array(stream, rt_blend_state, state->rt, valid_entries); + util_dump_member_end(stream); + } + + util_dump_struct_end(stream); +} + + +void +util_dump_blend_color(struct os_stream *stream, const struct pipe_blend_color *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_blend_color"); + + util_dump_member_array(stream, float, state, color); + + util_dump_struct_end(stream); +} + +void +util_dump_stencil_ref(struct os_stream *stream, const struct pipe_stencil_ref *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_stencil_ref"); + + util_dump_member_array(stream, uint, state, ref_value); + + util_dump_struct_end(stream); +} + +void +util_dump_framebuffer_state(struct os_stream *stream, const struct pipe_framebuffer_state *state) +{ + util_dump_struct_begin(stream, "pipe_framebuffer_state"); + + util_dump_member(stream, uint, state, width); + util_dump_member(stream, uint, state, height); + util_dump_member(stream, uint, state, nr_cbufs); + util_dump_member_array(stream, ptr, state, cbufs); + util_dump_member(stream, ptr, state, zsbuf); + + util_dump_struct_end(stream); +} + + +void +util_dump_sampler_state(struct os_stream *stream, const struct pipe_sampler_state *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_sampler_state"); + + util_dump_member(stream, uint, state, wrap_s); + util_dump_member(stream, uint, state, wrap_t); + util_dump_member(stream, uint, state, wrap_r); + util_dump_member(stream, uint, state, min_img_filter); + util_dump_member(stream, uint, state, min_mip_filter); + util_dump_member(stream, uint, state, mag_img_filter); + util_dump_member(stream, uint, state, compare_mode); + util_dump_member(stream, enum_func, state, compare_func); + util_dump_member(stream, bool, state, normalized_coords); + util_dump_member(stream, uint, state, max_anisotropy); + util_dump_member(stream, float, state, lod_bias); + util_dump_member(stream, float, state, min_lod); + util_dump_member(stream, float, state, max_lod); + util_dump_member_array(stream, float, state, border_color.f); + + util_dump_struct_end(stream); +} + + +void +util_dump_surface(struct os_stream *stream, const struct pipe_surface *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_surface"); + + util_dump_member(stream, format, state, format); + util_dump_member(stream, uint, state, width); + util_dump_member(stream, uint, state, height); + + util_dump_member(stream, uint, state, usage); + + util_dump_member(stream, ptr, state, texture); + util_dump_member(stream, uint, state, u.tex.level); + util_dump_member(stream, uint, state, u.tex.first_layer); + util_dump_member(stream, uint, state, u.tex.last_layer); + + util_dump_struct_end(stream); +} + + +void +util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_transfer"); + + util_dump_member(stream, ptr, state, resource); + /*util_dump_member(stream, uint, state, box);*/ + + util_dump_member(stream, uint, state, stride); + util_dump_member(stream, uint, state, layer_stride); + + /*util_dump_member(stream, ptr, state, data);*/ + + util_dump_struct_end(stream); +} + + +void +util_dump_vertex_buffer(struct os_stream *stream, const struct pipe_vertex_buffer *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_vertex_buffer"); + + util_dump_member(stream, uint, state, stride); + util_dump_member(stream, uint, state, buffer_offset); + util_dump_member(stream, ptr, state, buffer); + + util_dump_struct_end(stream); +} + + +void +util_dump_vertex_element(struct os_stream *stream, const struct pipe_vertex_element *state) +{ + if(!state) { + util_dump_null(stream); + return; + } + + util_dump_struct_begin(stream, "pipe_vertex_element"); + + util_dump_member(stream, uint, state, src_offset); + + util_dump_member(stream, uint, state, vertex_buffer_index); + + util_dump_member(stream, format, state, src_format); + + util_dump_struct_end(stream); +} diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index 23b6a9480..689dc8a99 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -304,7 +304,10 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) case GL_CLIP_DISTANCE6: case GL_CLIP_DISTANCE7: { - const GLuint p = cap - GL_CLIP_PLANE0; + const GLuint p = cap - GL_CLIP_DISTANCE0; + + if (p >= ctx->Const.MaxClipPlanes) + goto invalid_enum_error; if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) @@ -1084,13 +1087,21 @@ _mesa_IsEnabled( GLenum cap ) return ctx->Eval.AutoNormal; case GL_BLEND: return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: - return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; + case GL_CLIP_DISTANCE0: + case GL_CLIP_DISTANCE1: + case GL_CLIP_DISTANCE2: + case GL_CLIP_DISTANCE3: + case GL_CLIP_DISTANCE4: + case GL_CLIP_DISTANCE5: + case GL_CLIP_DISTANCE6: + case GL_CLIP_DISTANCE7: { + const GLuint p = cap - GL_CLIP_DISTANCE0; + + if (p >= ctx->Const.MaxClipPlanes) + goto invalid_enum_error; + + return (ctx->Transform.ClipPlanesEnabled >> p) & 1; + } case GL_COLOR_MATERIAL: return ctx->Light.ColorMaterialEnabled; case GL_CULL_FACE: diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 99ce567cc..cddea8ea2 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -102,6 +102,8 @@ enum value_type { TYPE_BIT_3, TYPE_BIT_4, TYPE_BIT_5, + TYPE_BIT_6, + TYPE_BIT_7, TYPE_FLOAT, TYPE_FLOAT_2, TYPE_FLOAT_3, @@ -134,6 +136,7 @@ enum value_extra { EXTRA_NEW_FRAG_CLAMP, EXTRA_VALID_DRAW_BUFFER, EXTRA_VALID_TEXTURE_UNIT, + EXTRA_VALID_CLIP_DISTANCE, EXTRA_FLUSH_CURRENT, }; @@ -189,6 +192,8 @@ union value { #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) +#define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6) +#define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7) #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) @@ -239,6 +244,11 @@ static const int extra_valid_texture_unit[] = { EXTRA_END }; +static const int extra_valid_clip_distance[] = { + EXTRA_VALID_CLIP_DISTANCE, + EXTRA_END +}; + static const int extra_flush_current_valid_texture_unit[] = { EXTRA_FLUSH_CURRENT, EXTRA_VALID_TEXTURE_UNIT, @@ -515,12 +525,14 @@ static const struct value_desc values[] = { { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA }, { GL_ALPHA_TEST_REF, LOC_CUSTOM, TYPE_FLOATN, 0, extra_new_frag_clamp }, { GL_BLEND_DST, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA }, - { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), NO_EXTRA }, + { GL_CLIP_DISTANCE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, + { GL_CLIP_DISTANCE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, + { GL_CLIP_DISTANCE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, + { GL_CLIP_DISTANCE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, + { GL_CLIP_DISTANCE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, + { GL_CLIP_DISTANCE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, + { GL_CLIP_DISTANCE6, CONTEXT_BIT6(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, + { GL_CLIP_DISTANCE7, CONTEXT_BIT7(Transform.ClipPlanesEnabled), extra_valid_clip_distance }, { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA }, { GL_CURRENT_COLOR, CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4), @@ -1798,6 +1810,13 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d return GL_FALSE; } break; + case EXTRA_VALID_CLIP_DISTANCE: + if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)", + func, d->pname - GL_CLIP_DISTANCE0); + return GL_FALSE; + } + break; case EXTRA_END: break; default: /* *e is a offset into the extension struct */ @@ -1986,6 +2005,8 @@ _mesa_GetBooleanv(GLenum pname, GLboolean *params) case TYPE_BIT_3: case TYPE_BIT_4: case TYPE_BIT_5: + case TYPE_BIT_6: + case TYPE_BIT_7: shift = d->type - TYPE_BIT_0; params[0] = (*(GLbitfield *) p >> shift) & 1; break; @@ -2073,6 +2094,8 @@ _mesa_GetFloatv(GLenum pname, GLfloat *params) case TYPE_BIT_3: case TYPE_BIT_4: case TYPE_BIT_5: + case TYPE_BIT_6: + case TYPE_BIT_7: shift = d->type - TYPE_BIT_0; params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); break; @@ -2166,6 +2189,8 @@ _mesa_GetIntegerv(GLenum pname, GLint *params) case TYPE_BIT_3: case TYPE_BIT_4: case TYPE_BIT_5: + case TYPE_BIT_6: + case TYPE_BIT_7: shift = d->type - TYPE_BIT_0; params[0] = (*(GLbitfield *) p >> shift) & 1; break; @@ -2260,6 +2285,8 @@ _mesa_GetInteger64v(GLenum pname, GLint64 *params) case TYPE_BIT_3: case TYPE_BIT_4: case TYPE_BIT_5: + case TYPE_BIT_6: + case TYPE_BIT_7: shift = d->type - TYPE_BIT_0; params[0] = (*(GLbitfield *) p >> shift) & 1; break; @@ -2348,6 +2375,8 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params) case TYPE_BIT_3: case TYPE_BIT_4: case TYPE_BIT_5: + case TYPE_BIT_6: + case TYPE_BIT_7: shift = d->type - TYPE_BIT_0; params[0] = (*(GLbitfield *) p >> shift) & 1; break; @@ -2618,6 +2647,8 @@ _mesa_GetFixedv(GLenum pname, GLfixed *params) case TYPE_BIT_3: case TYPE_BIT_4: case TYPE_BIT_5: + case TYPE_BIT_6: + case TYPE_BIT_7: shift = d->type - TYPE_BIT_0; params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); break; diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 2830dda86..d2f25b9f8 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -71,14 +71,13 @@ type_with_negative_values(GLenum type) static void get_tex_depth(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) + struct gl_texture_image *texImage) { const GLint width = texImage->Width; const GLint height = texImage->Height; const GLint depth = texImage->Depth; GLint img, row; GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat)); - const GLint texelSize = _mesa_get_format_bytes(texImage->TexFormat); if (!depthRow) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); @@ -86,18 +85,24 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions, } for (img = 0; img < depth; img++) { + GLubyte *srcMap; + GLint srcRowStride; + + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, img, + 0, 0, width, height, GL_MAP_READ_BIT, + &srcMap, &srcRowStride); + for (row = 0; row < height; row++) { void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); - const GLubyte *src = (GLubyte *) texImage->Data + - (texImage->ImageOffsets[img] + - texImage->RowStride * row) * texelSize; - + const GLubyte *src = srcMap + row * srcRowStride; _mesa_unpack_float_z_row(texImage->TexFormat, width, src, depthRow); - _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); } + + ctx->Driver.UnmapTextureImage(ctx, texImage, img); } free(depthRow); @@ -110,27 +115,35 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions, static void get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) + struct gl_texture_image *texImage) { const GLint width = texImage->Width; const GLint height = texImage->Height; const GLint depth = texImage->Depth; - const GLint rowstride = texImage->RowStride; - const GLuint *src = (const GLuint *) texImage->Data; GLint img, row; for (img = 0; img < depth; img++) { + GLubyte *srcMap; + GLint rowstride; + + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, img, + 0, 0, width, height, GL_MAP_READ_BIT, + &srcMap, &rowstride); + for (row = 0; row < height; row++) { + const GLubyte *src = srcMap + row * rowstride; void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); + /* XXX Z24_S8 vs. S8_Z24??? */ memcpy(dest, src, width * sizeof(GLuint)); if (ctx->Pack.SwapBytes) { _mesa_swap4((GLuint *) dest, width); } - - src += rowstride; } + + ctx->Driver.UnmapTextureImage(ctx, texImage, img); } } @@ -141,17 +154,24 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, static void get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) + struct gl_texture_image *texImage) { const GLint width = texImage->Width; const GLint height = texImage->Height; const GLint depth = texImage->Depth; - const GLint rowstride = texImage->RowStride; - const GLushort *src = (const GLushort *) texImage->Data; GLint img, row; for (img = 0; img < depth; img++) { + GLubyte *srcMap; + GLint rowstride; + + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, img, + 0, 0, width, height, GL_MAP_READ_BIT, + &srcMap, &rowstride); + for (row = 0; row < height; row++) { + const GLubyte *src = srcMap + row * rowstride; void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); @@ -168,9 +188,9 @@ get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, else if (ctx->Pack.SwapBytes) { _mesa_swap2((GLushort *) dest, width); } - - src += rowstride; } + + ctx->Driver.UnmapTextureImage(ctx, texImage, img); } } @@ -221,8 +241,32 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, return; } - _mesa_decompress_image(texFormat, texImage->Width, texImage->Height, - texImage->Data, texImage->RowStride, tempImage); + /* Decompress the texture image - results in 'tempImage' */ + { + GLubyte *srcMap; + GLint srcRowStride; + GLuint bytes, bw, bh; + + bytes = _mesa_get_format_bytes(texImage->TexFormat); + _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); + + ctx->Driver.MapTextureImage(ctx, texImage, 0, + 0, 0, width, height, + GL_MAP_READ_BIT, + &srcMap, &srcRowStride); + + /* XXX This line is a bit of a hack to work around the + * mismatch of compressed row strides as returned by + * MapTextureImage() vs. what the texture decompression code + * uses. This will be fixed in the future. + */ + srcRowStride = srcRowStride * bh / bytes; + + _mesa_decompress_image(texFormat, width, height, + srcMap, srcRowStride, tempImage); + + ctx->Driver.UnmapTextureImage(ctx, texImage, 0); + } if (baseFormat == GL_LUMINANCE || baseFormat == GL_LUMINANCE_ALPHA) { @@ -250,7 +294,6 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, } else { /* No decompression needed */ - const GLint texelSize = _mesa_get_format_bytes(texFormat); GLuint img, row; GLfloat (*rgba)[4]; @@ -261,13 +304,19 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, } for (img = 0; img < depth; img++) { + GLubyte *srcMap; + GLint rowstride; + + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, img, + 0, 0, width, height, GL_MAP_READ_BIT, + &srcMap, &rowstride); + for (row = 0; row < height; row++) { + const GLubyte *src = srcMap + row * rowstride; void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); - const GLubyte *src = (const GLubyte *) texImage->Data + - (texImage->ImageOffsets[img] + - texImage->RowStride * row) * texelSize; _mesa_unpack_rgba_row(texFormat, width, src, rgba); @@ -307,6 +356,9 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, format, type, dest, &ctx->Pack, transferOps); } + + /* Unmap the src texture buffer */ + ctx->Driver.UnmapTextureImage(ctx, texImage, img); } free(rgba); @@ -319,15 +371,13 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, * \return GL_TRUE if done, GL_FALSE otherwise */ static GLboolean -get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage) +get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, + GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { GLboolean memCopy = GL_FALSE; - /* Texture image should have been mapped already */ - assert(texImage->Data); - /* * Check if the src/dst formats are compatible. * Also note that GL's pixel transfer ops don't apply to glGetTexImage() @@ -386,20 +436,28 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixel texImage->Height, format, type, 0, 0); const GLint dstRowStride = _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type); - const GLubyte *src = texImage->Data; - const GLint srcRowStride = texImage->RowStride * bpp; - GLuint row; + GLubyte *src; + GLint srcRowStride; + + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, 0, + 0, 0, texImage->Width, texImage->Height, + GL_MAP_READ_BIT, &src, &srcRowStride); if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) { memcpy(dst, src, bytesPerRow * texImage->Height); } else { + GLuint row; for (row = 0; row < texImage->Height; row++) { memcpy(dst, src, bytesPerRow); dst += dstRowStride; src += srcRowStride; } } + + /* unmap src texture buffer */ + ctx->Driver.UnmapTextureImage(ctx, texImage, 0); } return memCopy; @@ -409,7 +467,8 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixel /** * This is the software fallback for Driver.GetTexImage(). * All error checking will have been done before this routine is called. - * The texture image must be mapped. + * We'll call ctx->Driver.MapTextureImage() to access the data, then + * unmap with ctx->Driver.UnmapTextureImage(). */ void _mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, @@ -419,9 +478,6 @@ _mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, { GLuint dimensions; - /* If we get here, the texture image should be mapped */ - assert(texImage->Data); - switch (target) { case GL_TEXTURE_1D: dimensions = 1; @@ -433,6 +489,7 @@ _mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, dimensions = 2; } + /* map dest buffer, if PBO */ if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Packing texture image into a PBO. * Map the (potentially) VRAM-based buffer into our process space so @@ -487,11 +544,11 @@ _mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - const GLuint row_stride = _mesa_format_row_stride(texImage->TexFormat, - texImage->Width); - const GLuint row_stride_stored = _mesa_format_row_stride(texImage->TexFormat, - texImage->RowStride); + const GLuint row_stride = + _mesa_format_row_stride(texImage->TexFormat, texImage->Width); GLuint i; + GLubyte *src; + GLint srcRowStride; if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack texture image into a PBO */ @@ -507,25 +564,32 @@ _mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level img = ADD_POINTERS(buf, img); } + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, 0, + 0, 0, texImage->Width, texImage->Height, + GL_MAP_READ_BIT, &src, &srcRowStride); + /* no pixelstore or pixel transfer, but respect stride */ - if (row_stride == row_stride_stored) { + if (row_stride == srcRowStride) { const GLuint size = _mesa_format_image_size(texImage->TexFormat, texImage->Width, texImage->Height, texImage->Depth); - memcpy(img, texImage->Data, size); + memcpy(img, src, size); } else { GLuint bw, bh; _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) { memcpy((GLubyte *)img + i * row_stride, - (GLubyte *)texImage->Data + i * row_stride_stored, + (GLubyte *)src + i * srcRowStride, row_stride); } } + ctx->Driver.UnmapTextureImage(ctx, texImage, 0); + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj); } diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index b2d507786..3b5a78d1b 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -27,7 +27,29 @@ #include "version.h" /*#include "git_sha1.h"*/ +/** + * Override the context's GL version if the environment variable + * MESA_GL_VERSION_OVERRIDE is set. Valid values of MESA_GL_VERSION_OVERRIDE + * are point-separated version numbers, such as "3.0". + */ +static void +override_version(struct gl_context *ctx, GLuint *major, GLuint *minor) +{ + const char *env_var = "MESA_GL_VERSION_OVERRIDE"; + const char *version; + int n; + + version = getenv(env_var); + if (!version) { + return; + } + n = sscanf(version, "%d.%d", major, minor); + if (n != 2) { + fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version); + return; + } +} /** * Examine enabled GL extensions to determine GL version. @@ -178,6 +200,9 @@ compute_version(struct gl_context *ctx) ctx->VersionMajor = major; ctx->VersionMinor = minor; + + override_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor); + ctx->VersionString = (char *) malloc(max); if (ctx->VersionString) { _mesa_snprintf(ctx->VersionString, max, diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c index 731338f9b..ad159c64d 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c +++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c @@ -176,7 +176,7 @@ convert_sampler(struct st_context *st, st_translate_color(msamp->BorderColor.f, teximg ? teximg->_BaseFormat : GL_RGBA, - sampler->border_color); + sampler->border_color.f); } sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ? diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index e744a9f0d..354e58de9 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -926,10 +926,10 @@ decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level, * then unmap it. */ static void -st_get_tex_image(struct gl_context * ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid * pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, GLboolean compressed_dst) +st_GetTexImage(struct gl_context * ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid * pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { struct st_context *st = st_context(ctx); struct st_texture_image *stImage = st_texture_image(texImage); @@ -939,9 +939,7 @@ st_get_tex_image(struct gl_context * ctx, GLenum target, GLint level, GLuint depth, i; GLubyte *dest; - if (stImage->pt && - util_format_is_s3tc(stImage->pt->format) && - !compressed_dst) { + if (stImage->pt && util_format_is_s3tc(stImage->pt->format)) { /* Need to decompress the texture. * We'll do this by rendering a textured quad. * Note that we only expect RGBA formats (no Z/depth formats). @@ -951,46 +949,14 @@ st_get_tex_image(struct gl_context * ctx, GLenum target, GLint level, return; } - /* Map */ - if (stImage->pt) { - /* Image is stored in hardware format in a buffer managed by the - * kernel. Need to explicitly map and unmap it. - */ - texImage->Data = st_texture_image_map(st, stImage, 0, - PIPE_TRANSFER_READ, 0, 0, - stImage->base.Width, - stImage->base.Height); - /* compute stride in texels from stride in bytes */ - texImage->RowStride = stImage->transfer->stride - * util_format_get_blockwidth(stImage->pt->format) - / util_format_get_blocksize(stImage->pt->format); - } - else { - /* Otherwise, the image should actually be stored in - * texImage->Data. This is pretty confusing for - * everybody, I'd much prefer to separate the two functions of - * texImage->Data - storage for texture images in main memory - * and access (ie mappings) of images. In other words, we'd - * create a new texImage->Map field and leave Data simply for - * storage. - */ - assert(texImage->Data); - } - depth = texImage->Depth; texImage->Depth = 1; dest = (GLubyte *) pixels; for (i = 0; i < depth; i++) { - if (compressed_dst) { - _mesa_get_compressed_teximage(ctx, target, level, dest, - texObj, texImage); - } - else { - _mesa_get_teximage(ctx, target, level, format, type, dest, - texObj, texImage); - } + _mesa_get_teximage(ctx, target, level, format, type, dest, + texObj, texImage); if (stImage->pt && i + 1 < depth) { /* unmap this slice */ @@ -1005,39 +971,10 @@ st_get_tex_image(struct gl_context * ctx, GLenum target, GLint level, } texImage->Depth = depth; - - /* Unmap */ - if (stImage->pt) { - st_texture_image_unmap(st, stImage); - texImage->Data = NULL; - } -} - - -static void -st_GetTexImage(struct gl_context * ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid * pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - st_get_tex_image(ctx, target, level, format, type, pixels, texObj, texImage, - GL_FALSE); } static void -st_GetCompressedTexImage(struct gl_context *ctx, GLenum target, GLint level, - GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - st_get_tex_image(ctx, target, level, 0, 0, pixels, texObj, texImage, - GL_TRUE); -} - - - -static void st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint width, GLint height, GLint depth, @@ -1924,7 +1861,7 @@ st_init_texture_functions(struct dd_function_table *functions) /* compressed texture functions */ functions->CompressedTexImage2D = st_CompressedTexImage2D; - functions->GetCompressedTexImage = st_GetCompressedTexImage; + functions->GetCompressedTexImage = _mesa_get_compressed_teximage; functions->NewTextureObject = st_NewTextureObject; functions->NewTextureImage = st_NewTextureImage; |