diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 02:45:26 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 02:45:26 +0000 |
commit | ba99b2fec3460c36a2139c9c559de2f99370d21b (patch) | |
tree | db6471826518792b4f024433991e0a42d0904d63 | |
parent | a625fca3ccf6883911b0c86f5bfb8238228d3994 (diff) |
import Mesa 11.0.6
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/os/os_misc.c | 31 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/os/os_time.h | 4 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/util/u_debug.c | 442 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c | 88 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/radeon/r600_cs.h | 171 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/rbug/rbug_objects.c | 12 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/trace/Makefile.am | 2 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/trace/SConscript | 2 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/trace/tr_dump_defines.h | 2 |
9 files changed, 464 insertions, 290 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/os/os_misc.c b/lib/mesa/src/gallium/auxiliary/os/os_misc.c index 09d4400e0..c46078bb0 100644 --- a/lib/mesa/src/gallium/auxiliary/os/os_misc.c +++ b/lib/mesa/src/gallium/auxiliary/os/os_misc.c @@ -69,21 +69,10 @@ os_log_message(const char *message) static FILE *fout = NULL; if (!fout) { -#ifdef DEBUG /* one-time init */ const char *filename = os_get_option("GALLIUM_LOG_FILE"); - if (filename) { - const char *mode = "w"; - if (filename[0] == '+') { - /* If the filename is prefixed with '+' then open the file for - * appending instead of normal writing. - */ - mode = "a"; - filename++; /* skip the '+' */ - } - fout = fopen(filename, mode); - } -#endif + if (filename) + fout = fopen(filename, "w"); if (!fout) fout = stderr; } @@ -107,13 +96,11 @@ os_log_message(const char *message) } -#if !defined(PIPE_SUBSYSTEM_EMBEDDED) const char * os_get_option(const char *name) { return getenv(name); } -#endif /* !PIPE_SUBSYSTEM_EMBEDDED */ /** @@ -128,11 +115,8 @@ os_get_total_physical_memory(uint64_t *size) const long phys_pages = sysconf(_SC_PHYS_PAGES); const long page_size = sysconf(_SC_PAGE_SIZE); - if (phys_pages <= 0 || page_size <= 0) - return false; - - *size = (uint64_t)phys_pages * (uint64_t)page_size; - return true; + *size = phys_pages * page_size; + return (phys_pages > 0 && page_size > 0); #elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD) size_t len = sizeof(*size); int mib[2]; @@ -156,11 +140,8 @@ os_get_total_physical_memory(uint64_t *size) status_t ret; ret = get_system_info(&info); - if (ret != B_OK || info.max_pages <= 0) - return false; - - *size = (uint64_t)info.max_pages * (uint64_t)B_PAGE_SIZE; - return true; + *size = info.max_pages * B_PAGE_SIZE; + return (ret == B_OK); #elif defined(PIPE_OS_WINDOWS) MEMORYSTATUSEX status; BOOL ret; diff --git a/lib/mesa/src/gallium/auxiliary/os/os_time.h b/lib/mesa/src/gallium/auxiliary/os/os_time.h index ca0bdd5a0..9312e0288 100644 --- a/lib/mesa/src/gallium/auxiliary/os/os_time.h +++ b/lib/mesa/src/gallium/auxiliary/os/os_time.h @@ -70,8 +70,12 @@ os_time_get(void) /* * Sleep. */ +#if defined(PIPE_OS_UNIX) +#define os_time_sleep(_usecs) usleep(_usecs) +#else void os_time_sleep(int64_t usecs); +#endif /* diff --git a/lib/mesa/src/gallium/auxiliary/util/u_debug.c b/lib/mesa/src/gallium/auxiliary/util/u_debug.c index dd3e16791..5fe9e33e2 100644 --- a/lib/mesa/src/gallium/auxiliary/util/u_debug.c +++ b/lib/mesa/src/gallium/auxiliary/util/u_debug.c @@ -1,9 +1,9 @@ /************************************************************************** - * + * * Copyright 2008 VMware, Inc. * Copyright (c) 2008 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 @@ -11,11 +11,11 @@ * 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. @@ -23,22 +23,24 @@ * 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_config.h" +#include "pipe/p_config.h" #include "pipe/p_compiler.h" -#include "util/u_debug.h" -#include "pipe/p_format.h" -#include "pipe/p_state.h" -#include "util/u_inlines.h" +#include "util/u_debug.h" +#include "pipe/p_format.h" +#include "pipe/p_state.h" +#include "util/u_inlines.h" #include "util/u_format.h" -#include "util/u_memory.h" -#include "util/u_string.h" -#include "util/u_math.h" +#include "util/u_memory.h" +#include "util/u_string.h" +#include "util/u_math.h" +#include "util/u_tile.h" #include "util/u_prim.h" +#include "util/u_surface.h" #include <inttypes.h> #include <stdio.h> @@ -51,15 +53,14 @@ #endif -void -_debug_vprintf(const char *format, va_list ap) +void _debug_vprintf(const char *format, va_list ap) { static char buf[4096] = {'\0'}; #if defined(PIPE_OS_WINDOWS) || defined(PIPE_SUBSYSTEM_EMBEDDED) /* We buffer until we find a newline. */ size_t len = strlen(buf); int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap); - if (ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) { + if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) { os_log_message(buf); buf[0] = '\0'; } @@ -71,20 +72,6 @@ _debug_vprintf(const char *format, va_list ap) void -_pipe_debug_message(struct pipe_debug_callback *cb, - unsigned *id, - enum pipe_debug_type type, - const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - if (cb && cb->debug_message) - cb->debug_message(cb->data, id, type, fmt, args); - va_end(args); -} - - -void debug_disable_error_message_boxes(void) { #ifdef _WIN32 @@ -111,8 +98,9 @@ debug_disable_error_message_boxes(void) #ifdef DEBUG -void -debug_print_blob(const char *name, const void *blob, unsigned size) +void debug_print_blob( const char *name, + const void *blob, + unsigned size ) { const unsigned *ublob = (const unsigned *)blob; unsigned i; @@ -145,53 +133,49 @@ debug_get_option_should_print(void) return value; } - const char * debug_get_option(const char *name, const char *dfault) { const char *result; result = os_get_option(name); - if (!result) + if(!result) result = dfault; if (debug_get_option_should_print()) - debug_printf("%s: %s = %s\n", __FUNCTION__, name, - result ? result : "(null)"); - + debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? result : "(null)"); + return result; } - boolean debug_get_bool_option(const char *name, boolean dfault) { const char *str = os_get_option(name); boolean result; - - if (str == NULL) + + if(str == NULL) result = dfault; - else if (!util_strcmp(str, "n")) + else if(!util_strcmp(str, "n")) result = FALSE; - else if (!util_strcmp(str, "no")) + else if(!util_strcmp(str, "no")) result = FALSE; - else if (!util_strcmp(str, "0")) + else if(!util_strcmp(str, "0")) result = FALSE; - else if (!util_strcmp(str, "f")) + else if(!util_strcmp(str, "f")) result = FALSE; - else if (!util_strcmp(str, "F")) + else if(!util_strcmp(str, "F")) result = FALSE; - else if (!util_strcmp(str, "false")) + else if(!util_strcmp(str, "false")) result = FALSE; - else if (!util_strcmp(str, "FALSE")) + else if(!util_strcmp(str, "FALSE")) result = FALSE; else result = TRUE; if (debug_get_option_should_print()) - debug_printf("%s: %s = %s\n", __FUNCTION__, name, - result ? "TRUE" : "FALSE"); - + debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? "TRUE" : "FALSE"); + return result; } @@ -201,18 +185,27 @@ debug_get_num_option(const char *name, long dfault) { long result; const char *str; - + str = os_get_option(name); - if (!str) { + if(!str) result = dfault; - } else { - char *endptr; - - result = strtol(str, &endptr, 0); - if (str == endptr) { - /* Restore the default value when no digits were found. */ - result = dfault; + else { + long sign; + char c; + c = *str++; + if(c == '-') { + sign = -1; + c = *str++; + } + else { + sign = 1; + } + result = 0; + while('0' <= c && c <= '9') { + result = result*10 + (c - '0'); + c = *str++; } + result *= sign; } if (debug_get_option_should_print()) @@ -221,9 +214,7 @@ debug_get_num_option(const char *name, long dfault) return result; } - -static boolean -str_has_option(const char *str, const char *name) +static boolean str_has_option(const char *str, const char *name) { /* Empty string. */ if (!*str) { @@ -266,9 +257,8 @@ str_has_option(const char *str, const char *name) return FALSE; } - uint64_t -debug_get_flags_option(const char *name, +debug_get_flags_option(const char *name, const struct debug_named_value *flags, uint64_t dfault) { @@ -276,9 +266,9 @@ debug_get_flags_option(const char *name, const char *str; const struct debug_named_value *orig = flags; unsigned namealign = 0; - + str = os_get_option(name); - if (!str) + if(!str) result = dfault; else if (!util_strcmp(str, "help")) { result = dfault; @@ -286,13 +276,13 @@ debug_get_flags_option(const char *name, for (; flags->name; ++flags) namealign = MAX2(namealign, strlen(flags->name)); for (flags = orig; flags->name; ++flags) - _debug_printf("| %*s [0x%0*"PRIx64"]%s%s\n", namealign, flags->name, + _debug_printf("| %*s [0x%0*"PRIu64"]%s%s\n", namealign, flags->name, (int)sizeof(uint64_t)*CHAR_BIT/4, flags->value, flags->desc ? " " : "", flags->desc ? flags->desc : ""); } else { result = 0; - while (flags->name) { + while( flags->name ) { if (str_has_option(str, flags->name)) result |= flags->value; ++flags; @@ -301,10 +291,9 @@ debug_get_flags_option(const char *name, if (debug_get_option_should_print()) { if (str) { - debug_printf("%s: %s = 0x%"PRIx64" (%s)\n", - __FUNCTION__, name, result, str); + debug_printf("%s: %s = 0x%"PRIu64" (%s)\n", __FUNCTION__, name, result, str); } else { - debug_printf("%s: %s = 0x%"PRIx64"\n", __FUNCTION__, name, result); + debug_printf("%s: %s = 0x%"PRIu64"\n", __FUNCTION__, name, result); } } @@ -312,24 +301,24 @@ debug_get_flags_option(const char *name, } -void -_debug_assert_fail(const char *expr, const char *file, unsigned line, - const char *function) +void _debug_assert_fail(const char *expr, + const char *file, + unsigned line, + const char *function) { - _debug_printf("%s:%u:%s: Assertion `%s' failed.\n", - file, line, function, expr); + _debug_printf("%s:%u:%s: Assertion `%s' failed.\n", file, line, function, expr); os_abort(); } const char * -debug_dump_enum(const struct debug_named_value *names, +debug_dump_enum(const struct debug_named_value *names, unsigned long value) { static char rest[64]; - - while (names->name) { - if (names->value == value) + + while(names->name) { + if(names->value == value) return names->name; ++names; } @@ -340,14 +329,14 @@ debug_dump_enum(const struct debug_named_value *names, const char * -debug_dump_enum_noprefix(const struct debug_named_value *names, +debug_dump_enum_noprefix(const struct debug_named_value *names, const char *prefix, unsigned long value) { static char rest[64]; - - while (names->name) { - if (names->value == value) { + + while(names->name) { + if(names->value == value) { const char *name = names->name; while (*name == *prefix) { name++; @@ -358,13 +347,16 @@ debug_dump_enum_noprefix(const struct debug_named_value *names, ++names; } + + util_snprintf(rest, sizeof(rest), "0x%08lx", value); return rest; } const char * -debug_dump_flags(const struct debug_named_value *names, unsigned long value) +debug_dump_flags(const struct debug_named_value *names, + unsigned long value) { static char output[4096]; static char rest[256]; @@ -372,8 +364,8 @@ debug_dump_flags(const struct debug_named_value *names, unsigned long value) output[0] = '\0'; - while (names->name) { - if ((names->value & value) == names->value) { + while(names->name) { + if((names->value & value) == names->value) { if (!first) util_strncat(output, "|", sizeof(output) - strlen(output) - 1); else @@ -384,28 +376,27 @@ debug_dump_flags(const struct debug_named_value *names, unsigned long value) } ++names; } - + if (value) { if (!first) util_strncat(output, "|", sizeof(output) - strlen(output) - 1); else first = 0; - + util_snprintf(rest, sizeof(rest), "0x%08lx", value); util_strncat(output, rest, sizeof(output) - strlen(output) - 1); output[sizeof(output) - 1] = '\0'; } - - if (first) + + if(first) return "0"; - + return output; } #ifdef DEBUG -void -debug_print_format(const char *msg, unsigned fmt ) +void debug_print_format(const char *msg, unsigned fmt ) { debug_printf("%s: %s\n", msg, util_format_name(fmt)); } @@ -414,7 +405,7 @@ debug_print_format(const char *msg, unsigned fmt ) /** Return string name of given primitive type */ const char * -u_prim_name(enum pipe_prim_type prim) +u_prim_name(unsigned prim) { static const struct debug_named_value names[] = { DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS), @@ -442,8 +433,7 @@ u_prim_name(enum pipe_prim_type prim) int fl_indent = 0; const char* fl_function[1024]; -int -debug_funclog_enter(const char* f, const int line, const char* file) +int debug_funclog_enter(const char* f, const int line, const char* file) { int i; @@ -457,16 +447,14 @@ debug_funclog_enter(const char* f, const int line, const char* file) return 0; } -void -debug_funclog_exit(const char* f, const int line, const char* file) +void debug_funclog_exit(const char* f, const int line, const char* file) { --fl_indent; assert(fl_indent >= 0); assert(fl_function[fl_indent] == f); } -void -debug_funclog_enter_exit(const char* f, const int line, const char* file) +void debug_funclog_enter_exit(const char* f, const int line, const char* file) { int i; for (i = 0; i < fl_indent; i++) @@ -479,6 +467,254 @@ debug_funclog_enter_exit(const char* f, const int line, const char* file) #ifdef DEBUG /** + * Dump an image to .ppm file. + * \param format PIPE_FORMAT_x + * \param cpp bytes per pixel + * \param width width in pixels + * \param height height in pixels + * \param stride row stride in bytes + */ +void debug_dump_image(const char *prefix, + enum pipe_format format, unsigned cpp, + unsigned width, unsigned height, + unsigned stride, + const void *data) +{ + /* write a ppm file */ + char filename[256]; + unsigned char *rgb8; + FILE *f; + + util_snprintf(filename, sizeof(filename), "%s.ppm", prefix); + + rgb8 = MALLOC(height * width * 3); + if (!rgb8) { + return; + } + + util_format_translate( + PIPE_FORMAT_R8G8B8_UNORM, + rgb8, width * 3, + 0, 0, + format, + data, stride, + 0, 0, width, height); + + /* Must be opened in binary mode or DOS line ending causes data + * to be read with one byte offset. + */ + f = fopen(filename, "wb"); + if (f) { + fprintf(f, "P6\n"); + fprintf(f, "# ppm-file created by gallium\n"); + fprintf(f, "%i %i\n", width, height); + fprintf(f, "255\n"); + fwrite(rgb8, 1, height * width * 3, f); + fclose(f); + } + else { + fprintf(stderr, "Can't open %s for writing\n", filename); + } + + FREE(rgb8); +} + +/* FIXME: dump resources, not surfaces... */ +void debug_dump_surface(struct pipe_context *pipe, + const char *prefix, + struct pipe_surface *surface) +{ + struct pipe_resource *texture; + struct pipe_transfer *transfer; + void *data; + + if (!surface) + return; + + /* XXX: this doesn't necessarily work, as the driver may be using + * temporary storage for the surface which hasn't been propagated + * back into the texture. Need to nail down the semantics of views + * and transfers a bit better before we can say if extra work needs + * to be done here: + */ + texture = surface->texture; + + data = pipe_transfer_map(pipe, texture, surface->u.tex.level, + surface->u.tex.first_layer, + PIPE_TRANSFER_READ, + 0, 0, surface->width, surface->height, &transfer); + if(!data) + return; + + debug_dump_image(prefix, + texture->format, + util_format_get_blocksize(texture->format), + util_format_get_nblocksx(texture->format, surface->width), + util_format_get_nblocksy(texture->format, surface->height), + transfer->stride, + data); + + pipe->transfer_unmap(pipe, transfer); +} + + +void debug_dump_texture(struct pipe_context *pipe, + const char *prefix, + struct pipe_resource *texture) +{ + struct pipe_surface *surface, surf_tmpl; + + if (!texture) + return; + + /* XXX for now, just dump image for layer=0, level=0 */ + u_surface_default_template(&surf_tmpl, texture); + surface = pipe->create_surface(pipe, texture, &surf_tmpl); + if (surface) { + debug_dump_surface(pipe, prefix, surface); + pipe->surface_destroy(pipe, surface); + } +} + + +#pragma pack(push,2) +struct bmp_file_header { + uint16_t bfType; + uint32_t bfSize; + uint16_t bfReserved1; + uint16_t bfReserved2; + uint32_t bfOffBits; +}; +#pragma pack(pop) + +struct bmp_info_header { + uint32_t biSize; + int32_t biWidth; + int32_t biHeight; + uint16_t biPlanes; + uint16_t biBitCount; + uint32_t biCompression; + uint32_t biSizeImage; + int32_t biXPelsPerMeter; + int32_t biYPelsPerMeter; + uint32_t biClrUsed; + uint32_t biClrImportant; +}; + +struct bmp_rgb_quad { + uint8_t rgbBlue; + uint8_t rgbGreen; + uint8_t rgbRed; + uint8_t rgbAlpha; +}; + +void +debug_dump_surface_bmp(struct pipe_context *pipe, + const char *filename, + struct pipe_surface *surface) +{ + struct pipe_transfer *transfer; + struct pipe_resource *texture = surface->texture; + void *ptr; + + ptr = pipe_transfer_map(pipe, texture, surface->u.tex.level, + surface->u.tex.first_layer, PIPE_TRANSFER_READ, + 0, 0, surface->width, surface->height, &transfer); + + debug_dump_transfer_bmp(pipe, filename, transfer, ptr); + + pipe->transfer_unmap(pipe, transfer); +} + +void +debug_dump_transfer_bmp(struct pipe_context *pipe, + const char *filename, + struct pipe_transfer *transfer, void *ptr) +{ + float *rgba; + + if (!transfer) + goto error1; + + rgba = MALLOC(transfer->box.width * + transfer->box.height * + transfer->box.depth * + 4*sizeof(float)); + if(!rgba) + goto error1; + + pipe_get_tile_rgba(transfer, ptr, 0, 0, + transfer->box.width, transfer->box.height, + rgba); + + debug_dump_float_rgba_bmp(filename, + transfer->box.width, transfer->box.height, + rgba, transfer->box.width); + + FREE(rgba); +error1: + ; +} + +void +debug_dump_float_rgba_bmp(const char *filename, + unsigned width, unsigned height, + float *rgba, unsigned stride) +{ + FILE *stream; + struct bmp_file_header bmfh; + struct bmp_info_header bmih; + unsigned x, y; + + if(!rgba) + goto error1; + + bmfh.bfType = 0x4d42; + bmfh.bfSize = 14 + 40 + height*width*4; + bmfh.bfReserved1 = 0; + bmfh.bfReserved2 = 0; + bmfh.bfOffBits = 14 + 40; + + bmih.biSize = 40; + bmih.biWidth = width; + bmih.biHeight = height; + bmih.biPlanes = 1; + bmih.biBitCount = 32; + bmih.biCompression = 0; + bmih.biSizeImage = height*width*4; + bmih.biXPelsPerMeter = 0; + bmih.biYPelsPerMeter = 0; + bmih.biClrUsed = 0; + bmih.biClrImportant = 0; + + stream = fopen(filename, "wb"); + if(!stream) + goto error1; + + fwrite(&bmfh, 14, 1, stream); + fwrite(&bmih, 40, 1, stream); + + y = height; + while(y--) { + float *ptr = rgba + (stride * y * 4); + for(x = 0; x < width; ++x) + { + struct bmp_rgb_quad pixel; + pixel.rgbRed = float_to_ubyte(ptr[x*4 + 0]); + pixel.rgbGreen = float_to_ubyte(ptr[x*4 + 1]); + pixel.rgbBlue = float_to_ubyte(ptr[x*4 + 2]); + pixel.rgbAlpha = float_to_ubyte(ptr[x*4 + 3]); + fwrite(&pixel, 1, 4, stream); + } + } + + fclose(stream); +error1: + ; +} + + +/** * Print PIPE_TRANSFER_x flags with a message. */ void @@ -517,6 +753,8 @@ debug_print_bind_flags(const char *msg, unsigned usage) DEBUG_NAMED_VALUE(PIPE_BIND_INDEX_BUFFER), DEBUG_NAMED_VALUE(PIPE_BIND_CONSTANT_BUFFER), DEBUG_NAMED_VALUE(PIPE_BIND_DISPLAY_TARGET), + DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_WRITE), + DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_READ), DEBUG_NAMED_VALUE(PIPE_BIND_STREAM_OUTPUT), DEBUG_NAMED_VALUE(PIPE_BIND_CURSOR), DEBUG_NAMED_VALUE(PIPE_BIND_CUSTOM), @@ -539,7 +777,7 @@ debug_print_bind_flags(const char *msg, unsigned usage) * Print PIPE_USAGE_x enum values with a message. */ void -debug_print_usage_enum(const char *msg, enum pipe_resource_usage usage) +debug_print_usage_enum(const char *msg, unsigned usage) { static const struct debug_named_value names[] = { DEBUG_NAMED_VALUE(PIPE_USAGE_DEFAULT), diff --git a/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c b/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c index b781fa766..dc9e4626f 100644 --- a/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c +++ b/lib/mesa/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c @@ -28,8 +28,7 @@ */ #include "ir3_nir.h" -#include "compiler/nir/nir_builder.h" -#include "compiler/nir/nir_control_flow.h" +#include "glsl/nir/nir_builder.h" /* Based on nir_opt_peephole_select, and hacked up to more aggressively * flatten anything that can be flattened @@ -58,6 +57,12 @@ * then we should prefer to not flatten the if/else.. */ +struct lower_state { + nir_builder b; + void *mem_ctx; + bool progress; +}; + static bool valid_dest(nir_block *block, nir_dest *dest) { @@ -74,7 +79,7 @@ valid_dest(nir_block *block, nir_dest *dest) /* The only uses of this definition must be phi's in the * successor or in the current block */ - nir_foreach_use(use, &dest->ssa) { + nir_foreach_use(&dest->ssa, use) { nir_instr *dest_instr = use->parent_instr; if (dest_instr->block == block) continue; @@ -90,7 +95,7 @@ valid_dest(nir_block *block, nir_dest *dest) static bool block_check_for_allowed_instrs(nir_block *block) { - nir_foreach_instr(instr, block) { + nir_foreach_instr(block, instr) { switch (instr->type) { case nir_instr_type_intrinsic: { nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); @@ -159,14 +164,14 @@ static void flatten_block(nir_builder *bld, nir_block *if_block, nir_block *prev_block, nir_ssa_def *condition, bool invert) { - nir_foreach_instr_safe(instr, if_block) { + nir_foreach_instr_safe(if_block, instr) { if (instr->type == nir_instr_type_intrinsic) { nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); if ((intr->intrinsic == nir_intrinsic_discard) || (intr->intrinsic == nir_intrinsic_discard_if)) { nir_ssa_def *discard_cond; - bld->cursor = nir_after_instr( + nir_builder_insert_after_instr(bld, nir_block_last_instr(prev_block)); if (invert) { @@ -207,39 +212,44 @@ flatten_block(nir_builder *bld, nir_block *if_block, nir_block *prev_block, } static bool -lower_if_else_block(nir_block *block, nir_builder *b, void *mem_ctx) +lower_if_else_block(nir_block *block, void *void_state) { + struct lower_state *state = void_state; + /* If the block is empty, then it certainly doesn't have any phi nodes, * so we can skip it. This also ensures that we do an early skip on the * end block of the function which isn't actually attached to the CFG. */ if (exec_list_is_empty(&block->instr_list)) - return false; + return true; if (nir_cf_node_is_first(&block->cf_node)) - return false; + return true; nir_cf_node *prev_node = nir_cf_node_prev(&block->cf_node); if (prev_node->type != nir_cf_node_if) - return false; + return true; nir_if *if_stmt = nir_cf_node_as_if(prev_node); - nir_block *then_block = nir_if_first_then_block(if_stmt); - nir_block *else_block = nir_if_first_else_block(if_stmt); + nir_cf_node *then_node = nir_if_first_then_node(if_stmt); + nir_cf_node *else_node = nir_if_first_else_node(if_stmt); /* We can only have one block in each side ... */ - if (nir_if_last_then_block(if_stmt) != then_block || - nir_if_last_else_block(if_stmt) != else_block) - return false; + if (nir_if_last_then_node(if_stmt) != then_node || + nir_if_last_else_node(if_stmt) != else_node) + return true; + + nir_block *then_block = nir_cf_node_as_block(then_node); + nir_block *else_block = nir_cf_node_as_block(else_node); /* ... and those blocks must only contain "allowed" instructions. */ if (!block_check_for_allowed_instrs(then_block) || !block_check_for_allowed_instrs(else_block)) - return false; + return true; /* condition should be ssa too, which simplifies flatten_block: */ if (!if_stmt->condition.is_ssa) - return false; + return true; /* At this point, we know that the previous CFG node is an if-then * statement containing only moves to phi nodes in this block. We can @@ -254,61 +264,63 @@ lower_if_else_block(nir_block *block, nir_builder *b, void *mem_ctx) * block before. There are a few things that need handling specially * like discard/discard_if. */ - flatten_block(b, then_block, prev_block, + flatten_block(&state->b, then_block, prev_block, if_stmt->condition.ssa, false); - flatten_block(b, else_block, prev_block, + flatten_block(&state->b, else_block, prev_block, if_stmt->condition.ssa, true); - nir_foreach_instr_safe(instr, block) { + nir_foreach_instr_safe(block, instr) { if (instr->type != nir_instr_type_phi) break; nir_phi_instr *phi = nir_instr_as_phi(instr); - nir_alu_instr *sel = nir_alu_instr_create(mem_ctx, nir_op_bcsel); - nir_src_copy(&sel->src[0].src, &if_stmt->condition, mem_ctx); + nir_alu_instr *sel = nir_alu_instr_create(state->mem_ctx, nir_op_bcsel); + nir_src_copy(&sel->src[0].src, &if_stmt->condition, state->mem_ctx); /* Splat the condition to all channels */ memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle); assert(exec_list_length(&phi->srcs) == 2); - nir_foreach_phi_src(src, phi) { + nir_foreach_phi_src(phi, src) { assert(src->pred == then_block || src->pred == else_block); assert(src->src.is_ssa); unsigned idx = src->pred == then_block ? 1 : 2; - nir_src_copy(&sel->src[idx].src, &src->src, mem_ctx); + nir_src_copy(&sel->src[idx].src, &src->src, state->mem_ctx); } nir_ssa_dest_init(&sel->instr, &sel->dest.dest, - phi->dest.ssa.num_components, 32, phi->dest.ssa.name); + phi->dest.ssa.num_components, phi->dest.ssa.name); sel->dest.write_mask = (1 << phi->dest.ssa.num_components) - 1; nir_ssa_def_rewrite_uses(&phi->dest.ssa, - nir_src_for_ssa(&sel->dest.dest.ssa)); + nir_src_for_ssa(&sel->dest.dest.ssa), + state->mem_ctx); nir_instr_insert_before(&phi->instr, &sel->instr); nir_instr_remove(&phi->instr); } nir_cf_node_remove(&if_stmt->cf_node); + state->progress = true; + return true; } static bool lower_if_else_impl(nir_function_impl *impl) { - void *mem_ctx = ralloc_parent(impl); - nir_builder b; - nir_builder_init(&b, impl); + struct lower_state state; - bool progress = false; - nir_foreach_block_safe(block, impl) { - progress |= lower_if_else_block(block, &b, mem_ctx); - } + state.mem_ctx = ralloc_parent(impl); + state.progress = false; + nir_builder_init(&state.b, impl); - if (progress) + nir_foreach_block(impl, lower_if_else_block, &state); + + if (state.progress) nir_metadata_preserve(impl, nir_metadata_none); - return progress; + return state.progress; } bool @@ -316,9 +328,9 @@ ir3_nir_lower_if_else(nir_shader *shader) { bool progress = false; - nir_foreach_function(function, shader) { - if (function->impl) - progress |= lower_if_else_impl(function->impl); + nir_foreach_overload(shader, overload) { + if (overload->impl) + progress |= lower_if_else_impl(overload->impl); } return progress; diff --git a/lib/mesa/src/gallium/drivers/radeon/r600_cs.h b/lib/mesa/src/gallium/drivers/radeon/r600_cs.h index 5bfce1ca7..03a04b754 100644 --- a/lib/mesa/src/gallium/drivers/radeon/r600_cs.h +++ b/lib/mesa/src/gallium/drivers/radeon/r600_cs.h @@ -31,163 +31,102 @@ #define R600_CS_H #include "r600_pipe_common.h" -#include "amd/common/sid.h" +#include "r600d_common.h" -/** - * Return true if there is enough memory in VRAM and GTT for the buffers - * added so far. - * - * \param vram VRAM memory size not added to the buffer list yet - * \param gtt GTT memory size not added to the buffer list yet - */ -static inline bool -radeon_cs_memory_below_limit(struct r600_common_screen *screen, - struct radeon_winsys_cs *cs, - uint64_t vram, uint64_t gtt) -{ - vram += cs->used_vram; - gtt += cs->used_gart; - - /* Anything that goes above the VRAM size should go to GTT. */ - if (vram > screen->info.vram_size) - gtt += vram - screen->info.vram_size; - - /* Now we just need to check if we have enough GTT. */ - return gtt < screen->info.gart_size * 0.7; -} - -/** - * Add a buffer to the buffer list for the given command stream (CS). - * - * All buffers used by a CS must be added to the list. This tells the kernel - * driver which buffers are used by GPU commands. Other buffers can - * be swapped out (not accessible) during execution. - * - * The buffer list becomes empty after every context flush and must be - * rebuilt. - */ -static inline unsigned radeon_add_to_buffer_list(struct r600_common_context *rctx, - struct r600_ring *ring, - struct r600_resource *rbo, - enum radeon_bo_usage usage, - enum radeon_bo_priority priority) +static inline unsigned r600_context_bo_reloc(struct r600_common_context *rctx, + struct r600_ring *ring, + struct r600_resource *rbo, + enum radeon_bo_usage usage, + enum radeon_bo_priority priority) { assert(usage); - return rctx->ws->cs_add_buffer( - ring->cs, rbo->buf, - (enum radeon_bo_usage)(usage | RADEON_USAGE_SYNCHRONIZED), - rbo->domains, priority) * 4; + + /* Make sure that all previous rings are flushed so that everything + * looks serialized from the driver point of view. + */ + if (!ring->flushing) { + if (ring == &rctx->rings.gfx) { + if (rctx->rings.dma.cs) { + /* flush dma ring */ + rctx->rings.dma.flush(rctx, RADEON_FLUSH_ASYNC, NULL); + } + } else { + /* flush gfx ring */ + rctx->rings.gfx.flush(rctx, RADEON_FLUSH_ASYNC, NULL); + } + } + return rctx->ws->cs_add_reloc(ring->cs, rbo->cs_buf, usage, + rbo->domains, priority) * 4; } -/** - * Same as above, but also checks memory usage and flushes the context - * accordingly. - * - * When this SHOULD NOT be used: - * - * - if r600_context_add_resource_size has been called for the buffer - * followed by *_need_cs_space for checking the memory usage - * - * - if r600_need_dma_space has been called for the buffer - * - * - when emitting state packets and draw packets (because preceding packets - * can't be re-emitted at that point) - * - * - if shader resource "enabled_mask" is not up-to-date or there is - * a different constraint disallowing a context flush - */ -static inline unsigned -radeon_add_to_buffer_list_check_mem(struct r600_common_context *rctx, - struct r600_ring *ring, - struct r600_resource *rbo, - enum radeon_bo_usage usage, - enum radeon_bo_priority priority, - bool check_mem) +static inline void r600_emit_reloc(struct r600_common_context *rctx, + struct r600_ring *ring, struct r600_resource *rbo, + enum radeon_bo_usage usage, + enum radeon_bo_priority priority) { - if (check_mem && - !radeon_cs_memory_below_limit(rctx->screen, ring->cs, - rctx->vram + rbo->vram_usage, - rctx->gtt + rbo->gart_usage)) - ring->flush(rctx, RADEON_FLUSH_ASYNC, NULL); - - return radeon_add_to_buffer_list(rctx, ring, rbo, usage, priority); + struct radeon_winsys_cs *cs = ring->cs; + bool has_vm = ((struct r600_common_screen*)rctx->b.screen)->info.r600_virtual_address; + unsigned reloc = r600_context_bo_reloc(rctx, ring, rbo, usage, priority); + + if (!has_vm) { + radeon_emit(cs, PKT3(PKT3_NOP, 0, 0)); + radeon_emit(cs, reloc); + } } -static inline void radeon_set_config_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) +static inline void r600_write_config_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) { - assert(reg < SI_CONTEXT_REG_OFFSET); - assert(cs->current.cdw + 2 + num <= cs->current.max_dw); + assert(reg < R600_CONTEXT_REG_OFFSET); + assert(cs->cdw+2+num <= cs->max_dw); radeon_emit(cs, PKT3(PKT3_SET_CONFIG_REG, num, 0)); - radeon_emit(cs, (reg - SI_CONFIG_REG_OFFSET) >> 2); + radeon_emit(cs, (reg - R600_CONFIG_REG_OFFSET) >> 2); } -static inline void radeon_set_config_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) +static inline void r600_write_config_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) { - radeon_set_config_reg_seq(cs, reg, 1); + r600_write_config_reg_seq(cs, reg, 1); radeon_emit(cs, value); } -static inline void radeon_set_context_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) +static inline void r600_write_context_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) { - assert(reg >= SI_CONTEXT_REG_OFFSET); - assert(cs->current.cdw + 2 + num <= cs->current.max_dw); + assert(reg >= R600_CONTEXT_REG_OFFSET); + assert(cs->cdw+2+num <= cs->max_dw); radeon_emit(cs, PKT3(PKT3_SET_CONTEXT_REG, num, 0)); - radeon_emit(cs, (reg - SI_CONTEXT_REG_OFFSET) >> 2); + radeon_emit(cs, (reg - R600_CONTEXT_REG_OFFSET) >> 2); } -static inline void radeon_set_context_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) +static inline void r600_write_context_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) { - radeon_set_context_reg_seq(cs, reg, 1); + r600_write_context_reg_seq(cs, reg, 1); radeon_emit(cs, value); } -static inline void radeon_set_context_reg_idx(struct radeon_winsys_cs *cs, - unsigned reg, unsigned idx, - unsigned value) -{ - assert(reg >= SI_CONTEXT_REG_OFFSET); - assert(cs->current.cdw + 3 <= cs->current.max_dw); - radeon_emit(cs, PKT3(PKT3_SET_CONTEXT_REG, 1, 0)); - radeon_emit(cs, (reg - SI_CONTEXT_REG_OFFSET) >> 2 | (idx << 28)); - radeon_emit(cs, value); -} - -static inline void radeon_set_sh_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) +static inline void si_write_sh_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) { assert(reg >= SI_SH_REG_OFFSET && reg < SI_SH_REG_END); - assert(cs->current.cdw + 2 + num <= cs->current.max_dw); + assert(cs->cdw+2+num <= cs->max_dw); radeon_emit(cs, PKT3(PKT3_SET_SH_REG, num, 0)); radeon_emit(cs, (reg - SI_SH_REG_OFFSET) >> 2); } -static inline void radeon_set_sh_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) +static inline void si_write_sh_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) { - radeon_set_sh_reg_seq(cs, reg, 1); + si_write_sh_reg_seq(cs, reg, 1); radeon_emit(cs, value); } -static inline void radeon_set_uconfig_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) +static inline void cik_write_uconfig_reg_seq(struct radeon_winsys_cs *cs, unsigned reg, unsigned num) { assert(reg >= CIK_UCONFIG_REG_OFFSET && reg < CIK_UCONFIG_REG_END); - assert(cs->current.cdw + 2 + num <= cs->current.max_dw); + assert(cs->cdw+2+num <= cs->max_dw); radeon_emit(cs, PKT3(PKT3_SET_UCONFIG_REG, num, 0)); radeon_emit(cs, (reg - CIK_UCONFIG_REG_OFFSET) >> 2); } -static inline void radeon_set_uconfig_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) +static inline void cik_write_uconfig_reg(struct radeon_winsys_cs *cs, unsigned reg, unsigned value) { - radeon_set_uconfig_reg_seq(cs, reg, 1); - radeon_emit(cs, value); -} - -static inline void radeon_set_uconfig_reg_idx(struct radeon_winsys_cs *cs, - unsigned reg, unsigned idx, - unsigned value) -{ - assert(reg >= CIK_UCONFIG_REG_OFFSET && reg < CIK_UCONFIG_REG_END); - assert(cs->current.cdw + 3 <= cs->current.max_dw); - radeon_emit(cs, PKT3(PKT3_SET_UCONFIG_REG, 1, 0)); - radeon_emit(cs, (reg - CIK_UCONFIG_REG_OFFSET) >> 2 | (idx << 28)); + cik_write_uconfig_reg_seq(cs, reg, 1); radeon_emit(cs, value); } diff --git a/lib/mesa/src/gallium/drivers/rbug/rbug_objects.c b/lib/mesa/src/gallium/drivers/rbug/rbug_objects.c index 2aa4e123f..25d55a383 100644 --- a/lib/mesa/src/gallium/drivers/rbug/rbug_objects.c +++ b/lib/mesa/src/gallium/drivers/rbug/rbug_objects.c @@ -43,13 +43,13 @@ rbug_resource_create(struct rbug_screen *rb_screen, { struct rbug_resource *rb_resource; - if (!resource) + if(!resource) goto error; assert(resource->screen == rb_screen->screen); rb_resource = CALLOC_STRUCT(rbug_resource); - if (!rb_resource) + if(!rb_resource) goto error; memcpy(&rb_resource->base, resource, sizeof(struct pipe_resource)); @@ -88,13 +88,13 @@ rbug_surface_create(struct rbug_context *rb_context, { struct rbug_surface *rb_surface; - if (!surface) + if(!surface) goto error; assert(surface->texture == rb_resource->resource); rb_surface = CALLOC_STRUCT(rbug_surface); - if (!rb_surface) + if(!rb_surface) goto error; memcpy(&rb_surface->base, surface, sizeof(struct pipe_surface)); @@ -165,13 +165,13 @@ rbug_transfer_create(struct rbug_context *rb_context, { struct rbug_transfer *rb_transfer; - if (!transfer) + if(!transfer) goto error; assert(transfer->resource == rb_resource->resource); rb_transfer = CALLOC_STRUCT(rbug_transfer); - if (!rb_transfer) + if(!rb_transfer) goto error; memcpy(&rb_transfer->base, transfer, sizeof(struct pipe_transfer)); diff --git a/lib/mesa/src/gallium/drivers/trace/Makefile.am b/lib/mesa/src/gallium/drivers/trace/Makefile.am index 564019233..6a8a74a91 100644 --- a/lib/mesa/src/gallium/drivers/trace/Makefile.am +++ b/lib/mesa/src/gallium/drivers/trace/Makefile.am @@ -3,7 +3,7 @@ include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ $(GALLIUM_DRIVER_CFLAGS) \ - $(MSVC2013_COMPAT_CFLAGS) + $(MSVC2008_COMPAT_CFLAGS) noinst_LTLIBRARIES = libtrace.la diff --git a/lib/mesa/src/gallium/drivers/trace/SConscript b/lib/mesa/src/gallium/drivers/trace/SConscript index 739798364..1bbed7390 100644 --- a/lib/mesa/src/gallium/drivers/trace/SConscript +++ b/lib/mesa/src/gallium/drivers/trace/SConscript @@ -2,7 +2,7 @@ Import('*') env = env.Clone() -env.MSVC2013Compat() +env.MSVC2008Compat() trace = env.ConvenienceLibrary( target = 'trace', diff --git a/lib/mesa/src/gallium/drivers/trace/tr_dump_defines.h b/lib/mesa/src/gallium/drivers/trace/tr_dump_defines.h index 7f969a303..b38d63eac 100644 --- a/lib/mesa/src/gallium/drivers/trace/tr_dump_defines.h +++ b/lib/mesa/src/gallium/drivers/trace/tr_dump_defines.h @@ -50,7 +50,7 @@ trace_dump_query_type(unsigned value) if (!trace_dumping_enabled_locked()) return; - trace_dump_enum(util_str_query_type(value, FALSE)); + trace_dump_enum(util_dump_query_type(value, FALSE)); } |