From dde3270c19143b42a55a93e1e85bb24194462671 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 20 Jan 2011 12:05:14 -0800 Subject: mesa: Connect glGetShaderPrecisionFormat into the dispatch table --- src/mesa/main/shaderapi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index e831175235e..a5e90d7cbd1 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1924,6 +1924,7 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec) /* GL_ARB_ES2_compatibility */ SET_ReleaseShaderCompiler(exec, _mesa_ReleaseShaderCompiler); + SET_GetShaderPrecisionFormat(exec, _mesa_GetShaderPrecisionFormat); #endif /* FEATURE_GL */ } -- cgit v1.2.3 From 04dca296e0a5e5ffbb8acb699e013a23ebd7b645 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 20 Jan 2011 12:05:38 -0800 Subject: mesa: Set correct values for range/precision of shader integer types --- src/mesa/main/context.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index fe370fa369b..e017939a45c 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -534,8 +534,17 @@ init_program_limits(GLenum type, struct gl_program_constants *prog) prog->MediumFloat.RangeMax = 127; prog->MediumFloat.Precision = 23; prog->LowFloat = prog->HighFloat = prog->MediumFloat; - /* assume ints are stored as floats for now */ - prog->LowInt = prog->MediumInt = prog->HighInt = prog->MediumFloat; + + /* Assume ints are stored as floats for now, since this is the least-common + * denominator. The OpenGL ES spec implies (page 132) that the precision + * of integer types should be 0. Practically speaking, IEEE + * single-precision floating point values can only store integers in the + * range [-0x01000000, 0x01000000] without loss of precision. + */ + prog->MediumInt.RangeMin = 24; + prog->MediumInt.RangeMax = 24; + prog->MediumInt.Precision = 0; + prog->LowInt = prog->HighInt = prog->MediumInt; } -- cgit v1.2.3 From 3d028024e581b05f71f0be915657c2c105885de6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 20 Jan 2011 12:07:21 -0800 Subject: i965: Set correct values for range/precision of fragment shader types --- src/mesa/drivers/dri/i965/brw_context.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 8fc322fd82e..d3b61abe896 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -151,6 +151,15 @@ GLboolean brwCreateContext( int api, MIN2(ctx->Const.FragmentProgram.MaxNativeParameters, ctx->Const.FragmentProgram.MaxEnvParams); + /* Fragment shaders use real, 32-bit twos-complement integers for all + * integer types. + */ + ctx->FragmentProgram.LowInt.RangeMin = 31; + ctx->FragmentProgram.LowInt.RangeMax = 30; + ctx->FragmentProgram.LowInt.Precision = 0; + ctx->FragmentProgram.HighInt = ctx->FragmentProgram.MediumInt + = ctx->FragmentProgram.LowInt; + /* Gen6 converts quads to polygon in beginning of 3D pipeline, but we're not sure how it's actually done for vertex order, that affect provoking vertex decision. Always use last vertex -- cgit v1.2.3 From 790ff232e2607a83e6207d06900a5e3de613d161 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 20 Jan 2011 12:07:51 -0800 Subject: i915: Set correct values for range/precision of fragment shader types --- src/mesa/drivers/dri/i915/i915_context.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index f32f3cf6020..49ad7db2893 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -168,6 +168,20 @@ i915CreateContext(int api, MIN2(ctx->Const.FragmentProgram.MaxNativeParameters, ctx->Const.FragmentProgram.MaxEnvParams); + /* i915 stores all values in single-precision floats. Values aren't set + * for other program targets because software is used for those targets. + */ + ctx->FragmentProgram.MediumFloat.RangeMin = 127; + ctx->FragmentProgram.MediumFloat.RangeMax = 127; + ctx->FragmentProgram.MediumFloat.Precision = 23; + ctx->FragmentProgram.LowFloat = ctx->FragmentProgram.HighFloat = + ctx->FragmentProgram.MediumFloat; + ctx->FragmentProgram.MediumInt.RangeMin = 24; + ctx->FragmentProgram.MediumInt.RangeMax = 24; + ctx->FragmentProgram.MediumInt.Precision = 0; + ctx->FragmentProgram.LowInt = ctx->FragmentProgram.HighInt = + ctx->FragmentProgram.MediumInt; + ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; /* FINISHME: Are there other options that should be enabled for software -- cgit v1.2.3 From 2fb0aebd4a248d2a0725099cd5646253c30c1dc3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 20 Jan 2011 13:51:07 -0800 Subject: intel: Fix typeos from 3d028024 and 790ff232 ...and remove egg from face. --- src/mesa/drivers/dri/i915/i915_context.c | 20 ++++++++++---------- src/mesa/drivers/dri/i965/brw_context.c | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 49ad7db2893..474252b640d 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -171,16 +171,16 @@ i915CreateContext(int api, /* i915 stores all values in single-precision floats. Values aren't set * for other program targets because software is used for those targets. */ - ctx->FragmentProgram.MediumFloat.RangeMin = 127; - ctx->FragmentProgram.MediumFloat.RangeMax = 127; - ctx->FragmentProgram.MediumFloat.Precision = 23; - ctx->FragmentProgram.LowFloat = ctx->FragmentProgram.HighFloat = - ctx->FragmentProgram.MediumFloat; - ctx->FragmentProgram.MediumInt.RangeMin = 24; - ctx->FragmentProgram.MediumInt.RangeMax = 24; - ctx->FragmentProgram.MediumInt.Precision = 0; - ctx->FragmentProgram.LowInt = ctx->FragmentProgram.HighInt = - ctx->FragmentProgram.MediumInt; + ctx->Const.FragmentProgram.MediumFloat.RangeMin = 127; + ctx->Const.FragmentProgram.MediumFloat.RangeMax = 127; + ctx->Const.FragmentProgram.MediumFloat.Precision = 23; + ctx->Const.FragmentProgram.LowFloat = ctx->Const.FragmentProgram.HighFloat = + ctx->Const.FragmentProgram.MediumFloat; + ctx->Const.FragmentProgram.MediumInt.RangeMin = 24; + ctx->Const.FragmentProgram.MediumInt.RangeMax = 24; + ctx->Const.FragmentProgram.MediumInt.Precision = 0; + ctx->Const.FragmentProgram.LowInt = ctx->Const.FragmentProgram.HighInt = + ctx->Const.FragmentProgram.MediumInt; ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index d3b61abe896..9483ec69d96 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -154,11 +154,11 @@ GLboolean brwCreateContext( int api, /* Fragment shaders use real, 32-bit twos-complement integers for all * integer types. */ - ctx->FragmentProgram.LowInt.RangeMin = 31; - ctx->FragmentProgram.LowInt.RangeMax = 30; - ctx->FragmentProgram.LowInt.Precision = 0; - ctx->FragmentProgram.HighInt = ctx->FragmentProgram.MediumInt - = ctx->FragmentProgram.LowInt; + ctx->Const.FragmentProgram.LowInt.RangeMin = 31; + ctx->Const.FragmentProgram.LowInt.RangeMax = 30; + ctx->Const.FragmentProgram.LowInt.Precision = 0; + ctx->Const.FragmentProgram.HighInt = ctx->Const.FragmentProgram.MediumInt + = ctx->Const.FragmentProgram.LowInt; /* Gen6 converts quads to polygon in beginning of 3D pipeline, but we're not sure how it's actually done for vertex order, -- cgit v1.2.3 From af4e2f46653cbc7ceaf1291ba22087ec5758d07f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 20 Jan 2011 18:52:39 -0700 Subject: docs: update README.WIN32 per Karl's request --- docs/README.WIN32 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/README.WIN32 b/docs/README.WIN32 index 204b8e66041..986b5994f2e 100644 --- a/docs/README.WIN32 +++ b/docs/README.WIN32 @@ -1,6 +1,10 @@ File: docs/README.WIN32 -Last updated: Apr 25, 2007 - Karl Schultz - kschultz@users.sourceforge.net +Last updated: Apr 25, 2007 + +NOTE: This information only applies to Mesa 7.8 and older. Nowadays +it's probably better to use Scons to build for Windows. + Quick Start ----- ----- @@ -130,11 +134,5 @@ change all the gl* symbols to mgl*. Because this is easy to do with a global replace operation in a text editor, no additional mangled version of mesa.def is maintained or shipped. -If you have a Windows-related build problem or question, it is -probably better to direct it to me (kschultz@users.sourceforge.net), -rather than directly to the other Mesa developers. I will help you as -much as I can. I also monitor the Mesa mailing lists and will answer -questions in this area there as well. - - -Karl Schultz +If you have a Windows-related build problem or question, please post +to the mesa-dev or mesa-users list. -- cgit v1.2.3 From 634e889bb5aee64ee17dcec221f4fb05ff93270d Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 21 Jan 2011 11:48:03 +0200 Subject: r600c: get OQ results only for 4 DBs on r600 class - since evergreen addition which increased this to 8 depth backends other bytes may contain garbage values --- src/mesa/drivers/dri/radeon/radeon_queryobj.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_queryobj.c b/src/mesa/drivers/dri/radeon/radeon_queryobj.c index a45ca7cad0d..cc395e9eab4 100644 --- a/src/mesa/drivers/dri/radeon/radeon_queryobj.c +++ b/src/mesa/drivers/dri/radeon/radeon_queryobj.c @@ -38,7 +38,7 @@ static void radeonQueryGetResult(struct gl_context *ctx, struct gl_query_object radeonContextPtr radeon = RADEON_CONTEXT(ctx); struct radeon_query_object *query = (struct radeon_query_object *)q; uint32_t *result; - int i; + int i, max_idx; radeon_print(RADEON_STATE, RADEON_VERBOSE, "%s: query id %d, result %d\n", @@ -56,7 +56,11 @@ static void radeonQueryGetResult(struct gl_context *ctx, struct gl_query_object * hw writes zpass end counts to qwords 1, 3, 5, 7. * then we substract. MSB is the valid bit. */ - for (i = 0; i < 32; i += 4) { + if (radeon->radeonScreen->chip_family >= CHIP_FAMILY_CEDAR) + max_idx = 8 * 4; /* 8 DB's */ + else + max_idx = 4 * 4; /* 4 DB's for r600, r700 */ + for (i = 0; i < max_idx; i += 4) { uint64_t start = (uint64_t)LE32_TO_CPU(result[i]) | (uint64_t)LE32_TO_CPU(result[i + 1]) << 32; uint64_t end = (uint64_t)LE32_TO_CPU(result[i + 2]) | -- cgit v1.2.3 From a637280e42b9a2f4ccbb5e7b209c5645073f584e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 17 Jan 2011 09:45:26 +1000 Subject: mesa: EXT_framebuffer_sRGB interface additions. This adds the get/enable enums and internal gl_config storage for this extension. In theory this is all that is needed to enable this extension from what I can see, since its not mandatory to implement the features if you don't advertise the visuals or the fb configs. Signed-off-by: Dave Airlie --- src/mesa/main/enable.c | 11 +++++++++++ src/mesa/main/get.c | 5 +++++ src/mesa/main/mtypes.h | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index d047586eb35..c4c4e1bb29d 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -968,6 +968,12 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) } break; + /* GL3.0 - GL_framebuffer_sRGB */ + case GL_FRAMEBUFFER_SRGB_EXT: + CHECK_EXTENSION(EXT_framebuffer_sRGB, cap); + ctx->Color.sRGBEnabled = state; + break; + default: goto invalid_enum_error; } @@ -1480,6 +1486,11 @@ _mesa_IsEnabled( GLenum cap ) } return ctx->Array.PrimitiveRestart; + /* GL3.0 - GL_framebuffer_sRGB */ + case GL_FRAMEBUFFER_SRGB_EXT: + CHECK_EXTENSION(EXT_framebuffer_sRGB); + return ctx->Color.sRGBEnabled; + default: goto invalid_enum_error; } diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index e223cf425ab..fa7aa1121aa 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -317,6 +317,7 @@ EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); EXTRA_EXT(ARB_vertex_buffer_object); EXTRA_EXT(ARB_geometry_shader4); EXTRA_EXT(ARB_copy_buffer); +EXTRA_EXT(EXT_framebuffer_sRGB); static const int extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { @@ -1238,6 +1239,10 @@ static const struct value_desc values[] = { { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 }, { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 }, + /* GL3.0 / GL_EXT_framebuffer_sRGB */ + { GL_FRAMEBUFFER_SRGB_EXT, CONTEXT_BOOL(Color.sRGBEnabled), extra_EXT_framebuffer_sRGB }, + { GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, BUFFER_INT(Visual.sRGBCapable), extra_EXT_framebuffer_sRGB }, + /* GL 3.1 */ /* NOTE: different enum values for GL_PRIMITIVE_RESTART_NV * vs. GL_PRIMITIVE_RESTART! diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 49dad4d4024..34003b4b6fb 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -524,6 +524,9 @@ struct gl_config GLint bindToMipmapTexture; GLint bindToTextureTargets; GLint yInverted; + + /* EXT_framebuffer_sRGB */ + GLint sRGBCapable; }; @@ -754,6 +757,8 @@ struct gl_colorbuffer_attrib GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + + GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ }; -- cgit v1.2.3 From 4b3789427f5eaef8560b9cb4845a6b1c92228f02 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 21 Jan 2011 12:39:07 -0500 Subject: r600g: FLT_TO_INT_FLOOR is trans instruction Add missing evergreen FLT_TO_INT_FLOOR instruction. --- src/gallium/drivers/r600/r600_asm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c index b9c74e93299..f46059b9e90 100644 --- a/src/gallium/drivers/r600/r600_asm.c +++ b/src/gallium/drivers/r600/r600_asm.c @@ -419,6 +419,7 @@ static int is_alu_trans_unit_inst(struct r600_bc *bc, struct r600_bc_alu *alu) if (!alu->is_op3) return alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT || alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT || + alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR || alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT || alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHL_INT || alu->inst == EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LSHR_INT || -- cgit v1.2.3 From a40305dcdb17588613c02868777b3f0e997fb6ff Mon Sep 17 00:00:00 2001 From: Christian König Date: Sun, 9 Jan 2011 13:18:48 +0100 Subject: r600g: check if hardware blits are possible bevore enabling tilling --- src/gallium/drivers/r600/r600_texture.c | 81 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index 91032e83825..51560bd19e6 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -321,6 +321,45 @@ r600_texture_create_object(struct pipe_screen *screen, return rtex; } +/* Figure out whether u_blitter will fallback to a transfer operation. + * If so, don't use a staging resource. + */ +static boolean permit_hardware_blit(struct pipe_screen *screen, + const struct pipe_resource *res) +{ + unsigned bind; + + if (util_format_is_depth_or_stencil(res->format)) + bind = PIPE_BIND_DEPTH_STENCIL; + else + bind = PIPE_BIND_RENDER_TARGET; + + /* See r600_resource_copy_region: there is something wrong + * with depth resource copies at the moment so avoid them for + * now. + */ + if (util_format_get_component_bits(res->format, + UTIL_FORMAT_COLORSPACE_ZS, + 0) != 0) + return FALSE; + + if (!screen->is_format_supported(screen, + res->format, + res->target, + res->nr_samples, + bind, 0)) + return FALSE; + + if (!screen->is_format_supported(screen, + res->format, + res->target, + res->nr_samples, + PIPE_BIND_SAMPLER_VIEW, 0)) + return FALSE; + + return TRUE; +} + struct pipe_resource *r600_texture_create(struct pipe_screen *screen, const struct pipe_resource *templ) { @@ -332,7 +371,7 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen, if (force_tiling == -1) force_tiling = debug_get_bool_option("R600_FORCE_TILING", FALSE); - if (force_tiling) { + if (force_tiling && permit_hardware_blit(screen, templ)) { if (!(templ->flags & R600_RESOURCE_FLAG_TRANSFER) && !(templ->bind & PIPE_BIND_SCANOUT)) { array_mode = V_038000_ARRAY_2D_TILED_THIN1; @@ -485,46 +524,6 @@ static INLINE unsigned u_box_volume( const struct pipe_box *box ) return box->width * box->depth * box->height; }; - -/* Figure out whether u_blitter will fallback to a transfer operation. - * If so, don't use a staging resource. - */ -static boolean permit_hardware_blit(struct pipe_screen *screen, - struct pipe_resource *res) -{ - unsigned bind; - - if (util_format_is_depth_or_stencil(res->format)) - bind = PIPE_BIND_DEPTH_STENCIL; - else - bind = PIPE_BIND_RENDER_TARGET; - - /* See r600_resource_copy_region: there is something wrong - * with depth resource copies at the moment so avoid them for - * now. - */ - if (util_format_get_component_bits(res->format, - UTIL_FORMAT_COLORSPACE_ZS, - 0) != 0) - return FALSE; - - if (!screen->is_format_supported(screen, - res->format, - res->target, - res->nr_samples, - bind, 0)) - return FALSE; - - if (!screen->is_format_supported(screen, - res->format, - res->target, - res->nr_samples, - PIPE_BIND_SAMPLER_VIEW, 0)) - return FALSE; - - return TRUE; -} - struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx, struct pipe_resource *texture, unsigned level, -- cgit v1.2.3 From 484edfc8151ddf63d3e0e7be3b4c8fa3906a0ec9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 21 Jan 2011 18:10:31 +0100 Subject: st/dri: Fix warning --- src/gallium/state_trackers/dri/common/dri_drawable.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c index 5fd6e7863c0..060748622c9 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c @@ -233,6 +233,7 @@ const __DRItexBufferExtension driTexBufferExtension = { { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, dri_set_tex_buffer, dri_set_tex_buffer2, + NULL, }; /** -- cgit v1.2.3 From 7287964f944d7e2bcf409b758163ab75c61b0f8e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 3 Dec 2010 19:42:45 +0100 Subject: i915g: Use slab allocator for transfers Also remove unused i915_transfer struct --- src/gallium/drivers/i915/i915_context.c | 4 +++ src/gallium/drivers/i915/i915_context.h | 4 +++ src/gallium/drivers/i915/i915_resource_buffer.c | 36 ++++++++++++++++++++++-- src/gallium/drivers/i915/i915_resource_texture.c | 16 +++++++++-- src/gallium/drivers/i915/i915_screen.h | 16 ----------- 5 files changed, 55 insertions(+), 21 deletions(-) diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 9be31619254..9d43381f7b3 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -140,6 +140,10 @@ i915_create_context(struct pipe_screen *screen, void *priv) i915->base.draw_vbo = i915_draw_vbo; + /* init this before draw */ + util_slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer), + 16, UTIL_SLAB_SINGLETHREADED); + /* * Create drawing context and plug our rendering stage into it. */ diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index d15e1723d83..1bf9cde4d4d 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -37,6 +37,8 @@ #include "tgsi/tgsi_scan.h" +#include "util/u_slab.h" + struct i915_winsys; struct i915_winsys_buffer; @@ -237,6 +239,8 @@ struct i915_context { struct i915_state current; unsigned hardware_dirty; + + struct util_slab_mempool transfer_pool; }; /* A flag for each state_tracker state object: diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c index 450203d60a9..6e2b490f535 100644 --- a/src/gallium/drivers/i915/i915_resource_buffer.c +++ b/src/gallium/drivers/i915/i915_resource_buffer.c @@ -60,6 +60,38 @@ i915_buffer_destroy(struct pipe_screen *screen, } +static struct pipe_transfer * +i915_get_transfer(struct pipe_context *pipe, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box) +{ + struct i915_context *i915 = i915_context(pipe); + struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool); + + 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; +} + +static void +i915_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *transfer) +{ + struct i915_context *i915 = i915_context(pipe); + util_slab_free(&i915->transfer_pool, transfer); +} + static void * i915_buffer_transfer_map( struct pipe_context *pipe, struct pipe_transfer *transfer ) @@ -92,8 +124,8 @@ struct u_resource_vtbl i915_buffer_vtbl = i915_buffer_get_handle, /* get_handle */ i915_buffer_destroy, /* resource_destroy */ NULL, /* is_resource_referenced */ - u_default_get_transfer, /* get_transfer */ - u_default_transfer_destroy, /* transfer_destroy */ + i915_get_transfer, /* get_transfer */ + i915_transfer_destroy, /* transfer_destroy */ i915_buffer_transfer_map, /* transfer_map */ u_default_transfer_flush_region, /* transfer_flush_region */ u_default_transfer_unmap, /* transfer_unmap */ diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c index f19106f3414..e793d126ade 100644 --- a/src/gallium/drivers/i915/i915_resource_texture.c +++ b/src/gallium/drivers/i915/i915_resource_texture.c @@ -716,14 +716,16 @@ i915_texture_destroy(struct pipe_screen *screen, } static struct pipe_transfer * -i915_texture_get_transfer(struct pipe_context *context, +i915_texture_get_transfer(struct pipe_context *pipe, struct pipe_resource *resource, unsigned level, unsigned usage, const struct pipe_box *box) { + struct i915_context *i915 = i915_context(pipe); struct i915_texture *tex = i915_texture(resource); - struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer); + struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool); + if (transfer == NULL) return NULL; @@ -737,6 +739,14 @@ i915_texture_get_transfer(struct pipe_context *context, return transfer; } +static void +i915_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *transfer) +{ + struct i915_context *i915 = i915_context(pipe); + util_slab_free(&i915->transfer_pool, transfer); +} + static void * i915_texture_transfer_map(struct pipe_context *pipe, struct pipe_transfer *transfer) @@ -781,7 +791,7 @@ struct u_resource_vtbl i915_texture_vtbl = i915_texture_destroy, /* resource_destroy */ NULL, /* is_resource_referenced */ i915_texture_get_transfer, /* get_transfer */ - u_default_transfer_destroy, /* transfer_destroy */ + i915_transfer_destroy, /* transfer_destroy */ i915_texture_transfer_map, /* transfer_map */ u_default_transfer_flush_region, /* transfer_flush_region */ i915_texture_transfer_unmap, /* transfer_unmap */ diff --git a/src/gallium/drivers/i915/i915_screen.h b/src/gallium/drivers/i915/i915_screen.h index 0c4186c68ee..bb4d255a3b3 100644 --- a/src/gallium/drivers/i915/i915_screen.h +++ b/src/gallium/drivers/i915/i915_screen.h @@ -47,16 +47,6 @@ struct i915_screen boolean is_i945; }; -/** - * Subclass of pipe_transfer - */ -struct i915_transfer -{ - struct pipe_transfer base; - - unsigned offset; -}; - /* * Cast wrappers @@ -69,11 +59,5 @@ i915_screen(struct pipe_screen *pscreen) return (struct i915_screen *) pscreen; } -static INLINE struct i915_transfer * -i915_transfer(struct pipe_transfer *transfer) -{ - return (struct i915_transfer *)transfer; -} - #endif /* I915_SCREEN_H */ -- cgit v1.2.3 From 2e60aa511dd232f88697d1cc2091442caaef79b2 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 29 Nov 2010 21:37:09 +0100 Subject: i915g: Don't emit FS constants when VS contants change --- src/gallium/drivers/i915/i915_context.c | 18 ++++++++++++++---- src/gallium/drivers/i915/i915_context.h | 8 +++++--- src/gallium/drivers/i915/i915_debug.c | 3 ++- src/gallium/drivers/i915/i915_state.c | 11 +++++++++-- src/gallium/drivers/i915/i915_state_fpc.c | 2 +- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 9d43381f7b3..15454d02cfb 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -51,6 +51,14 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) struct draw_context *draw = i915->draw; void *mapped_indices = NULL; unsigned i; + unsigned cbuf_dirty; + + + /* + * Ack vs contants here, helps ipers a lot. + */ + cbuf_dirty = i915->dirty & I915_NEW_VS_CONSTANTS; + i915->dirty &= ~I915_NEW_VS_CONSTANTS; if (i915->dirty) i915_update_derived(i915); @@ -70,10 +78,12 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) mapped_indices = i915_buffer(i915->index_buffer.buffer)->data; draw_set_mapped_index_buffer(draw, mapped_indices); - draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, - i915->current.constants[PIPE_SHADER_VERTEX], - (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * - 4 * sizeof(float))); + if (cbuf_dirty) { + draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, + i915->current.constants[PIPE_SHADER_VERTEX], + (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * + 4 * sizeof(float))); + } /* * Do the drawing diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 1bf9cde4d4d..6dab3a14a58 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -257,9 +257,11 @@ struct i915_context { #define I915_NEW_DEPTH_STENCIL 0x200 #define I915_NEW_SAMPLER 0x400 #define I915_NEW_SAMPLER_VIEW 0x800 -#define I915_NEW_CONSTANTS 0x1000 -#define I915_NEW_VBO 0x2000 -#define I915_NEW_VS 0x4000 +#define I915_NEW_VS_CONSTANTS 0x1000 +#define I915_NEW_FS_CONSTANTS 0x2000 +#define I915_NEW_GS_CONSTANTS 0x4000 +#define I915_NEW_VBO 0x8000 +#define I915_NEW_VS 0x10000 /* Driver's internally generated state flags: diff --git a/src/gallium/drivers/i915/i915_debug.c b/src/gallium/drivers/i915/i915_debug.c index 87c435a2f36..845e92cf5c6 100644 --- a/src/gallium/drivers/i915/i915_debug.c +++ b/src/gallium/drivers/i915/i915_debug.c @@ -948,7 +948,8 @@ i915_dump_dirty(struct i915_context *i915, const char *func) {I915_NEW_DEPTH_STENCIL, "depth_stencil"}, {I915_NEW_SAMPLER, "sampler"}, {I915_NEW_SAMPLER_VIEW, "sampler_view"}, - {I915_NEW_CONSTANTS, "constants"}, + {I915_NEW_VS_CONSTANTS, "vs_const"}, + {I915_NEW_FS_CONSTANTS, "fs_const"}, {I915_NEW_VBO, "vbo"}, {I915_NEW_VS, "vs"}, {0, NULL}, diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index f5b60ed5942..cc8bd3b0c39 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -527,6 +527,10 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, struct i915_context *i915 = i915_context(pipe); draw_flush(i915->draw); + /* XXX don't support geom shaders now */ + if (shader == PIPE_SHADER_GEOMETRY) + return; + /* Make a copy of shader constants. * During fragment program translation we may add additional * constants to the array. @@ -538,6 +542,10 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, */ if (buf) { struct i915_buffer *ir = i915_buffer(buf); + + if (!memcmp(i915->current.constants[shader], ir->data, ir->b.b.width0)) + return; + memcpy(i915->current.constants[shader], ir->data, ir->b.b.width0); i915->current.num_user_constants[shader] = (ir->b.b.width0 / 4 * sizeof(float)); @@ -546,8 +554,7 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, i915->current.num_user_constants[shader] = 0; } - - i915->dirty |= I915_NEW_CONSTANTS; + i915->dirty |= shader == PIPE_SHADER_VERTEX ? I915_NEW_VS_CONSTANTS : I915_NEW_FS_CONSTANTS; } diff --git a/src/gallium/drivers/i915/i915_state_fpc.c b/src/gallium/drivers/i915/i915_state_fpc.c index ec7cec0e471..1959a24691d 100644 --- a/src/gallium/drivers/i915/i915_state_fpc.c +++ b/src/gallium/drivers/i915/i915_state_fpc.c @@ -40,7 +40,7 @@ static void update_hw_constants(struct i915_context *i915) struct i915_tracked_state i915_hw_constants = { "hw_constants", update_hw_constants, - I915_NEW_CONSTANTS | I915_NEW_FS + I915_NEW_FS_CONSTANTS | I915_NEW_FS }; -- cgit v1.2.3 From 0c3352b6df7972fd530a901396b392d0293d27ae Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 1 Dec 2010 05:45:42 +0100 Subject: i915g: Don't do unnecessary copies of constants Even tho st/mesa use user buffers for constants align buffers other state trackers doesn't use user buffers. --- src/gallium/drivers/i915/i915_context.c | 7 ++++- src/gallium/drivers/i915/i915_context.h | 2 -- src/gallium/drivers/i915/i915_resource_buffer.c | 3 +- src/gallium/drivers/i915/i915_state.c | 42 ++++++++++++++----------- src/gallium/drivers/i915/i915_state_emit.c | 3 +- 5 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 15454d02cfb..ea3c10b5e78 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -80,7 +80,7 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) if (cbuf_dirty) { draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, - i915->current.constants[PIPE_SHADER_VERTEX], + i915_buffer(i915->constants[PIPE_SHADER_VERTEX])->data, (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 4 * sizeof(float))); } @@ -127,6 +127,11 @@ static void i915_destroy(struct pipe_context *pipe) } pipe_surface_reference(&i915->framebuffer.zsbuf, NULL); + /* unbind constant buffers */ + for (i = 0; i < PIPE_SHADER_TYPES; i++) { + pipe_resource_reference(&i915->constants[i], NULL); + } + FREE(i915); } diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 6dab3a14a58..b7f1fb22221 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -136,7 +136,6 @@ struct i915_state unsigned immediate[I915_MAX_IMMEDIATE]; unsigned dynamic[I915_MAX_DYNAMIC]; - float constants[PIPE_SHADER_TYPES][I915_MAX_CONSTANT][4]; /** number of constants passed in through a constant buffer */ uint num_user_constants[PIPE_SHADER_TYPES]; @@ -214,7 +213,6 @@ struct i915_context { struct pipe_blend_color blend_color; struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; - /* XXX unneded */ struct pipe_resource *constants[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c index 6e2b490f535..51482f54fc4 100644 --- a/src/gallium/drivers/i915/i915_resource_buffer.c +++ b/src/gallium/drivers/i915/i915_resource_buffer.c @@ -147,8 +147,7 @@ i915_buffer_create(struct pipe_screen *screen, buf->b.vtbl = &i915_buffer_vtbl; pipe_reference_init(&buf->b.b.reference, 1); buf->b.b.screen = screen; - - buf->data = MALLOC(template->width0); + buf->data = align_malloc(template->width0, 16); buf->free_on_destroy = TRUE; if (!buf->data) diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index cc8bd3b0c39..4a1a4a04f6d 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -525,36 +525,40 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, struct pipe_resource *buf) { struct i915_context *i915 = i915_context(pipe); - draw_flush(i915->draw); + unsigned new_num = 0; + boolean diff = TRUE; + /* XXX don't support geom shaders now */ if (shader == PIPE_SHADER_GEOMETRY) return; - /* Make a copy of shader constants. - * During fragment program translation we may add additional - * constants to the array. - * - * We want to consider the situation where some user constants - * (ex: a material color) may change frequently but the shader program - * stays the same. In that case we should only be updating the first - * N constants, leaving any extras from shader translation alone. - */ + /* if we have a new buffer compare it with the old one */ if (buf) { struct i915_buffer *ir = i915_buffer(buf); + struct pipe_resource *old_buf = i915->constants[shader]; + struct i915_buffer *old = old_buf ? i915_buffer(old_buf) : NULL; - if (!memcmp(i915->current.constants[shader], ir->data, ir->b.b.width0)) - return; + new_num = ir->b.b.width0 / 4 * sizeof(float); - memcpy(i915->current.constants[shader], ir->data, ir->b.b.width0); - i915->current.num_user_constants[shader] = (ir->b.b.width0 / - 4 * sizeof(float)); - } - else { - i915->current.num_user_constants[shader] = 0; + if (old && new_num != i915->current.num_user_constants[shader]) + diff = memcmp(old->data, ir->data, ir->b.b.width0); + } else { + diff = i915->current.num_user_constants[shader] != 0; } - i915->dirty |= shader == PIPE_SHADER_VERTEX ? I915_NEW_VS_CONSTANTS : I915_NEW_FS_CONSTANTS; + /* + * flush before updateing the state. + * XXX: looks like its okay to skip the flush for vertex cbufs + */ + if (diff && shader == PIPE_SHADER_FRAGMENT) + draw_flush(i915->draw); + + pipe_resource_reference(&i915->constants[shader], buf); + i915->current.num_user_constants[shader] = new_num; + + if (diff) + i915->dirty |= shader == PIPE_SHADER_VERTEX ? I915_NEW_VS_CONSTANTS : I915_NEW_FS_CONSTANTS; } diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c index 86c02976495..5a89977c26c 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -367,7 +367,8 @@ i915_emit_hardware_state(struct i915_context *i915 ) const uint *c; if (i915->fs->constant_flags[i] == I915_CONSTFLAG_USER) { /* grab user-defined constant */ - c = (uint *) i915->current.constants[PIPE_SHADER_FRAGMENT][i]; + c = (uint *) i915_buffer(i915->constants[PIPE_SHADER_FRAGMENT])->data; + c += 4 * i; } else { /* emit program constant */ -- cgit v1.2.3 From 8af583f6e844ef2d173eb3c5c2e378cd1da018a8 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 1 Dec 2010 05:49:42 +0100 Subject: i915g: Don't (un)map vbuf on each (un)map call --- src/gallium/drivers/i915/i915_prim_vbuf.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c b/src/gallium/drivers/i915/i915_prim_vbuf.c index baebbc7bae3..3473c863970 100644 --- a/src/gallium/drivers/i915/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915/i915_prim_vbuf.c @@ -181,6 +181,7 @@ i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size) struct i915_winsys *iws = i915->iws; if (i915_render->vbo) { + iws->buffer_unmap(iws, i915_render->vbo); iws->buffer_destroy(iws, i915_render->vbo); /* * XXX If buffers where referenced then this should be done in @@ -208,6 +209,7 @@ i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size) i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, I915_NEW_VERTEX); + i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, TRUE); } /** @@ -262,16 +264,13 @@ i915_vbuf_render_map_vertices(struct vbuf_render *render) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; - struct i915_winsys *iws = i915->iws; if (i915->vbo_flushed) debug_printf("%s bad vbo flush occured stalling on hw\n", __FUNCTION__); #ifdef VBUF_MAP_BUFFER - i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, TRUE); return (unsigned char *)i915_render->vbo_ptr + i915_render->vbo_sw_offset; #else - (void)iws; return (unsigned char *)i915_render->vbo_ptr; #endif } @@ -288,7 +287,7 @@ i915_vbuf_render_unmap_vertices(struct vbuf_render *render, i915_render->vbo_max_index = max_index; i915_render->vbo_max_used = MAX2(i915_render->vbo_max_used, i915_render->vertex_size * (max_index + 1)); #ifdef VBUF_MAP_BUFFER - iws->buffer_unmap(iws, i915_render->vbo); + (void)iws; #else i915_render->map_used_start = i915_render->vertex_size * min_index; i915_render->map_used_end = i915_render->vertex_size * (max_index + 1); @@ -684,6 +683,15 @@ static void i915_vbuf_render_destroy(struct vbuf_render *render) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); + struct i915_context *i915 = i915_render->i915; + struct i915_winsys *iws = i915->iws; + + if (i915_render->vbo) { + i915->vbo = NULL; + iws->buffer_unmap(iws, i915_render->vbo); + iws->buffer_destroy(iws, i915_render->vbo); + } + FREE(i915_render); } -- cgit v1.2.3