diff options
Diffstat (limited to 'mesalib/src')
23 files changed, 235 insertions, 164 deletions
diff --git a/mesalib/src/gallium/Automake.inc b/mesalib/src/gallium/Automake.inc index 74053eb2d..c43f735c3 100644 --- a/mesalib/src/gallium/Automake.inc +++ b/mesalib/src/gallium/Automake.inc @@ -16,6 +16,7 @@ GALLIUM_DRIVER_CFLAGS = \ -I$(top_srcdir)/src/gallium/include \ -I$(top_srcdir)/src/gallium/auxiliary \ -I$(top_srcdir)/src/gallium/drivers \ + -I$(top_srcdir)/src/gallium/winsys \ $(DEFINES) \ $(VISIBILITY_CFLAGS) @@ -26,6 +27,7 @@ GALLIUM_DRIVER_CXXFLAGS = \ -I$(top_srcdir)/src/gallium/include \ -I$(top_srcdir)/src/gallium/auxiliary \ -I$(top_srcdir)/src/gallium/drivers \ + -I$(top_srcdir)/src/gallium/winsys \ $(DEFINES) \ $(VISIBILITY_CXXFLAGS) diff --git a/mesalib/src/gallium/Makefile.am b/mesalib/src/gallium/Makefile.am index 1e1fd43d5..e4ef00346 100644 --- a/mesalib/src/gallium/Makefile.am +++ b/mesalib/src/gallium/Makefile.am @@ -109,6 +109,15 @@ if NEED_WINSYS_WRAPPER SUBDIRS += winsys/sw/wrapper endif +## +## Don't forget to bundle the remaining (non autotools) winsys' +## + +EXTRA_DIST = \ + winsys/sw/android \ + winsys/sw/gdi \ + winsys/sw/hgl + ## ## Gallium state trackers and their users (targets) @@ -164,6 +173,14 @@ SUBDIRS += state_trackers/xvmc targets/xvmc endif ## +## Don't forget to bundle the remaining (non autotools) state-trackers/targets +## + +EXTRA_DIST += \ + state_trackers/hgl targets/haiku-softpipe + + +## ## Gallium tests ## diff --git a/mesalib/src/gallium/SConscript b/mesalib/src/gallium/SConscript index 98d017e4d..977e3fbf4 100644 --- a/mesalib/src/gallium/SConscript +++ b/mesalib/src/gallium/SConscript @@ -85,6 +85,7 @@ if not env['embedded']: if env['platform'] == 'haiku': SConscript([ + 'state_trackers/hgl/SConscript', 'targets/haiku-softpipe/SConscript', ]) diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf.c b/mesalib/src/gallium/auxiliary/util/u_vbuf.c index c475ee1b3..650df9f6a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_vbuf.c +++ b/mesalib/src/gallium/auxiliary/util/u_vbuf.c @@ -191,47 +191,114 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, const struct pipe_vertex_element *attribs); static void u_vbuf_delete_vertex_elements(struct u_vbuf *mgr, void *cso); +static const struct { + enum pipe_format from, to; +} vbuf_format_fallbacks[] = { + { PIPE_FORMAT_R32_FIXED, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R32G32_FIXED, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R32G32B32_FIXED, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R32G32B32A32_FIXED, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R16_FLOAT, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R16G16_FLOAT, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R16G16B16_FLOAT, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R16G16B16A16_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R64_FLOAT, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R64G64_FLOAT, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R64G64B64_FLOAT, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R64G64B64A64_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R32_UNORM, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R32G32_UNORM, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R32G32B32_UNORM, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R32G32B32A32_UNORM, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R32_SNORM, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R32G32_SNORM, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R32G32B32_SNORM, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R32G32B32A32_SNORM, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R32_USCALED, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R32G32_USCALED, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R32G32B32_USCALED, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R32G32B32A32_USCALED, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R32_SSCALED, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R32G32_SSCALED, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R32G32B32_SSCALED, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R32G32B32A32_SSCALED, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R16_UNORM, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R16G16_UNORM, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R16G16B16_UNORM, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R16G16B16A16_UNORM, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R16_SNORM, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R16G16_SNORM, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R16G16B16_SNORM, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R16_USCALED, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R16G16_USCALED, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R16G16B16_USCALED, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R16G16B16A16_USCALED, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R16_SSCALED, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R16G16_SSCALED, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R16G16B16_SSCALED, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R16G16B16A16_SSCALED, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R8_UNORM, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R8G8_UNORM, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R8G8B8_UNORM, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R8G8B8A8_UNORM, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R8_SNORM, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R8G8_SNORM, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R8G8B8_SNORM, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R8G8B8A8_SNORM, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R8_USCALED, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R8G8_USCALED, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R8G8B8_USCALED, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R8G8B8A8_USCALED, PIPE_FORMAT_R32G32B32A32_FLOAT }, + { PIPE_FORMAT_R8_SSCALED, PIPE_FORMAT_R32_FLOAT }, + { PIPE_FORMAT_R8G8_SSCALED, PIPE_FORMAT_R32G32_FLOAT }, + { PIPE_FORMAT_R8G8B8_SSCALED, PIPE_FORMAT_R32G32B32_FLOAT }, + { PIPE_FORMAT_R8G8B8A8_SSCALED, PIPE_FORMAT_R32G32B32A32_FLOAT }, +}; -void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps) +boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps) { - caps->format_fixed32 = - screen->is_format_supported(screen, PIPE_FORMAT_R32_FIXED, PIPE_BUFFER, - 0, PIPE_BIND_VERTEX_BUFFER); - - caps->format_float16 = - screen->is_format_supported(screen, PIPE_FORMAT_R16_FLOAT, PIPE_BUFFER, - 0, PIPE_BIND_VERTEX_BUFFER); - - caps->format_float64 = - screen->is_format_supported(screen, PIPE_FORMAT_R64_FLOAT, PIPE_BUFFER, - 0, PIPE_BIND_VERTEX_BUFFER); - - caps->format_norm32 = - screen->is_format_supported(screen, PIPE_FORMAT_R32_UNORM, PIPE_BUFFER, - 0, PIPE_BIND_VERTEX_BUFFER) && - screen->is_format_supported(screen, PIPE_FORMAT_R32_SNORM, PIPE_BUFFER, - 0, PIPE_BIND_VERTEX_BUFFER); - - caps->format_scaled32 = - screen->is_format_supported(screen, PIPE_FORMAT_R32_USCALED, PIPE_BUFFER, - 0, PIPE_BIND_VERTEX_BUFFER) && - screen->is_format_supported(screen, PIPE_FORMAT_R32_SSCALED, PIPE_BUFFER, - 0, PIPE_BIND_VERTEX_BUFFER); + unsigned i; + boolean fallback = FALSE; + + /* I'd rather have a bitfield of which formats are supported and a static + * table of the translations indexed by format, but since we don't have C99 + * we can't easily make a sparsely-populated table indexed by format. So, + * we construct the sparse table here. + */ + for (i = 0; i < PIPE_FORMAT_COUNT; i++) + caps->format_translation[i] = i; + + for (i = 0; i < Elements(vbuf_format_fallbacks); i++) { + enum pipe_format format = vbuf_format_fallbacks[i].from; + + if (!screen->is_format_supported(screen, format, PIPE_BUFFER, 0, + PIPE_BIND_VERTEX_BUFFER)) { + caps->format_translation[format] = vbuf_format_fallbacks[i].to; + fallback = TRUE; + } + } caps->buffer_offset_unaligned = !screen->get_param(screen, - PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY); - + PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY); caps->buffer_stride_unaligned = - !screen->get_param(screen, + !screen->get_param(screen, PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY); - caps->velem_src_offset_unaligned = !screen->get_param(screen, - PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY); - + PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY); caps->user_vertex_buffers = screen->get_param(screen, PIPE_CAP_USER_VERTEX_BUFFERS); + + if (!caps->buffer_offset_unaligned || + !caps->buffer_stride_unaligned || + !caps->velem_src_offset_unaligned || + !caps->user_vertex_buffers) { + fallback = TRUE; + } + + return fallback; } struct u_vbuf * @@ -664,9 +731,6 @@ static void u_vbuf_translate_end(struct u_vbuf *mgr) } } -#define FORMAT_REPLACE(what, withwhat) \ - case PIPE_FORMAT_##what: format = PIPE_FORMAT_##withwhat; break - static void * u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, const struct pipe_vertex_element *attribs) @@ -695,62 +759,7 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, ve->noninstance_vb_mask_any |= 1 << ve->ve[i].vertex_buffer_index; } - /* Choose a native format. - * For now we don't care about the alignment, that's going to - * be sorted out later. */ - if (!mgr->caps.format_fixed32) { - switch (format) { - FORMAT_REPLACE(R32_FIXED, R32_FLOAT); - FORMAT_REPLACE(R32G32_FIXED, R32G32_FLOAT); - FORMAT_REPLACE(R32G32B32_FIXED, R32G32B32_FLOAT); - FORMAT_REPLACE(R32G32B32A32_FIXED, R32G32B32A32_FLOAT); - default:; - } - } - if (!mgr->caps.format_float16) { - switch (format) { - FORMAT_REPLACE(R16_FLOAT, R32_FLOAT); - FORMAT_REPLACE(R16G16_FLOAT, R32G32_FLOAT); - FORMAT_REPLACE(R16G16B16_FLOAT, R32G32B32_FLOAT); - FORMAT_REPLACE(R16G16B16A16_FLOAT, R32G32B32A32_FLOAT); - default:; - } - } - if (!mgr->caps.format_float64) { - switch (format) { - FORMAT_REPLACE(R64_FLOAT, R32_FLOAT); - FORMAT_REPLACE(R64G64_FLOAT, R32G32_FLOAT); - FORMAT_REPLACE(R64G64B64_FLOAT, R32G32B32_FLOAT); - FORMAT_REPLACE(R64G64B64A64_FLOAT, R32G32B32A32_FLOAT); - default:; - } - } - if (!mgr->caps.format_norm32) { - switch (format) { - FORMAT_REPLACE(R32_UNORM, R32_FLOAT); - FORMAT_REPLACE(R32G32_UNORM, R32G32_FLOAT); - FORMAT_REPLACE(R32G32B32_UNORM, R32G32B32_FLOAT); - FORMAT_REPLACE(R32G32B32A32_UNORM, R32G32B32A32_FLOAT); - FORMAT_REPLACE(R32_SNORM, R32_FLOAT); - FORMAT_REPLACE(R32G32_SNORM, R32G32_FLOAT); - FORMAT_REPLACE(R32G32B32_SNORM, R32G32B32_FLOAT); - FORMAT_REPLACE(R32G32B32A32_SNORM, R32G32B32A32_FLOAT); - default:; - } - } - if (!mgr->caps.format_scaled32) { - switch (format) { - FORMAT_REPLACE(R32_USCALED, R32_FLOAT); - FORMAT_REPLACE(R32G32_USCALED, R32G32_FLOAT); - FORMAT_REPLACE(R32G32B32_USCALED, R32G32B32_FLOAT); - FORMAT_REPLACE(R32G32B32A32_USCALED,R32G32B32A32_FLOAT); - FORMAT_REPLACE(R32_SSCALED, R32_FLOAT); - FORMAT_REPLACE(R32G32_SSCALED, R32G32_FLOAT); - FORMAT_REPLACE(R32G32B32_SSCALED, R32G32B32_FLOAT); - FORMAT_REPLACE(R32G32B32A32_SSCALED,R32G32B32A32_FLOAT); - default:; - } - } + format = mgr->caps.format_translation[format]; driver_attribs[i].src_format = format; ve->native_format[i] = format; diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf.h b/mesalib/src/gallium/auxiliary/util/u_vbuf.h index a608184e5..9e8b135fb 100644 --- a/mesalib/src/gallium/auxiliary/util/u_vbuf.h +++ b/mesalib/src/gallium/auxiliary/util/u_vbuf.h @@ -35,19 +35,14 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "pipe/p_format.h" struct cso_context; struct u_vbuf; /* Hardware vertex fetcher limitations can be described by this structure. */ struct u_vbuf_caps { - /* Vertex format CAPs. */ - /* TRUE if hardware supports it. */ - unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */ - unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */ - unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */ - unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */ - unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */ + enum pipe_format format_translation[PIPE_FORMAT_COUNT]; /* Whether vertex fetches don't have to be 4-byte-aligned. */ /* TRUE if hardware supports it. */ @@ -60,7 +55,7 @@ struct u_vbuf_caps { }; -void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps); +boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps); struct u_vbuf * u_vbuf_create(struct pipe_context *pipe, diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp index 39c7beeb2..7130d6162 100644 --- a/mesalib/src/glsl/ast_function.cpp +++ b/mesalib/src/glsl/ast_function.cpp @@ -103,35 +103,35 @@ verify_image_parameter(YYLTYPE *loc, _mesa_glsl_parse_state *state, * qualifiers. [...] It is legal to have additional qualifiers * on a formal parameter, but not to have fewer." */ - if (actual->data.image.coherent && !formal->data.image.coherent) { + if (actual->data.image_coherent && !formal->data.image_coherent) { _mesa_glsl_error(loc, state, "function call parameter `%s' drops " "`coherent' qualifier", formal->name); return false; } - if (actual->data.image._volatile && !formal->data.image._volatile) { + if (actual->data.image_volatile && !formal->data.image_volatile) { _mesa_glsl_error(loc, state, "function call parameter `%s' drops " "`volatile' qualifier", formal->name); return false; } - if (actual->data.image.restrict_flag && !formal->data.image.restrict_flag) { + if (actual->data.image_restrict && !formal->data.image_restrict) { _mesa_glsl_error(loc, state, "function call parameter `%s' drops " "`restrict' qualifier", formal->name); return false; } - if (actual->data.image.read_only && !formal->data.image.read_only) { + if (actual->data.image_read_only && !formal->data.image_read_only) { _mesa_glsl_error(loc, state, "function call parameter `%s' drops " "`readonly' qualifier", formal->name); return false; } - if (actual->data.image.write_only && !formal->data.image.write_only) { + if (actual->data.image_write_only && !formal->data.image_write_only) { _mesa_glsl_error(loc, state, "function call parameter `%s' drops " "`writeonly' qualifier", formal->name); diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index 30b02d016..897505c60 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -2360,11 +2360,11 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual, "global variables"); } - var->data.image.read_only |= qual->flags.q.read_only; - var->data.image.write_only |= qual->flags.q.write_only; - var->data.image.coherent |= qual->flags.q.coherent; - var->data.image._volatile |= qual->flags.q._volatile; - var->data.image.restrict_flag |= qual->flags.q.restrict_flag; + var->data.image_read_only |= qual->flags.q.read_only; + var->data.image_write_only |= qual->flags.q.write_only; + var->data.image_coherent |= qual->flags.q.coherent; + var->data.image_volatile |= qual->flags.q._volatile; + var->data.image_restrict |= qual->flags.q.restrict_flag; var->data.read_only = true; if (qual->flags.q.explicit_image_format) { @@ -2378,7 +2378,7 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual, "base data type of the image"); } - var->data.image.format = qual->image_format; + var->data.image_format = qual->image_format; } else { if (var->data.mode == ir_var_uniform && !qual->flags.q.write_only) { _mesa_glsl_error(loc, state, "uniforms not qualified with " @@ -2386,7 +2386,7 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual, "qualifier"); } - var->data.image.format = GL_NONE; + var->data.image_format = GL_NONE; } } } diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp index 2cc714a98..a1473d270 100755 --- a/mesalib/src/glsl/builtin_functions.cpp +++ b/mesalib/src/glsl/builtin_functions.cpp @@ -4476,11 +4476,11 @@ builtin_builder::_image_prototype(const glsl_type *image_type, * accept everything that needs to be accepted, and reject cases * like loads from write-only or stores to read-only images. */ - image->data.image.read_only = flags & IMAGE_FUNCTION_READ_ONLY; - image->data.image.write_only = flags & IMAGE_FUNCTION_WRITE_ONLY; - image->data.image.coherent = true; - image->data.image._volatile = true; - image->data.image.restrict_flag = true; + image->data.image_read_only = (flags & IMAGE_FUNCTION_READ_ONLY) != 0; + image->data.image_write_only = (flags & IMAGE_FUNCTION_WRITE_ONLY) != 0; + image->data.image_coherent = true; + image->data.image_volatile = true; + image->data.image_restrict = true; return sig; } diff --git a/mesalib/src/glsl/glcpp/glcpp-lex.l b/mesalib/src/glsl/glcpp/glcpp-lex.l index 98d500ec0..fa9aa5069 100644 --- a/mesalib/src/glsl/glcpp/glcpp-lex.l +++ b/mesalib/src/glsl/glcpp/glcpp-lex.l @@ -289,8 +289,14 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? } /* Swallow empty #pragma directives, (to avoid confusing the - * downstream compiler). */ -<HASH>pragma{HSPACE}*/{NEWLINE} { + * downstream compiler). + * + * Note: We use a simple regular expression for the lookahead + * here. Specifically, we cannot use the complete {NEWLINE} expression + * since it uses alternation and we've found that there's a flex bug + * where using alternation in the lookahead portion of a pattern + * triggers a buffer overrun. */ +<HASH>pragma{HSPACE}*/[\r\n] { BEGIN INITIAL; } diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy index beabb5ffd..cef968420 100644 --- a/mesalib/src/glsl/glsl_parser.yy +++ b/mesalib/src/glsl/glsl_parser.yy @@ -25,6 +25,9 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#ifndef _MSC_VER +#include <strings.h> +#endif #include <assert.h> #include "ast.h" @@ -180,7 +183,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2, */ %token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO %token INLINE_TOK NOINLINE PUBLIC_TOK STATIC EXTERN EXTERNAL -%token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK OUPTUT +%token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK %token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 %token SAMPLER3DRECT %token SIZEOF CAST NAMESPACE USING diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp index c7029dc4c..c2bfda938 100755 --- a/mesalib/src/glsl/ir.cpp +++ b/mesalib/src/glsl/ir.cpp @@ -1551,6 +1551,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->data.has_initializer = false; this->data.location = -1; this->data.location_frac = 0; + this->data.binding = 0; this->warn_extension = NULL; this->constant_value = NULL; this->constant_initializer = NULL; @@ -1566,13 +1567,12 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->data.mode = mode; this->data.interpolation = INTERP_QUALIFIER_NONE; this->data.max_array_access = 0; - this->data.atomic.buffer_index = 0; this->data.atomic.offset = 0; - this->data.image.read_only = false; - this->data.image.write_only = false; - this->data.image.coherent = false; - this->data.image._volatile = false; - this->data.image.restrict_flag = false; + this->data.image_read_only = false; + this->data.image_write_only = false; + this->data.image_coherent = false; + this->data.image_volatile = false; + this->data.image_restrict = false; if (type != NULL) { if (type->base_type == GLSL_TYPE_SAMPLER) @@ -1678,11 +1678,11 @@ ir_function_signature::qualifiers_match(exec_list *params) a->data.interpolation != b->data.interpolation || a->data.centroid != b->data.centroid || a->data.sample != b->data.sample || - a->data.image.read_only != b->data.image.read_only || - a->data.image.write_only != b->data.image.write_only || - a->data.image.coherent != b->data.image.coherent || - a->data.image._volatile != b->data.image._volatile || - a->data.image.restrict_flag != b->data.image.restrict_flag) { + a->data.image_read_only != b->data.image_read_only || + a->data.image_write_only != b->data.image_write_only || + a->data.image_coherent != b->data.image_coherent || + a->data.image_volatile != b->data.image_volatile || + a->data.image_restrict != b->data.image_restrict) { /* parameter a's qualifiers don't match */ return a->name; diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h index 18623b968..e9051732b 100644 --- a/mesalib/src/glsl/ir.h +++ b/mesalib/src/glsl/ir.h @@ -689,6 +689,28 @@ public: unsigned must_be_shader_input:1; /** + * Output index for dual source blending. + * + * \note + * The GLSL spec only allows the values 0 or 1 for the index in \b dual + * source blending. + */ + unsigned index:1; + + + /** + * ARB_shader_image_load_store qualifiers. + */ + unsigned image_read_only:1; /**< "readonly" qualifier. */ + unsigned image_write_only:1; /**< "writeonly" qualifier. */ + unsigned image_coherent:1; + unsigned image_volatile:1; + unsigned image_restrict:1; + + /** Image internal format if specified explicitly, otherwise GL_NONE. */ + uint16_t image_format; + + /** * \brief Layout qualifier for gl_FragDepth. * * This is not equal to \c ir_depth_layout_none if and only if this @@ -722,12 +744,7 @@ public: unsigned stream; /** - * output index for dual source blending. - */ - int index; - - /** - * Initial binding point for a sampler or UBO. + * Initial binding point for a sampler, atomic, or UBO. * * For array types, this represents the binding point for the first element. */ @@ -737,25 +754,10 @@ public: * Location an atomic counter is stored at. */ struct { - unsigned buffer_index; unsigned offset; } atomic; /** - * ARB_shader_image_load_store qualifiers. - */ - struct { - bool read_only; /**< "readonly" qualifier. */ - bool write_only; /**< "writeonly" qualifier. */ - bool coherent; - bool _volatile; - bool restrict_flag; - - /** Image internal format if specified explicitly, otherwise GL_NONE. */ - GLenum format; - } image; - - /** * Highest element accessed with a constant expression array index * * Not used for non-array variables. diff --git a/mesalib/src/glsl/link_atomics.cpp b/mesalib/src/glsl/link_atomics.cpp index 75699fd93..603873a5d 100644 --- a/mesalib/src/glsl/link_atomics.cpp +++ b/mesalib/src/glsl/link_atomics.cpp @@ -201,7 +201,9 @@ link_assign_atomic_counter_resources(struct gl_context *ctx, gl_uniform_storage *const storage = &prog->UniformStorage[id]; mab.Uniforms[j] = id; - var->data.atomic.buffer_index = i; + if (!var->data.explicit_binding) + var->data.binding = i; + storage->atomic_buffer_index = i; storage->offset = var->data.atomic.offset; storage->array_stride = (var->type->is_array() ? diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp index f1484617b..1d5b62d71 100644 --- a/mesalib/src/glsl/link_uniforms.cpp +++ b/mesalib/src/glsl/link_uniforms.cpp @@ -829,8 +829,8 @@ link_set_image_access_qualifiers(struct gl_shader_program *prog) (void) found; const gl_uniform_storage *storage = &prog->UniformStorage[id]; const unsigned index = storage->image[i].index; - const GLenum access = (var->data.image.read_only ? GL_READ_ONLY : - var->data.image.write_only ? GL_WRITE_ONLY : + const GLenum access = (var->data.image_read_only ? GL_READ_ONLY : + var->data.image_write_only ? GL_WRITE_ONLY : GL_READ_WRITE); for (unsigned j = 0; j < MAX2(1, storage->array_elements); ++j) diff --git a/mesalib/src/hgl/GLRendererRoster.cpp b/mesalib/src/hgl/GLRendererRoster.cpp index 1712a871c..d29f7ecc8 100644 --- a/mesalib/src/hgl/GLRendererRoster.cpp +++ b/mesalib/src/hgl/GLRendererRoster.cpp @@ -17,7 +17,7 @@ #include <Directory.h> #include <FindDirectory.h> #include <Path.h> -#include <String.h> +#include <strings.h> #include "GLDispatcher.h" #include "GLRendererRoster.h" diff --git a/mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml b/mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml index 0ee6a3c00..7e6268877 100644 --- a/mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml +++ b/mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml @@ -53,6 +53,7 @@ <enum name="VERTEX_BINDING_STRIDE" value="0x82D8"/> <enum name="MAX_VERTEX_ATTRIB_RELATIVE_OFFSET" value="0x82D9"/> <enum name="MAX_VERTEX_ATTRIB_BINDINGS" value="0x82DA"/> + <enum name="MAX_VERTEX_ATTRIB_STRIDE" value="0x82E5"/> </category> </OpenGLAPI> diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 232084267..fbdbd680a 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -670,6 +670,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) ? GL_CONTEXT_CORE_PROFILE_BIT : GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; + /* GL 4.4 */ + consts->MaxVertexAttribStride = 2048; + /** GL_EXT_gpu_shader4 */ consts->MinProgramTexelOffset = -8; consts->MaxProgramTexelOffset = 7; diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py index ff858207b..aace8a5b5 100644 --- a/mesalib/src/mesa/main/get_hash_params.py +++ b/mesalib/src/mesa/main/get_hash_params.py @@ -712,6 +712,9 @@ descriptor=[ [ "MAX_GEOMETRY_INPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents), extra_version_32" ], [ "MAX_GEOMETRY_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents), extra_version_32" ], +# GL 4.4 + [ "MAX_VERTEX_ATTRIB_STRIDE", "CONTEXT_ENUM(Const.MaxVertexAttribStride), NO_EXTRA" ], + # GL_ARB_robustness [ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA" ], diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index cb2a4df4f..dc25ea467 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2317,9 +2317,6 @@ struct gl_geometry_program_state struct gl_geometry_program *_Current; GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; }; /** @@ -3414,6 +3411,9 @@ struct gl_constants /** OpenGL version 3.2 */ GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ + /** OpenGL version 4.4 */ + GLuint MaxVertexAttribStride; + /** GL_EXT_transform_feedback */ GLuint MaxTransformFeedbackBuffers; GLuint MaxTransformFeedbackSeparateComponents; diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 2a82c2d4e..923cf60d7 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -772,18 +772,21 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex) { if (!ctx->Shared->FallbackTex[tex]) { /* create fallback texture now */ - const GLsizei width = 1, height = 1, depth = 1; - GLubyte texel[4]; + const GLsizei width = 1, height = 1; + GLsizei depth = 1; + GLubyte texel[24]; struct gl_texture_object *texObj; struct gl_texture_image *texImage; mesa_format texFormat; GLuint dims, face, numFaces = 1; GLenum target; - texel[0] = - texel[1] = - texel[2] = 0x0; - texel[3] = 0xff; + for (face = 0; face < 6; face++) { + texel[4*face + 0] = + texel[4*face + 1] = + texel[4*face + 2] = 0x0; + texel[4*face + 3] = 0xff; + } switch (tex) { case TEXTURE_2D_ARRAY_INDEX: @@ -822,6 +825,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex) case TEXTURE_CUBE_ARRAY_INDEX: dims = 3; target = GL_TEXTURE_CUBE_MAP_ARRAY; + depth = 6; break; case TEXTURE_EXTERNAL_INDEX: dims = 2; diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index 5d3cc2a70..7d169f9d4 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -424,6 +424,13 @@ update_array(struct gl_context *ctx, return; } + if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 && + stride > ctx->Const.MaxVertexAttribStride) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(stride=%d > " + "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, stride); + return; + } + /* Page 29 (page 44 of the PDF) of the OpenGL 3.3 spec says: * * "An INVALID_OPERATION error is generated under any of the following @@ -1437,6 +1444,13 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset, return; } + if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 && + stride > ctx->Const.MaxVertexAttribStride) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindVertexBuffer(stride=%d > " + "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride); + return; + } + if (buffer == vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj->Name) { vbo = vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj; } else if (buffer != 0) { @@ -1565,6 +1579,14 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers, continue; } + if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 && + strides[i] > ctx->Const.MaxVertexAttribStride) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBindVertexBuffers(strides[%u]=%d > " + "GL_MAX_VERTEX_ATTRIB_STRIDE)", i, strides[i]); + continue; + } + if (buffers[i]) { struct gl_vertex_buffer_binding *binding = &vao->VertexBinding[VERT_ATTRIB_GENERIC(first + i)]; diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c index ef5bf6b11..6e17fe65f 100644 --- a/mesalib/src/mesa/program/program.c +++ b/mesalib/src/mesa/program/program.c @@ -100,7 +100,6 @@ _mesa_init_program(struct gl_context *ctx) /* right now by default we don't have a geometry program */ _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL); - ctx->GeometryProgram.Cache = _mesa_new_program_cache(); /* XXX probably move this stuff */ ctx->ATIFragmentShader.Enabled = GL_FALSE; @@ -121,7 +120,6 @@ _mesa_free_program_data(struct gl_context *ctx) _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); _mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache); _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL); - _mesa_delete_program_cache(ctx, ctx->GeometryProgram.Cache); /* XXX probably move this stuff */ if (ctx->ATIFragmentShader.Current) { diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 4110eb5dd..9db648c03 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -289,6 +289,9 @@ void st_init_limits(struct pipe_screen *screen, /* The vertex stream must fit into pipe_stream_output_info::stream */ assert(c->MaxVertexStreams <= 4); + c->MaxVertexAttribStride + = screen->get_param(screen, PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE); + c->StripTextureBorder = GL_TRUE; c->GLSLSkipStrictMaxUniformLimitCheck = |