diff options
Diffstat (limited to 'mesalib/src')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_transfer.c | 249 | ||||
-rw-r--r-- | mesalib/src/glsl/glcpp/glcpp-parse.y | 50 | ||||
-rw-r--r-- | mesalib/src/glsl/glcpp/glcpp.h | 2 | ||||
-rw-r--r-- | mesalib/src/glsl/link_uniforms.cpp | 15 | ||||
-rw-r--r-- | mesalib/src/glsl/linker.h | 2 | ||||
-rw-r--r-- | mesalib/src/glsl/ralloc.c | 11 | ||||
-rw-r--r-- | mesalib/src/glsl/ralloc.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/readpix.c | 22 | ||||
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_draw.c | 9 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo.h | 18 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_exec_array.c | 16 |
12 files changed, 219 insertions, 185 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_transfer.c b/mesalib/src/gallium/auxiliary/util/u_transfer.c index 772b6d269..673a984fc 100644 --- a/mesalib/src/gallium/auxiliary/util/u_transfer.c +++ b/mesalib/src/gallium/auxiliary/util/u_transfer.c @@ -1,114 +1,135 @@ -#include "pipe/p_context.h"
-#include "util/u_rect.h"
-#include "util/u_inlines.h"
-#include "util/u_transfer.h"
-#include "util/u_memory.h"
-
-/* One-shot transfer operation with data supplied in a user
- * pointer. XXX: strides??
- */
-void u_default_transfer_inline_write( struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned layer_stride)
-{
- struct pipe_transfer *transfer = NULL;
- uint8_t *map = NULL;
- const uint8_t *src_data = data;
- unsigned i;
-
- transfer = pipe->get_transfer(pipe,
- resource,
- level,
- usage,
- box );
- if (transfer == NULL)
- goto out;
-
- map = pipe_transfer_map(pipe, transfer);
- if (map == NULL)
- goto out;
-
- for (i = 0; i < box->depth; i++) {
- util_copy_rect(map,
- resource->format,
- transfer->stride, /* bytes */
- 0, 0,
- box->width,
- box->height,
- src_data,
- stride, /* bytes */
- 0, 0);
- map += transfer->layer_stride;
- src_data += layer_stride;
- }
-
-out:
- if (map)
- pipe_transfer_unmap(pipe, transfer);
-
- if (transfer)
- pipe_transfer_destroy(pipe, transfer);
-}
-
-
-boolean u_default_resource_get_handle(struct pipe_screen *screen,
- struct pipe_resource *resource,
- struct winsys_handle *handle)
-{
- return FALSE;
-}
-
-
-
-void u_default_transfer_flush_region( struct pipe_context *pipe,
- struct pipe_transfer *transfer,
- const struct pipe_box *box)
-{
- /* This is a no-op implementation, nothing to do.
- */
-}
-
-struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
-{
- struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
- if (transfer == NULL)
- return NULL;
-
- transfer->resource = resource;
- transfer->level = level;
- transfer->usage = usage;
- transfer->box = *box;
-
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return transfer;
-}
-
-void u_default_transfer_unmap( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
-}
-
-void u_default_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- FREE(transfer);
-}
-
-void u_default_redefine_user_buffer(struct pipe_context *ctx,
- struct pipe_resource *resource,
- unsigned offset,
- unsigned size)
-{
- resource->width0 = MAX2(resource->width0, offset + size);
-}
+#include "pipe/p_context.h" +#include "util/u_rect.h" +#include "util/u_inlines.h" +#include "util/u_transfer.h" +#include "util/u_memory.h" + +/* One-shot transfer operation with data supplied in a user + * pointer. XXX: strides?? + */ +void u_default_transfer_inline_write( struct pipe_context *pipe, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box, + const void *data, + unsigned stride, + unsigned layer_stride) +{ + struct pipe_transfer *transfer = NULL; + uint8_t *map = NULL; + + assert(!(usage & PIPE_TRANSFER_READ)); + + /* the write flag is implicit by the nature of transfer_inline_write */ + usage |= PIPE_TRANSFER_WRITE; + + /* transfer_inline_write implicitly discards the rewritten buffer range */ + if (box->x == 0 && box->width == resource->width0) { + usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE; + } else { + usage |= PIPE_TRANSFER_DISCARD_RANGE; + } + + transfer = pipe->get_transfer(pipe, + resource, + level, + usage, + box ); + if (transfer == NULL) + goto out; + + map = pipe_transfer_map(pipe, transfer); + if (map == NULL) + goto out; + + if (resource->target == PIPE_BUFFER) { + assert(box->height == 1); + assert(box->depth == 1); + + memcpy(map, data, box->width); + } + else { + const uint8_t *src_data = data; + unsigned i; + + for (i = 0; i < box->depth; i++) { + util_copy_rect(map, + resource->format, + transfer->stride, /* bytes */ + 0, 0, + box->width, + box->height, + src_data, + stride, /* bytes */ + 0, 0); + map += transfer->layer_stride; + src_data += layer_stride; + } + } + +out: + if (map) + pipe_transfer_unmap(pipe, transfer); + + if (transfer) + pipe_transfer_destroy(pipe, transfer); +} + + +boolean u_default_resource_get_handle(struct pipe_screen *screen, + struct pipe_resource *resource, + struct winsys_handle *handle) +{ + return FALSE; +} + + + +void u_default_transfer_flush_region( struct pipe_context *pipe, + struct pipe_transfer *transfer, + const struct pipe_box *box) +{ + /* This is a no-op implementation, nothing to do. + */ +} + +struct pipe_transfer * u_default_get_transfer(struct pipe_context *context, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box) +{ + struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer); + if (transfer == NULL) + return NULL; + + transfer->resource = resource; + transfer->level = level; + transfer->usage = usage; + transfer->box = *box; + + /* Note strides are zero, this is ok for buffers, but not for + * textures 2d & higher at least. + */ + return transfer; +} + +void u_default_transfer_unmap( struct pipe_context *pipe, + struct pipe_transfer *transfer ) +{ +} + +void u_default_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *transfer) +{ + FREE(transfer); +} + +void u_default_redefine_user_buffer(struct pipe_context *ctx, + struct pipe_resource *resource, + unsigned offset, + unsigned size) +{ + resource->width0 = MAX2(resource->width0, offset + size); +} diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y index efcc205c2..47ba54ddf 100644 --- a/mesalib/src/glsl/glcpp/glcpp-parse.y +++ b/mesalib/src/glsl/glcpp/glcpp-parse.y @@ -184,11 +184,11 @@ input: line: control_line { - ralloc_strcat (&parser->output, "\n"); + ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n"); } | text_line { _glcpp_parser_print_expanded_token_list (parser, $1); - ralloc_strcat (&parser->output, "\n"); + ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n"); ralloc_free ($1); } | expanded_line @@ -320,7 +320,7 @@ control_line: if ($2 >= 130 || $2 == 100) add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1); - ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, $2); + ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "#version %" PRIiMAX, $2); } | HASH NEWLINE ; @@ -903,54 +903,54 @@ _token_list_equal_ignoring_space (token_list_t *a, token_list_t *b) } static void -_token_print (char **out, token_t *token) +_token_print (char **out, size_t *len, token_t *token) { if (token->type < 256) { - ralloc_asprintf_append (out, "%c", token->type); + ralloc_asprintf_rewrite_tail (out, len, "%c", token->type); return; } switch (token->type) { case INTEGER: - ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival); + ralloc_asprintf_rewrite_tail (out, len, "%" PRIiMAX, token->value.ival); break; case IDENTIFIER: case INTEGER_STRING: case OTHER: - ralloc_strcat (out, token->value.str); + ralloc_asprintf_rewrite_tail (out, len, "%s", token->value.str); break; case SPACE: - ralloc_strcat (out, " "); + ralloc_asprintf_rewrite_tail (out, len, " "); break; case LEFT_SHIFT: - ralloc_strcat (out, "<<"); + ralloc_asprintf_rewrite_tail (out, len, "<<"); break; case RIGHT_SHIFT: - ralloc_strcat (out, ">>"); + ralloc_asprintf_rewrite_tail (out, len, ">>"); break; case LESS_OR_EQUAL: - ralloc_strcat (out, "<="); + ralloc_asprintf_rewrite_tail (out, len, "<="); break; case GREATER_OR_EQUAL: - ralloc_strcat (out, ">="); + ralloc_asprintf_rewrite_tail (out, len, ">="); break; case EQUAL: - ralloc_strcat (out, "=="); + ralloc_asprintf_rewrite_tail (out, len, "=="); break; case NOT_EQUAL: - ralloc_strcat (out, "!="); + ralloc_asprintf_rewrite_tail (out, len, "!="); break; case AND: - ralloc_strcat (out, "&&"); + ralloc_asprintf_rewrite_tail (out, len, "&&"); break; case OR: - ralloc_strcat (out, "||"); + ralloc_asprintf_rewrite_tail (out, len, "||"); break; case PASTE: - ralloc_strcat (out, "##"); + ralloc_asprintf_rewrite_tail (out, len, "##"); break; case COMMA_FINAL: - ralloc_strcat (out, ","); + ralloc_asprintf_rewrite_tail (out, len, ","); break; case PLACEHOLDER: /* Nothing to print. */ @@ -1040,11 +1040,11 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) } glcpp_error (&token->location, parser, ""); - ralloc_strcat (&parser->info_log, "Pasting \""); - _token_print (&parser->info_log, token); - ralloc_strcat (&parser->info_log, "\" and \""); - _token_print (&parser->info_log, other); - ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n"); + ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "Pasting \""); + _token_print (&parser->info_log, &parser->info_log_length, token); + ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "\" and \""); + _token_print (&parser->info_log, &parser->info_log_length, other); + ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "\" does not give a valid preprocessing token.\n"); return token; } @@ -1058,7 +1058,7 @@ _token_list_print (glcpp_parser_t *parser, token_list_t *list) return; for (node = list->head; node; node = node->next) - _token_print (&parser->output, node->token); + _token_print (&parser->output, &parser->output_length, node->token); } void @@ -1104,7 +1104,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) parser->lex_from_node = NULL; parser->output = ralloc_strdup(parser, ""); + parser->output_length = 0; parser->info_log = ralloc_strdup(parser, ""); + parser->info_log_length = 0; parser->error = 0; /* Add pre-defined macros. */ diff --git a/mesalib/src/glsl/glcpp/glcpp.h b/mesalib/src/glsl/glcpp/glcpp.h index dc816e90e..2d7cad2e6 100644 --- a/mesalib/src/glsl/glcpp/glcpp.h +++ b/mesalib/src/glsl/glcpp/glcpp.h @@ -174,6 +174,8 @@ struct glcpp_parser { token_node_t *lex_from_node; char *output; char *info_log; + size_t output_length; + size_t info_log_length; int error; }; diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp index d51850c21..613c9b7ae 100644 --- a/mesalib/src/glsl/link_uniforms.cpp +++ b/mesalib/src/glsl/link_uniforms.cpp @@ -67,7 +67,7 @@ uniform_field_visitor::process(ir_variable *var) void uniform_field_visitor::recursion(const glsl_type *t, char **name, - unsigned name_length) + size_t name_length) { /* Records need to have each field processed individually. * @@ -78,22 +78,21 @@ uniform_field_visitor::recursion(const glsl_type *t, char **name, if (t->is_record()) { for (unsigned i = 0; i < t->length; i++) { const char *field = t->fields.structure[i].name; + size_t new_length = name_length; /* Append '.field' to the current uniform name. */ - ralloc_asprintf_rewrite_tail(name, name_length, ".%s", field); + ralloc_asprintf_rewrite_tail(name, &new_length, ".%s", field); - recursion(t->fields.structure[i].type, name, - name_length + 1 + strlen(field)); + recursion(t->fields.structure[i].type, name, new_length); } } else if (t->is_array() && t->fields.array->is_record()) { for (unsigned i = 0; i < t->length; i++) { - char subscript[13]; + size_t new_length = name_length; /* Append the subscript to the current uniform name */ - const unsigned subscript_length = snprintf(subscript, 13, "[%u]", i); - ralloc_asprintf_rewrite_tail(name, name_length, "%s", subscript); + ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]", i); - recursion(t->fields.array, name, name_length + subscript_length); + recursion(t->fields.array, name, new_length); } } else { this->visit_field(t, *name); diff --git a/mesalib/src/glsl/linker.h b/mesalib/src/glsl/linker.h index 433c63be2..0b4c001f7 100644 --- a/mesalib/src/glsl/linker.h +++ b/mesalib/src/glsl/linker.h @@ -76,7 +76,7 @@ private: * \param name_length Length of the current name \b not including the * terminating \c NUL character. */ - void recursion(const glsl_type *t, char **name, unsigned name_length); + void recursion(const glsl_type *t, char **name, size_t name_length); }; #endif /* GLSL_LINKER_H */ diff --git a/mesalib/src/glsl/ralloc.c b/mesalib/src/glsl/ralloc.c index 91e4bab2e..2f93dcdea 100644 --- a/mesalib/src/glsl/ralloc.c +++ b/mesalib/src/glsl/ralloc.c @@ -448,11 +448,11 @@ ralloc_vasprintf_append(char **str, const char *fmt, va_list args) size_t existing_length; assert(str != NULL); existing_length = *str ? strlen(*str) : 0; - return ralloc_vasprintf_rewrite_tail(str, existing_length, fmt, args); + return ralloc_vasprintf_rewrite_tail(str, &existing_length, fmt, args); } bool -ralloc_asprintf_rewrite_tail(char **str, size_t start, const char *fmt, ...) +ralloc_asprintf_rewrite_tail(char **str, size_t *start, const char *fmt, ...) { bool success; va_list args; @@ -463,7 +463,7 @@ ralloc_asprintf_rewrite_tail(char **str, size_t start, const char *fmt, ...) } bool -ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt, +ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt, va_list args) { size_t new_length; @@ -479,11 +479,12 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt, new_length = printf_length(fmt, args); - ptr = resize(*str, start + new_length + 1); + ptr = resize(*str, *start + new_length + 1); if (unlikely(ptr == NULL)) return false; - vsnprintf(ptr + start, new_length + 1, fmt, args); + vsnprintf(ptr + *start, new_length + 1, fmt, args); *str = ptr; + *start += new_length; return true; } diff --git a/mesalib/src/glsl/ralloc.h b/mesalib/src/glsl/ralloc.h index 1324f3466..86306b1f5 100644 --- a/mesalib/src/glsl/ralloc.h +++ b/mesalib/src/glsl/ralloc.h @@ -329,10 +329,11 @@ char *ralloc_vasprintf(const void *ctx, const char *fmt, va_list args); * \param fmt A printf-style formatting string * * \p str will be updated to the new pointer unless allocation fails. + * \p start will be increased by the length of the newly formatted text. * * \return True unless allocation failed. */ -bool ralloc_asprintf_rewrite_tail(char **str, size_t start, +bool ralloc_asprintf_rewrite_tail(char **str, size_t *start, const char *fmt, ...); /** @@ -352,10 +353,11 @@ bool ralloc_asprintf_rewrite_tail(char **str, size_t start, * \param args A va_list containing the data to be formatted * * \p str will be updated to the new pointer unless allocation fails. + * \p start will be increased by the length of the newly formatted text. * * \return True unless allocation failed. */ -bool ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt, +bool ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt, va_list args); /** diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index 0f429ab22..3384d8a38 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -225,6 +225,16 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx, ctx->Pack.SwapBytes)) return GL_FALSE; + /* If the format is unsigned normalized then we can ignore clamping + * because the values are already in the range [0,1] so it won't + * have any effect anyway. + */ + if (_mesa_get_format_datatype(rb->Format) == GL_UNSIGNED_NORMALIZED) + transferOps &= ~IMAGE_CLAMP_BIT; + + if (transferOps) + return GL_FALSE; + dstStride = _mesa_image_row_stride(packing, width, format, type); dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, format, type, 0, 0); @@ -320,13 +330,11 @@ read_rgba_pixels( struct gl_context *ctx, transferOps |= IMAGE_CLAMP_BIT; } - if (!transferOps) { - /* Try the optimized paths first. */ - if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height, - format, type, pixels, packing, - transferOps)) { - return; - } + /* Try the optimized paths first. */ + if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height, + format, type, pixels, packing, + transferOps)) { + return; } slow_read_rgba_pixels(ctx, x, y, width, height, diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 9b6c6c896..5328ae296 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -69,8 +69,6 @@ * * This is the format which is used during texture application (i.e. the * texture format and env mode determine the arithmetic used. - * - * XXX this could be static */ GLint _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) @@ -830,7 +828,7 @@ _mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) struct gl_texture_image *texImage; GLuint texIndex; - if (level < 0 ) + if (level < 0) return NULL; switch (target) { diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index c0554cfc7..c4b2caccd 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -905,6 +905,7 @@ st_validate_varrays(struct gl_context *ctx, unsigned num_vbuffers, num_velements; GLuint attr; unsigned i; + unsigned old_num_user_attribs; /* must get these after state validation! */ vp = st->vp; @@ -913,9 +914,7 @@ st_validate_varrays(struct gl_context *ctx, memset(velements, 0, sizeof(struct pipe_vertex_element) * vpv->num_inputs); /* Unreference any user vertex buffers. */ - for (i = 0; i < st->num_user_attribs; i++) { - pipe_resource_reference(&st->user_attrib[i].buffer, NULL); - } + old_num_user_attribs = st->num_user_attribs; st->num_user_attribs = 0; /* @@ -954,6 +953,10 @@ st_validate_varrays(struct gl_context *ctx, assert(!vbuffer[attr].buffer); } + for (i = old_num_user_attribs; i < st->num_user_attribs; i++) { + pipe_resource_reference(&st->user_attrib[i].buffer, NULL); + } + return GL_TRUE; } diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h index bf925ab16..2d01d9823 100644 --- a/mesalib/src/mesa/vbo/vbo.h +++ b/mesalib/src/mesa/vbo/vbo.h @@ -123,8 +123,22 @@ void vbo_rebase_prims( struct gl_context *ctx, GLuint max_index, vbo_draw_func draw ); -int -vbo_sizeof_ib_type(GLenum type); +static inline int +vbo_sizeof_ib_type(GLenum type) +{ + switch (type) { + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + default: + assert(!"unsupported index data type"); + /* In case assert is turned off */ + return 0; + } +} void vbo_get_minmax_indices(struct gl_context *ctx, const struct _mesa_prim *prim, diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index 06e36a677..b0a4261e7 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -75,22 +75,6 @@ vbo_check_buffers_are_unmapped(struct gl_context *ctx) assert(!_mesa_bufferobj_mapped(exec->vtx.bufferobj)); } -int -vbo_sizeof_ib_type(GLenum type) -{ - switch (type) { - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - default: - assert(!"unsupported index data type"); - /* In case assert is turned off */ - return 0; - } -} /** |