From 95ce6474f46e86d5511117cc5bbb2702b2469f5c Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 15 Dec 2008 12:29:34 +0100 Subject: gallium: Fix PIPE_FORMAT_X8B8G8R8_SNORM definition. --- src/gallium/include/pipe/p_format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 97a4c8c510..546cf5d9b4 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -348,7 +348,7 @@ enum pipe_format { PIPE_FORMAT_R8G8B8X8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ), PIPE_FORMAT_B6G5R5_SNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_BGR1, 6, 5, 5, 0, PIPE_FORMAT_TYPE_SNORM ), PIPE_FORMAT_A8B8G8R8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGRA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ), - PIPE_FORMAT_X8B8G8R8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ), + PIPE_FORMAT_X8B8G8R8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGR1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ), PIPE_FORMAT_R8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ), PIPE_FORMAT_R8G8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SSCALED ), PIPE_FORMAT_R8G8B8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SSCALED ), -- cgit v1.2.3 From 2a299851b9ee06fafc03cf4dc7d26023bac17f69 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 10:55:29 -0700 Subject: winsys: fix depth buffer size when using stencil --- src/gallium/winsys/xlib/fakeglx.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/gallium/winsys/xlib/fakeglx.c b/src/gallium/winsys/xlib/fakeglx.c index a56e63572a..fd2d222c85 100644 --- a/src/gallium/winsys/xlib/fakeglx.c +++ b/src/gallium/winsys/xlib/fakeglx.c @@ -304,6 +304,9 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, return NULL; } + if (stencil_size > 0 && depth_size > 0) + depth_size = 24; + /* Comparing IDs uses less memory but sometimes fails. */ /* XXX revisit this after 3.0 is finished. */ if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) -- cgit v1.2.3 From cdaaf8e107010624bed4abdf9553c0ef63c8b708 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 10:55:40 -0700 Subject: mesa: fix vertex program test in get_fp_input_mask() We were accidentally using the fixed-function logic when a vertex shader was being used. --- src/mesa/main/texenvprogram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index c279956f2a..b99bcb1774 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -215,9 +215,7 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx ) else if (ctx->RenderMode == GL_FEEDBACK) { fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0); } - else if (!ctx->VertexProgram._Enabled || - !ctx->VertexProgram._Current) { - + else if (!ctx->VertexProgram._Current) { /* Fixed function logic */ GLbitfield varying_inputs = ctx->varying_vp_inputs; -- cgit v1.2.3 From a8751f49167df81611390377aa3e84aba1ed3ae3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 11:29:42 -0700 Subject: Revert "mesa: fix vertex program test in get_fp_input_mask()" This reverts commit cdaaf8e107010624bed4abdf9553c0ef63c8b708. --- src/mesa/main/texenvprogram.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index b99bcb1774..c279956f2a 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -215,7 +215,9 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx ) else if (ctx->RenderMode == GL_FEEDBACK) { fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0); } - else if (!ctx->VertexProgram._Current) { + else if (!ctx->VertexProgram._Enabled || + !ctx->VertexProgram._Current) { + /* Fixed function logic */ GLbitfield varying_inputs = ctx->varying_vp_inputs; -- cgit v1.2.3 From 35bb2aa96a2499860869c0d307b599b3033b5264 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 13:17:15 -0700 Subject: mesa: add missing cases for texture array targets --- src/mesa/main/texenvprogram.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index c279956f2a..0294c107b2 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -179,13 +179,17 @@ static GLuint translate_mode( GLenum mode ) #define TEXTURE_UNKNOWN_INDEX 7 static GLuint translate_tex_src_bit( GLbitfield bit ) { + /* make sure number of switch cases is correct */ + assert(NUM_TEXTURE_TARGETS == 7); switch (bit) { - case TEXTURE_1D_BIT: return TEXTURE_1D_INDEX; - case TEXTURE_2D_BIT: return TEXTURE_2D_INDEX; - case TEXTURE_RECT_BIT: return TEXTURE_RECT_INDEX; - case TEXTURE_3D_BIT: return TEXTURE_3D_INDEX; - case TEXTURE_CUBE_BIT: return TEXTURE_CUBE_INDEX; - default: return TEXTURE_UNKNOWN_INDEX; + case TEXTURE_1D_BIT: return TEXTURE_1D_INDEX; + case TEXTURE_2D_BIT: return TEXTURE_2D_INDEX; + case TEXTURE_3D_BIT: return TEXTURE_3D_INDEX; + case TEXTURE_CUBE_BIT: return TEXTURE_CUBE_INDEX; + case TEXTURE_RECT_BIT: return TEXTURE_RECT_INDEX; + case TEXTURE_1D_ARRAY_BIT: return TEXTURE_1D_ARRAY_INDEX; + case TEXTURE_2D_ARRAY_BIT: return TEXTURE_2D_ARRAY_INDEX; + default: return TEXTURE_UNKNOWN_INDEX; } } -- cgit v1.2.3 From 947d04d08bead28c43f525ea4c1d99a039bed047 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 14:04:03 -0700 Subject: mesa: fix fixed-function test in get_fp_input_mask() - again. The problem we're solving only occured when there was a user-defined vertex shader but no fragment shader. Check for that case now. Fixes glean api2 vertex array failure. --- src/mesa/main/texenvprogram.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 0294c107b2..75f5baa3e1 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -207,6 +207,9 @@ static GLuint translate_tex_src_bit( GLbitfield bit ) */ static GLbitfield get_fp_input_mask( GLcontext *ctx ) { + const GLboolean vertexShader = (ctx->Shader.CurrentProgram && + ctx->Shader.CurrentProgram->VertexProgram); + const GLboolean vertexProgram = ctx->VertexProgram._Enabled; GLbitfield fp_inputs = 0x0; if (ctx->VertexProgram._Overriden) { @@ -219,10 +222,9 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx ) else if (ctx->RenderMode == GL_FEEDBACK) { fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0); } - else if (!ctx->VertexProgram._Enabled || + else if (!(vertexProgram || vertexShader) || !ctx->VertexProgram._Current) { - - /* Fixed function logic */ + /* Fixed function vertex logic */ GLbitfield varying_inputs = ctx->varying_vp_inputs; /* These get generated in the setup routine regardless of the -- cgit v1.2.3 From b890fffbf4ad435ef533988d288e98b0bfe4d17b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 18:52:10 -0700 Subject: gallium: fix memory corruption in u_gen_mipmap.c Remove the old/initial vbuf allocation in util_create_gen_mipmap(). We were allocating a small vbuf at this point so get_next_slot() didn't have as large of buffer as it expected. So all but the first set_vertex_data() was writing out of bounds. Also added some comments. --- src/gallium/auxiliary/util/u_gen_mipmap.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 5f395ec6e9..5afc52ba35 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -760,15 +760,6 @@ util_create_gen_mipmap(struct pipe_context *pipe, /* fragment shader */ ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader); - ctx->vbuf = pipe_buffer_create(pipe->screen, - 32, - PIPE_BUFFER_USAGE_VERTEX, - sizeof(ctx->vertices)); - if (!ctx->vbuf) { - FREE(ctx); - return NULL; - } - /* vertex data that doesn't change */ for (i = 0; i < 4; i++) { ctx->vertices[i][0][2] = 0.0f; /* z */ @@ -777,11 +768,18 @@ util_create_gen_mipmap(struct pipe_context *pipe, ctx->vertices[i][1][3] = 1.0f; /* q */ } + /* Note: the actual vertex buffer is allocated as needed below */ + return ctx; } -static unsigned get_next_slot( struct gen_mipmap_state *ctx ) +/** + * Get next "slot" of vertex space in the vertex buffer. + * We're allocating one large vertex buffer and using it piece by piece. + */ +static unsigned +get_next_slot(struct gen_mipmap_state *ctx) { const unsigned max_slots = 4096 / sizeof ctx->vertices; @@ -798,6 +796,7 @@ static unsigned get_next_slot( struct gen_mipmap_state *ctx ) return ctx->vbuf_slot++ * sizeof ctx->vertices; } + static unsigned set_vertex_data(struct gen_mipmap_state *ctx, float width, float height) { -- cgit v1.2.3 From f9c76750a7687e9902f2efd91d5551ae0128003c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 19:01:34 -0700 Subject: mesa: choose GLSL vertex shader over ARB/internal vertex program in get_fp_input_mask() This is a work-around the for the fact that we do fragment shader state validation before vertex shader validation (see comments in state.c) so in get_fp_input_mask() we can't rely on ctx->VertexProgram._Current being up to date yet. This fixes a glean glsl1 test failure. --- src/mesa/main/texenvprogram.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 75f5baa3e1..64b2ab6c13 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -258,7 +258,19 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx ) } else { /* calculate from vp->outputs */ - GLbitfield vp_outputs = ctx->VertexProgram._Current->Base.OutputsWritten; + struct gl_vertex_program *vprog; + GLbitfield vp_outputs; + + /* Choose GLSL vertex shader over ARB vertex program. Need this + * since vertex shader state validation comes after fragment state + * validation (see additional comments in state.c). + */ + if (vertexShader) + vprog = ctx->Shader.CurrentProgram->VertexProgram; + else + vprog = ctx->VertexProgram._Current; + + vp_outputs = vprog->Base.OutputsWritten; /* These get generated in the setup routine regardless of the * vertex program: -- cgit v1.2.3 From 92dc8ffa719276fe536abf4dcf7874cf12588f60 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Dec 2008 14:53:24 +0000 Subject: gallium: Enable memory debugging on all windows platforms. --- src/gallium/auxiliary/util/u_memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h index 857102719d..bcae10832a 100644 --- a/src/gallium/auxiliary/util/u_memory.h +++ b/src/gallium/auxiliary/util/u_memory.h @@ -52,7 +52,7 @@ extern "C" { #endif -#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG) +#if defined(PIPE_SUBSYSTEM_WINDOWS) && defined(DEBUG) /* memory debugging */ -- cgit v1.2.3 From a402d48f840f1d51eb46dc15a047589e2b8ca431 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 7 Oct 2008 18:47:31 -0700 Subject: mesa: Pass the context to query object delete cb to avoid null dereference. --- src/mesa/main/queryobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 2d06030030..e3ba7b6ff7 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -546,6 +546,6 @@ delete_queryobj_cb(GLuint id, void *data, void *userData) void _mesa_free_query_data(GLcontext *ctx) { - _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, NULL); + _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx); _mesa_DeleteHashTable(ctx->Query.QueryObjects); } -- cgit v1.2.3 From 97d08366aa2a56705d32806845134cb4b5edbff0 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 18 Dec 2008 18:45:32 +0100 Subject: glsl: Fix handling of nested parens in macro actual arguments. --- src/mesa/shader/slang/slang_preprocess.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index 786f6467c9..7d971627f5 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -641,8 +641,10 @@ expand_symbol (expand_state *e, pp_symbol *symbol) SKIP_WHITE(e->input); /* Parse macro actual parameters. This can be anything, separated by a colon. - * TODO: What about nested/grouped parameters by parenthesis? */ + */ for (i = 0; i < symbol->parameters.count; i++) { + GLuint nested_paren_count = 0; /* track number of nested parentheses */ + if (*e->input == ')') { slang_info_log_error (e->state->elog, "preprocess error: unexpected ')'."); return GL_FALSE; @@ -650,8 +652,19 @@ expand_symbol (expand_state *e, pp_symbol *symbol) /* Eat all characters up to the comma or closing parentheses. */ pp_symbol_reset (&symbol->parameters.symbols[i]); - while (!IS_NULL(*e->input) && *e->input != ',' && *e->input != ')') + while (!IS_NULL(*e->input)) { + /* Exit loop only when all nested parens have been eaten. */ + if (nested_paren_count == 0 && (*e->input == ',' || *e->input == ')')) + break; + + /* Actually count nested parens here. */ + if (*e->input == '(') + nested_paren_count++; + else if (*e->input == ')') + nested_paren_count--; + slang_string_pushc (&symbol->parameters.symbols[i].replacement, *e->input++); + } /* If it was not the last paremeter, skip the comma. Otherwise, skip the * closing parentheses. */ -- cgit v1.2.3 From 36c7bb697d47560e2bf4798db11afd7f1751abef Mon Sep 17 00:00:00 2001 From: Robert Ellison Date: Thu, 18 Dec 2008 09:46:53 -0700 Subject: Gallium: fix for conform test The following construction in util_surface_copy() in gallium/auxiliary/util/u_rect.c, introduced in commit d177c9ddda2c452cf7d6696d89cf4458ef986f98, incorrectly inverts the Y coordinate in the last parameter to pipe_copy_rect(). /* If do_flip, invert src_y position and pass negative src stride */ pipe_copy_rect(dst_map, &dst->block, dst->stride, dst_x, dst_y, w, h, src_map, do_flip ? -(int) src->stride : src->stride, src_x, do_flip ? w - src_y : src_y); The intention is to start at the last Y coordinate line and move backwards, in the case of a flip; in that case, the correct calculation is "src_y + h - 1", not "w - src_y". This fixes a Gallium assertion failure in the conformance tests: u_rect.c:65:pipe_copy_rect: Assertion `src_y >= 0' failed. debug_get_bool_option: GALLIUM_ABORT_ON_ASSERT = TRUE Trace/breakpoint trap --- src/gallium/auxiliary/util/u_rect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c index 30f32413d7..fe81a685be 100644 --- a/src/gallium/auxiliary/util/u_rect.c +++ b/src/gallium/auxiliary/util/u_rect.c @@ -223,7 +223,7 @@ util_surface_copy(struct pipe_context *pipe, src_map, do_flip ? -(int) src->stride : src->stride, src_x, - do_flip ? w - src_y : src_y); + do_flip ? src_y + h - 1 : src_y); } pipe->screen->surface_unmap(pipe->screen, src); -- cgit v1.2.3 From 78a204f507f966d12ecd3931a51a85763c66ddb3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Dec 2008 16:00:20 -0700 Subject: gallium: fix two-sided lighting test in state tracker This fixes two-sided lighting for vertex shaders. --- src/mesa/state_tracker/st_atom_rasterizer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 5eef4ebe92..ea76487bcf 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -107,12 +107,15 @@ static void update_raster_state( struct st_context *st ) /* _NEW_LIGHT | _NEW_PROGRAM * * Back-face colors can come from traditional lighting (when - * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs (when + * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs/shaders (when * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. */ if (ctx->VertexProgram._Current) { - if (ctx->VertexProgram._Enabled) { - /* user-defined program */ + if (ctx->VertexProgram._Enabled || + (ctx->Shader.CurrentProgram && + ctx->Shader.CurrentProgram->VertexProgram && + ctx->Shader.CurrentProgram->LinkStatus)) { + /* user-defined vertex program or shader */ raster->light_twoside = ctx->VertexProgram.TwoSideEnabled; } else { -- cgit v1.2.3 From 59a168d5c9b5f478e4e8bedcd8522e359e98987e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Dec 2008 18:06:38 -0700 Subject: tgsi: scan for additional info: uses_fogcoord, uses_frontfacing --- src/gallium/auxiliary/tgsi/tgsi_scan.c | 49 ++++++++++++++++++++++++---------- src/gallium/auxiliary/tgsi/tgsi_scan.h | 3 ++- 2 files changed, 37 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c index be4870a498..cfc7ea8e89 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c @@ -2,6 +2,7 @@ * * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. + * Copyright 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 @@ -79,38 +80,61 @@ tgsi_scan_shader(const struct tgsi_token *tokens, switch( parse.FullToken.Token.Type ) { case TGSI_TOKEN_TYPE_INSTRUCTION: { - struct tgsi_full_instruction *fullinst + const struct tgsi_full_instruction *fullinst = &parse.FullToken.FullInstruction; assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST); info->opcode_count[fullinst->Instruction.Opcode]++; + + /* special case: scan fragment shaders for use of the fog + * input/attribute. The X component is fog, the Y component + * is the front/back-face flag. + */ + if (procType == TGSI_PROCESSOR_FRAGMENT) { + uint i; + for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) { + const struct tgsi_full_src_register *src = + &fullinst->FullSrcRegisters[i]; + if (src->SrcRegister.File == TGSI_FILE_INPUT) { + const int ind = src->SrcRegister.Index; + if (info->input_semantic_name[ind] == TGSI_SEMANTIC_FOG) { + if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_X) { + info->uses_fogcoord = TRUE; + } + else if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_Y) { + info->uses_frontfacing = TRUE; + } + } + } + } + } } break; case TGSI_TOKEN_TYPE_DECLARATION: { - struct tgsi_full_declaration *fulldecl + const struct tgsi_full_declaration *fulldecl = &parse.FullToken.FullDeclaration; uint file = fulldecl->Declaration.File; - uint i; - for (i = fulldecl->DeclarationRange.First; - i <= fulldecl->DeclarationRange.Last; - i++) { + uint reg; + for (reg = fulldecl->DeclarationRange.First; + reg <= fulldecl->DeclarationRange.Last; + reg++) { /* only first 32 regs will appear in this bitfield */ - info->file_mask[file] |= (1 << i); + info->file_mask[file] |= (1 << reg); info->file_count[file]++; info->file_max[file] = MAX2(info->file_max[file], (int)i); if (file == TGSI_FILE_INPUT) { - info->input_semantic_name[i] = (ubyte)fulldecl->Semantic.SemanticName; - info->input_semantic_index[i] = (ubyte)fulldecl->Semantic.SemanticIndex; + info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.SemanticName; + info->input_semantic_index[reg] = (ubyte)fulldecl->Semantic.SemanticIndex; info->num_inputs++; } if (file == TGSI_FILE_OUTPUT) { - info->output_semantic_name[i] = (ubyte)fulldecl->Semantic.SemanticName; - info->output_semantic_index[i] = (ubyte)fulldecl->Semantic.SemanticIndex; + info->output_semantic_name[reg] = (ubyte)fulldecl->Semantic.SemanticName; + info->output_semantic_index[reg] = (ubyte)fulldecl->Semantic.SemanticIndex; info->num_outputs++; } @@ -133,9 +157,6 @@ tgsi_scan_shader(const struct tgsi_token *tokens, } } - assert( info->file_max[TGSI_FILE_INPUT] + 1 == info->num_inputs ); - assert( info->file_max[TGSI_FILE_OUTPUT] + 1 == info->num_outputs ); - info->uses_kill = (info->opcode_count[TGSI_OPCODE_KIL] || info->opcode_count[TGSI_OPCODE_KILP]); diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h index 5cb6efb343..2c1a75bc81 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.h +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h @@ -41,7 +41,6 @@ struct tgsi_shader_info { uint num_tokens; - /* XXX eventually remove the corresponding fields from pipe_shader_state: */ ubyte num_inputs; ubyte num_outputs; ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */ @@ -59,6 +58,8 @@ struct tgsi_shader_info boolean writes_z; /**< does fragment shader write Z value? */ boolean uses_kill; /**< KIL or KILP instruction used? */ + boolean uses_fogcoord; /**< fragment shader uses fog coord? */ + boolean uses_frontfacing; /**< fragment shader uses front/back-face flag? */ }; -- cgit v1.2.3 From 030a7a320cb2c49ff60f3948bd9c4976ca0b0b17 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Dec 2008 07:33:17 -0700 Subject: gallium: replace #elif with #else --- src/gallium/auxiliary/util/u_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c index bf7d1d1c8d..f84514165a 100644 --- a/src/gallium/auxiliary/util/u_time.c +++ b/src/gallium/auxiliary/util/u_time.c @@ -111,7 +111,7 @@ util_time_add(const struct util_time *t1, #elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) /* 1 tick = 100 nano seconds. */ t2->counter = t1->counter + usecs * 10; -#elif +#else LARGE_INTEGER temp; LONGLONG freq; freq = temp.QuadPart; -- cgit v1.2.3 From b901e1f212c11afda05f2628a522d86802f87c52 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 19 Dec 2008 20:06:11 +0000 Subject: gallium: Simple and efficient cache. Fixed size hash table. Collisions are handled by simply destroying the previous entry. It hasn't received much testing yet. --- src/gallium/auxiliary/util/Makefile | 2 + src/gallium/auxiliary/util/SConscript | 2 + src/gallium/auxiliary/util/u_cache.c | 209 ++++++++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_cache.h | 87 ++++++++++++++ src/gallium/auxiliary/util/u_hash.c | 121 ++++++++++++++++++++ src/gallium/auxiliary/util/u_hash.h | 55 +++++++++ 6 files changed, 476 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_cache.c create mode 100644 src/gallium/auxiliary/util/u_cache.h create mode 100644 src/gallium/auxiliary/util/u_hash.c create mode 100644 src/gallium/auxiliary/util/u_hash.h (limited to 'src') diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile index d3951e4e7d..5c227c1eb5 100644 --- a/src/gallium/auxiliary/util/Makefile +++ b/src/gallium/auxiliary/util/Makefile @@ -6,10 +6,12 @@ LIBNAME = util C_SOURCES = \ p_debug.c \ u_blit.c \ + u_cache.c \ u_draw_quad.c \ u_gen_mipmap.c \ u_handle_table.c \ u_hash_table.c \ + u_hash.c \ u_math.c \ u_mm.c \ u_rect.c \ diff --git a/src/gallium/auxiliary/util/SConscript b/src/gallium/auxiliary/util/SConscript index e65c17b1cc..1ef06631bf 100644 --- a/src/gallium/auxiliary/util/SConscript +++ b/src/gallium/auxiliary/util/SConscript @@ -7,9 +7,11 @@ util = env.ConvenienceLibrary( 'p_debug_mem.c', 'p_debug_prof.c', 'u_blit.c', + 'u_cache.c', 'u_draw_quad.c', 'u_gen_mipmap.c', 'u_handle_table.c', + 'u_hash.c', 'u_hash_table.c', 'u_math.c', 'u_mm.c', diff --git a/src/gallium/auxiliary/util/u_cache.c b/src/gallium/auxiliary/util/u_cache.c new file mode 100644 index 0000000000..69a52687fb --- /dev/null +++ b/src/gallium/auxiliary/util/u_cache.c @@ -0,0 +1,209 @@ +/************************************************************************** + * + * Copyright 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 + * 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. + * + **************************************************************************/ + +/** + * @file + * Simple cache implementation. + * + * We simply have fixed size array, and destroy previous values on collision. + * + * @author Jose Fonseca + */ + + +#include "pipe/p_compiler.h" +#include "pipe/p_debug.h" + +#include "util/u_math.h" +#include "util/u_memory.h" +#include "util/u_cache.h" + + +struct util_cache_entry +{ + void *key; + void *value; + +#ifdef DEBUG + unsigned count; +#endif +}; + + +struct util_cache +{ + /** Hash function */ + uint32_t (*hash)(void *key); + + /** Compare two keys */ + int (*compare)(void *key1, void *key2); + + /** Destroy a (key, value) pair */ + void (*destroy)(void *key, void *value); + + uint32_t size; + + struct util_cache_entry *entries; + +#ifdef DEBUG + unsigned count; +#endif +}; + + +struct util_cache * +util_cache_create(uint32_t (*hash)(void *key), + int (*compare)(void *key1, void *key2), + void (*destroy)(void *key, void *value), + uint32_t size) +{ + struct util_cache *cache; + + cache = CALLOC_STRUCT(util_cache); + if(!cache) + return NULL; + + cache->hash = hash; + cache->compare = compare; + cache->destroy = destroy; + cache->size = size; + + cache->entries = CALLOC(size, sizeof(struct util_cache_entry)); + if(!cache->entries) { + FREE(cache); + return NULL; + } + + return cache; +} + + +static INLINE struct util_cache_entry * +util_cache_entry_get(struct util_cache *cache, + void *key) +{ + uint32_t hash; + + hash = cache->hash(key); + + return &cache->entries[hash % cache->size]; +} + +static INLINE void +util_cache_entry_destroy(struct util_cache *cache, + struct util_cache_entry *entry) +{ + void *key = entry->key; + void *value = entry->value; + + entry->key = NULL; + entry->value = NULL; + + if(key || value) + if(cache->destroy) + cache->destroy(key, value); +} + + +void +util_cache_set(struct util_cache *cache, + void *key, + void *value) +{ + struct util_cache_entry *entry; + + assert(cache); + + entry = util_cache_entry_get(cache, key); + util_cache_entry_destroy(cache, entry); + +#ifdef DEBUG + ++entry->count; + ++cache->count; +#endif + + entry->key = key; + entry->value = value; +} + + +void * +util_cache_get(struct util_cache *cache, + void *key) +{ + struct util_cache_entry *entry; + + assert(cache); + + entry = util_cache_entry_get(cache, key); + if(!entry->key && !entry->value) + return NULL; + + if(cache->compare(key, entry->key) != 0) + return NULL; + + return entry->value; +} + + +void +util_cache_clear(struct util_cache *cache) +{ + uint32_t i; + + assert(cache); + + for(i = 0; i < cache->size; ++i) + util_cache_entry_destroy(cache, &cache->entries[i]); +} + + +void +util_cache_destroy(struct util_cache *cache) +{ + assert(cache); + +#ifdef DEBUG + if(cache->count >= 20*cache->size) { + /* Normal approximation of the Poisson distribution */ + double mean = (double)cache->count/(double)cache->size; + double stddev = sqrt(mean); + unsigned i; + for(i = 0; i < cache->size; ++i) { + double z = fabs(cache->count - mean)/stddev; + /* This assert should not fail 99.9999998027% of the times, unless + * the hash function is a poor one */ + assert(z <= 6.0); + } + } +#endif + + util_cache_clear(cache); + + FREE(cache->entries); + FREE(cache); +} diff --git a/src/gallium/auxiliary/util/u_cache.h b/src/gallium/auxiliary/util/u_cache.h new file mode 100644 index 0000000000..835e083734 --- /dev/null +++ b/src/gallium/auxiliary/util/u_cache.h @@ -0,0 +1,87 @@ +/************************************************************************** + * + * Copyright 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 + * 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. + * + **************************************************************************/ + +/** + * @file + * Simple cache. + * + * @author Jose Fonseca + */ + +#ifndef U_CACHE_H_ +#define U_CACHE_H_ + + +#include "pipe/p_compiler.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Least Recently Used (LRU) cache. + */ +struct util_cache; + + +/** + * Create a cache. + * + * @param hash hash function + * @param compare should return 0 for two equal keys + * @param destroy destruction callback (optional) + * @param size maximum number of entries + */ +struct util_cache * +util_cache_create(uint32_t (*hash)(void *key), + int (*compare)(void *key1, void *key2), + void (*destroy)(void *key, void *value), + uint32_t size); + +void +util_cache_set(struct util_cache *cache, + void *key, + void *value); + +void * +util_cache_get(struct util_cache *cache, + void *key); + +void +util_cache_clear(struct util_cache *cache); + +void +util_cache_destroy(struct util_cache *cache); + + +#ifdef __cplusplus +} +#endif + +#endif /* U_CACHE_H_ */ diff --git a/src/gallium/auxiliary/util/u_hash.c b/src/gallium/auxiliary/util/u_hash.c new file mode 100644 index 0000000000..508a31f2cb --- /dev/null +++ b/src/gallium/auxiliary/util/u_hash.c @@ -0,0 +1,121 @@ +/************************************************************************** + * + * Copyright 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 + * 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. + * + **************************************************************************/ + +/** + * @file + * Hash functions implementation. + * + * @author Jose Fonseca + */ + + +#include "u_hash.h" + + +static uint32_t +util_crc32_table[256] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, + 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, + 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, + 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, + 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, + 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, + 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, + 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, + 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, + 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, + 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, + 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, + 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, + 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, + 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + + +/** + * @sa http://www.w3.org/TR/PNG/#D-CRCAppendix + */ +uint32_t +util_hash_crc32(void *data, size_t size) +{ + uint8_t *p = (uint8_t *)data; + uint32_t crc = 0xffffffff; + + while (size--) + crc = util_crc32_table[(crc ^ *p++) & 0xff] ^ (crc >> 8); + + return crc; +} diff --git a/src/gallium/auxiliary/util/u_hash.h b/src/gallium/auxiliary/util/u_hash.h new file mode 100644 index 0000000000..76c3513e4a --- /dev/null +++ b/src/gallium/auxiliary/util/u_hash.h @@ -0,0 +1,55 @@ +/************************************************************************** + * + * Copyright 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 + * 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. + * + **************************************************************************/ + +/** + * @file + * Hash functions. + * + * @author Jose Fonseca + */ + +#ifndef U_HASH_H_ +#define U_HASH_H_ + + +#include "pipe/p_compiler.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +uint32_t +util_hash_crc32(void *data, size_t size); + + +#ifdef __cplusplus +} +#endif + +#endif /* U_HASH_H_ */ -- cgit v1.2.3 From 9127a03bcbef27ed3cfc36d370969b430870fa0e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 20 Dec 2008 12:59:51 +0000 Subject: gallium: Fix typo in define name. --- src/gallium/auxiliary/util/u_memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h index bcae10832a..79e34e185f 100644 --- a/src/gallium/auxiliary/util/u_memory.h +++ b/src/gallium/auxiliary/util/u_memory.h @@ -52,7 +52,7 @@ extern "C" { #endif -#if defined(PIPE_SUBSYSTEM_WINDOWS) && defined(DEBUG) +#if defined(PIPE_OS_WINDOWS) && defined(DEBUG) /* memory debugging */ -- cgit v1.2.3 From ae7e75d6108e8621878083b35a13edc1aca893df Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 22 Dec 2008 16:55:27 +0000 Subject: gallium: const correctness. --- src/gallium/auxiliary/util/u_cache.c | 16 ++++++++-------- src/gallium/auxiliary/util/u_cache.h | 14 +++++++------- src/gallium/auxiliary/util/u_hash.c | 4 ++-- src/gallium/auxiliary/util/u_hash.h | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_cache.c b/src/gallium/auxiliary/util/u_cache.c index 69a52687fb..0a1a64259f 100644 --- a/src/gallium/auxiliary/util/u_cache.c +++ b/src/gallium/auxiliary/util/u_cache.c @@ -57,10 +57,10 @@ struct util_cache_entry struct util_cache { /** Hash function */ - uint32_t (*hash)(void *key); + uint32_t (*hash)(const void *key); /** Compare two keys */ - int (*compare)(void *key1, void *key2); + int (*compare)(const void *key1, const void *key2); /** Destroy a (key, value) pair */ void (*destroy)(void *key, void *value); @@ -76,10 +76,10 @@ struct util_cache struct util_cache * -util_cache_create(uint32_t (*hash)(void *key), - int (*compare)(void *key1, void *key2), - void (*destroy)(void *key, void *value), - uint32_t size) +util_cache_create(uint32_t (*hash)(const void *key), + int (*compare)(const void *key1, const void *key2), + void (*destroy)(void *key, void *value), + uint32_t size) { struct util_cache *cache; @@ -104,7 +104,7 @@ util_cache_create(uint32_t (*hash)(void *key), static INLINE struct util_cache_entry * util_cache_entry_get(struct util_cache *cache, - void *key) + const void *key) { uint32_t hash; @@ -153,7 +153,7 @@ util_cache_set(struct util_cache *cache, void * util_cache_get(struct util_cache *cache, - void *key) + const void *key) { struct util_cache_entry *entry; diff --git a/src/gallium/auxiliary/util/u_cache.h b/src/gallium/auxiliary/util/u_cache.h index 835e083734..8a612c6585 100644 --- a/src/gallium/auxiliary/util/u_cache.h +++ b/src/gallium/auxiliary/util/u_cache.h @@ -59,19 +59,19 @@ struct util_cache; * @param size maximum number of entries */ struct util_cache * -util_cache_create(uint32_t (*hash)(void *key), - int (*compare)(void *key1, void *key2), - void (*destroy)(void *key, void *value), - uint32_t size); +util_cache_create(uint32_t (*hash)(const void *key), + int (*compare)(const void *key1, const void *key2), + void (*destroy)(void *key, void *value), + uint32_t size); void util_cache_set(struct util_cache *cache, - void *key, - void *value); + void *key, + void *value); void * util_cache_get(struct util_cache *cache, - void *key); + const void *key); void util_cache_clear(struct util_cache *cache); diff --git a/src/gallium/auxiliary/util/u_hash.c b/src/gallium/auxiliary/util/u_hash.c index 508a31f2cb..b67653ec70 100644 --- a/src/gallium/auxiliary/util/u_hash.c +++ b/src/gallium/auxiliary/util/u_hash.c @@ -36,7 +36,7 @@ #include "u_hash.h" -static uint32_t +static const uint32_t util_crc32_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, @@ -109,7 +109,7 @@ util_crc32_table[256] = { * @sa http://www.w3.org/TR/PNG/#D-CRCAppendix */ uint32_t -util_hash_crc32(void *data, size_t size) +util_hash_crc32(const void *data, size_t size) { uint8_t *p = (uint8_t *)data; uint32_t crc = 0xffffffff; diff --git a/src/gallium/auxiliary/util/u_hash.h b/src/gallium/auxiliary/util/u_hash.h index 76c3513e4a..8d92b07c85 100644 --- a/src/gallium/auxiliary/util/u_hash.h +++ b/src/gallium/auxiliary/util/u_hash.h @@ -45,7 +45,7 @@ extern "C" { uint32_t -util_hash_crc32(void *data, size_t size); +util_hash_crc32(const void *data, size_t size); #ifdef __cplusplus -- cgit v1.2.3 From 85bc49a6f17fb3909c3d5e7200114c3bb58c9019 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Thu, 18 Dec 2008 13:34:27 +0100 Subject: softpipe: convert to use texture instead of surface --- src/gallium/drivers/softpipe/sp_texture.c | 65 ++++++++++++++----------------- 1 file changed, 30 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index cb48035771..84a497c351 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -94,40 +94,31 @@ softpipe_texture_layout(struct pipe_screen *screen, return spt->buffer != NULL; } - - -/* Hack it up to use the old winsys->surface_alloc_storage() - * method for now: - */ static boolean softpipe_displaytarget_layout(struct pipe_screen *screen, struct softpipe_texture * spt) { struct pipe_winsys *ws = screen->winsys; - struct pipe_surface surf; - unsigned flags = (PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - - memset(&surf, 0, sizeof(surf)); - - ws->surface_alloc_storage( ws, - &surf, - spt->base.width[0], - spt->base.height[0], - spt->base.format, - flags, - spt->base.tex_usage); - + size_t tex_size; + unsigned cpp; + + switch (spt->base.format) { + case PIPE_FORMAT_R5G6B5_UNORM: + cpp = 2; + break; + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: + default: + cpp = 4; + break; + } + tex_size = spt->base.width[0] * cpp * spt->base.height[0]; + spt->buffer = ws->buffer_create(ws, 64, PIPE_BUFFER_USAGE_PIXEL, tex_size); /* Now extract the goodies: */ spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]); spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]); - spt->stride[0] = surf.stride; - spt->buffer = surf.buffer; - + spt->stride[0] = spt->base.width[0] * cpp; return spt->buffer != NULL; } @@ -227,10 +218,11 @@ softpipe_get_tex_surface(struct pipe_screen *screen, assert(level <= pt->last_level); - ps = ws->surface_alloc(ws); + ps = CALLOC_STRUCT(pipe_surface); if (ps) { assert(ps->refcount); assert(ps->winsys); + pipe_texture_reference(&ps->texture, pt); pipe_buffer_reference(screen, &ps->buffer, spt->buffer); ps->format = pt->format; ps->block = pt->block; @@ -261,19 +253,18 @@ softpipe_get_tex_surface(struct pipe_screen *screen, spt->modified = TRUE; } - pipe_texture_reference(&ps->texture, pt); ps->face = face; ps->level = level; ps->zslice = zslice; if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) { - ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) * - ps->nblocksy * - ps->stride; + ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) * + ps->nblocksy * + ps->stride; } else { - assert(face == 0); - assert(zslice == 0); + assert(face == 0); + assert(zslice == 0); } } return ps; @@ -284,14 +275,18 @@ static void softpipe_tex_surface_release(struct pipe_screen *screen, struct pipe_surface **s) { + struct pipe_surface *surf = *s; /* Effectively do the texture_update work here - if texture images * needed post-processing to put them into hardware layout, this is * where it would happen. For softpipe, nothing to do. */ assert ((*s)->texture); - pipe_texture_reference(&(*s)->texture, NULL); - - screen->winsys->surface_release(screen->winsys, s); + if (--surf->refcount == 0) { + pipe_texture_reference(&surf->texture, NULL); + pipe_buffer_reference(screen, &surf->buffer, NULL); + FREE(surf); + } + *s = NULL; } -- cgit v1.2.3 From 5f36c5b2c59bb8be53d3712b3896b448ef086c74 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Thu, 18 Dec 2008 19:56:45 +0100 Subject: softpipe: initialize refcount and winsys --- src/gallium/drivers/softpipe/sp_texture.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 84a497c351..0cb4b2f03c 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -219,6 +219,8 @@ softpipe_get_tex_surface(struct pipe_screen *screen, assert(level <= pt->last_level); ps = CALLOC_STRUCT(pipe_surface); + ps->refcount = 1; + ps->winsys = ws; if (ps) { assert(ps->refcount); assert(ps->winsys); -- cgit v1.2.3