From 986eb4b99fd9304abc949407e48dade5e122712e Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 22 Apr 2010 02:33:10 -0400 Subject: r300: fix vertex unit setup RV3xx is 2, RV560,RV570 is 8 Noticed by Tormod Volden. --- src/mesa/drivers/dri/r300/r300_state.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 5979dedac4f..188169ce87a 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1658,20 +1658,21 @@ void r300VapCntl(r300ContextPtr rmesa, GLuint input_count, (5 << R300_PVS_NUM_CNTLRS_SHIFT) | (5 << R300_VF_MAX_VTX_NUM_SHIFT)); - if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV515) - rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (2 << R300_PVS_NUM_FPUS_SHIFT); - else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530) || - (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560) || - (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570)) + if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) || + (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R350)) + rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (4 << R300_PVS_NUM_FPUS_SHIFT); + else if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530) rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (5 << R300_PVS_NUM_FPUS_SHIFT); else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410) || (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420)) rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (6 << R300_PVS_NUM_FPUS_SHIFT); else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R520) || - (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580)) + (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580) || + (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560) || + (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570)) rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (8 << R300_PVS_NUM_FPUS_SHIFT); else - rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (4 << R300_PVS_NUM_FPUS_SHIFT); + rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (2 << R300_PVS_NUM_FPUS_SHIFT); } -- cgit v1.2.3 From 52bc90caa86925629296c02306773c4e00176f78 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 15:11:34 +0100 Subject: u_format: Reduce code duplication. --- src/gallium/auxiliary/util/u_format_s3tc.c | 215 +++++++++++++---------------- 1 file changed, 97 insertions(+), 118 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c index 79dee2b4238..abc1951f8f6 100644 --- a/src/gallium/auxiliary/util/u_format_s3tc.c +++ b/src/gallium/auxiliary/util/u_format_s3tc.c @@ -233,8 +233,12 @@ util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned * Block decompression. */ -void -util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +static INLINE void +util_format_dxtn_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height, + util_format_dxtn_fetch_t fetch, + unsigned block_size) { unsigned x, y, i, j; for(y = 0; y < height; y += 4) { @@ -243,98 +247,65 @@ util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, c for(j = 0; j < 4; ++j) { for(i = 0; i < 4; ++i) { uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - util_format_dxt1_rgb_fetch(0, src, i, j, dst); + fetch(0, src, i, j, dst); } } - src += 8; + src += block_size; } src_row += src_stride; } } void -util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { - unsigned x, y, i, j; - for(y = 0; y < height; y += 4) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += 4) { - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - util_format_dxt1_rgba_fetch(0, src, i, j, dst); - } - } - src += 8; - } - src_row += src_stride; - } + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgb_fetch, 8); } void -util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { - unsigned x, y, i, j; - for(y = 0; y < height; y += 4) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += 4) { - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - util_format_dxt3_rgba_fetch(0, src, i, j, dst); - } - } - src += 16; - } - src_row += src_stride; - } + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgba_fetch, 8); } void -util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { - unsigned x, y, i, j; - for(y = 0; y < height; y += 4) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += 4) { - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - util_format_dxt5_rgba_fetch(0, src, i, j, dst); - } - } - src += 16; - } - src_row += src_stride; - } + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt3_rgba_fetch, 16); } void -util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { - unsigned x, y, i, j; - for(y = 0; y < height; y += 4) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += 4) { - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - uint8_t tmp[4]; - util_format_dxt1_rgb_fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - dst[3] = 1.0; - } - } - src += 8; - } - src_row += src_stride; - } + util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt5_rgba_fetch, 16); } void -util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height, + util_format_dxtn_fetch_t fetch, + unsigned block_size) { unsigned x, y, i, j; for(y = 0; y < height; y += 4) { @@ -344,65 +315,61 @@ util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, con for(i = 0; i < 4; ++i) { float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; uint8_t tmp[4]; - util_format_dxt1_rgba_fetch(0, src, i, j, tmp); + fetch(0, src, i, j, tmp); dst[0] = ubyte_to_float(tmp[0]); dst[1] = ubyte_to_float(tmp[1]); dst[2] = ubyte_to_float(tmp[2]); dst[3] = ubyte_to_float(tmp[3]); } } - src += 8; + src += block_size; } src_row += src_stride; } } void -util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { - unsigned x, y, i, j; - for(y = 0; y < height; y += 4) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += 4) { - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - uint8_t tmp[4]; - util_format_dxt3_rgba_fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); - } - } - src += 16; - } - src_row += src_stride; - } + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgb_fetch, 8); } void -util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { - unsigned x, y, i, j; - for(y = 0; y < height; y += 4) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += 4) { - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - uint8_t tmp[4]; - util_format_dxt5_rgba_fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); - } - } - src += 16; - } - src_row += src_stride; - } + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt1_rgba_fetch, 8); +} + +void +util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt3_rgba_fetch, 16); +} + +void +util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, + src_row, src_stride, + width, height, + util_format_dxt5_rgba_fetch, 16); } @@ -411,7 +378,9 @@ util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, con */ void -util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y, i, j, k; for(y = 0; y < height; y += 4) { @@ -436,7 +405,9 @@ util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, con } void -util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y, i, j, k; for(y = 0; y < height; y += 4) { @@ -461,7 +432,9 @@ util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, co } void -util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y, i, j, k; for(y = 0; y < height; y += 4) { @@ -486,7 +459,9 @@ util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, co } void -util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y, i, j, k; for(y = 0; y < height; y += 4) { @@ -511,7 +486,9 @@ util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, co } void -util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y, i, j, k; for(y = 0; y < height; y += 4) { @@ -536,7 +513,9 @@ util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, cons } void -util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) +util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) { unsigned x, y, i, j, k; for(y = 0; y < height; y += 4) { -- cgit v1.2.3 From 6ae9975ea08b64d7f4e7a2c6c535c14280bef843 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 15:11:57 +0100 Subject: llvmpipe: Fix typo in assert. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 59d5a440c03..551c3757bbb 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -1112,8 +1112,8 @@ make_variant_key(struct llvmpipe_context *lp, unsigned chan; format_desc = util_format_description(lp->framebuffer.cbufs[i]->format); - assert(format_desc->layout == UTIL_FORMAT_COLORSPACE_RGB || - format_desc->layout == UTIL_FORMAT_COLORSPACE_SRGB); + assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB || + format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB); key->blend.rt[i].colormask = lp->blend->rt[i].colormask; -- cgit v1.2.3 From 510669cd87994b39e50a8ab1ac24110e6a299e4d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 15:12:30 +0100 Subject: llvmpipe: Do not advertise S3TC rendering support. --- src/gallium/drivers/llvmpipe/lp_screen.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 6d309c6b647..f453b9fe5ae 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -181,16 +181,6 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, target == PIPE_TEXTURE_3D || target == PIPE_TEXTURE_CUBE); - switch(format) { - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: - case PIPE_FORMAT_DXT3_RGBA: - case PIPE_FORMAT_DXT5_RGBA: - return util_format_s3tc_enabled; - default: - break; - } - if(tex_usage & PIPE_BIND_RENDER_TARGET) { if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) return FALSE; @@ -220,6 +210,16 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, return FALSE; } + switch(format) { + case PIPE_FORMAT_DXT1_RGB: + case PIPE_FORMAT_DXT1_RGBA: + case PIPE_FORMAT_DXT3_RGBA: + case PIPE_FORMAT_DXT5_RGBA: + return util_format_s3tc_enabled; + default: + break; + } + return TRUE; } -- cgit v1.2.3 From 2eea1714fdffbd665a2076c7b8fed7b264a42968 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 18:06:05 +0100 Subject: llvmpipe: Fix resource_is_texture. It was missing PIPE_BIND_RENDER_TARGET, causing assertion failures for pure render targets. Also bind flags are too variable and complex for a good assessment for whether the resource is a texture or not. Target is more concise. --- src/gallium/drivers/llvmpipe/lp_texture.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index cee170ec834..4fce02ac713 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -55,14 +55,18 @@ static INLINE boolean resource_is_texture(const struct pipe_resource *resource) { - const unsigned tex_binds = (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED | - PIPE_BIND_DEPTH_STENCIL | - PIPE_BIND_SAMPLER_VIEW); - const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource); - - return (lpr->base.bind & tex_binds) ? TRUE : FALSE; + switch (resource->target) { + case PIPE_BUFFER: + return FALSE; + case PIPE_TEXTURE_1D: + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_3D: + case PIPE_TEXTURE_CUBE: + return TRUE; + default: + assert(0); + return FALSE; + } } -- cgit v1.2.3 From 4d7ef6e06b45c75bc24f8f238bcc3d2328e53c7d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 08:46:46 -0600 Subject: mesa: fix conversion errors in signed_rgba8888[rev] texel fetch Without the cast the returned texel colors were wrong. Also, we don't need the "& 0xff" part anymore. Bug found by Vinson Lee. --- src/mesa/main/texfetch_tmp.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index e6772c89f36..b11ed5c39a3 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -1215,10 +1215,10 @@ static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s >> 24) ); - texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff ); - texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 8) & 0xff ); - texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s ) & 0xff ); + texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); + texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); + texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); + texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); } #if DIM == 3 @@ -1235,10 +1235,10 @@ static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = BYTE_TO_FLOAT_TEX( (s ) & 0xff ); - texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 8) & 0xff ); - texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff ); - texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s >> 24) ); + texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); + texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); + texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); + texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); } #if DIM == 3 -- cgit v1.2.3 From b1a9c76b574f4da6b87c5a0750bfbe5bc98d1f4e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 10:26:20 -0600 Subject: st/mesa: add cases for MESA_FORMAT_Z24_X8, MESA_FORMAT_X8_Z24 --- src/mesa/state_tracker/st_format.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 9ae0c9f9bab..91e386c848a 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -154,6 +154,10 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) return PIPE_FORMAT_S8Z24_UNORM; case MESA_FORMAT_S8_Z24: return PIPE_FORMAT_Z24S8_UNORM; + case MESA_FORMAT_Z24_X8: + return PIPE_FORMAT_X8Z24_UNORM; + case MESA_FORMAT_X8_Z24: + return PIPE_FORMAT_Z24X8_UNORM; case MESA_FORMAT_YCBCR: return PIPE_FORMAT_UYVY; #if FEATURE_texture_s3tc -- cgit v1.2.3 From 446062b83453d3b64205d135a8abbc0999927f00 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 10:02:18 -0600 Subject: mesa: sort texel fetch/store table by format index --- src/mesa/main/texfetch.c | 506 ++++++++++++++++++++++++----------------------- 1 file changed, 256 insertions(+), 250 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index b37039429f4..323850e1981 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -115,7 +115,7 @@ static void store_null_texel(struct gl_texture_image *texImage, * XXX this is somewhat temporary. */ static struct { - GLuint Name; + gl_format Name; FetchTexelFuncF Fetch1D; FetchTexelFuncF Fetch2D; FetchTexelFuncF Fetch3D; @@ -124,222 +124,13 @@ static struct { texfetch_funcs[MESA_FORMAT_COUNT] = { { - MESA_FORMAT_SRGB8, - fetch_texel_1d_srgb8, - fetch_texel_2d_srgb8, - fetch_texel_3d_srgb8, - store_texel_srgb8 - }, - { - MESA_FORMAT_SRGBA8, - fetch_texel_1d_srgba8, - fetch_texel_2d_srgba8, - fetch_texel_3d_srgba8, - store_texel_srgba8 - }, - { - MESA_FORMAT_SARGB8, - fetch_texel_1d_sargb8, - fetch_texel_2d_sargb8, - fetch_texel_3d_sargb8, - store_texel_sargb8 - }, - { - MESA_FORMAT_SL8, - fetch_texel_1d_sl8, - fetch_texel_2d_sl8, - fetch_texel_3d_sl8, - store_texel_sl8 - }, - { - MESA_FORMAT_SLA8, - fetch_texel_1d_sla8, - fetch_texel_2d_sla8, - fetch_texel_3d_sla8, - store_texel_sla8 - }, - { - MESA_FORMAT_RGB_FXT1, - NULL, - _mesa_fetch_texel_2d_f_rgb_fxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_FXT1, - NULL, - _mesa_fetch_texel_2d_f_rgba_fxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_DXT1, - NULL, - _mesa_fetch_texel_2d_f_rgb_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT1, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT3, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt3, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT5, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt5, - NULL, - NULL - }, - { - MESA_FORMAT_SRGB_DXT1, - NULL, - _mesa_fetch_texel_2d_f_srgb_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT1, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT3, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt3, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT5, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt5, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_FLOAT32, - fetch_texel_1d_f_rgba_f32, - fetch_texel_2d_f_rgba_f32, - fetch_texel_3d_f_rgba_f32, - store_texel_rgba_f32 - }, - { - MESA_FORMAT_RGBA_FLOAT16, - fetch_texel_1d_f_rgba_f16, - fetch_texel_2d_f_rgba_f16, - fetch_texel_3d_f_rgba_f16, - store_texel_rgba_f16 - }, - { - MESA_FORMAT_RGB_FLOAT32, - fetch_texel_1d_f_rgb_f32, - fetch_texel_2d_f_rgb_f32, - fetch_texel_3d_f_rgb_f32, - store_texel_rgb_f32 - }, - { - MESA_FORMAT_RGB_FLOAT16, - fetch_texel_1d_f_rgb_f16, - fetch_texel_2d_f_rgb_f16, - fetch_texel_3d_f_rgb_f16, - store_texel_rgb_f16 - }, - { - MESA_FORMAT_ALPHA_FLOAT32, - fetch_texel_1d_f_alpha_f32, - fetch_texel_2d_f_alpha_f32, - fetch_texel_3d_f_alpha_f32, - store_texel_alpha_f32 - }, - { - MESA_FORMAT_ALPHA_FLOAT16, - fetch_texel_1d_f_alpha_f16, - fetch_texel_2d_f_alpha_f16, - fetch_texel_3d_f_alpha_f16, - store_texel_alpha_f16 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT32, - fetch_texel_1d_f_luminance_f32, - fetch_texel_2d_f_luminance_f32, - fetch_texel_3d_f_luminance_f32, - store_texel_luminance_f32 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT16, - fetch_texel_1d_f_luminance_f16, - fetch_texel_2d_f_luminance_f16, - fetch_texel_3d_f_luminance_f16, - store_texel_luminance_f16 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - fetch_texel_1d_f_luminance_alpha_f32, - fetch_texel_2d_f_luminance_alpha_f32, - fetch_texel_3d_f_luminance_alpha_f32, - store_texel_luminance_alpha_f32 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - fetch_texel_1d_f_luminance_alpha_f16, - fetch_texel_2d_f_luminance_alpha_f16, - fetch_texel_3d_f_luminance_alpha_f16, - store_texel_luminance_alpha_f16 - }, - { - MESA_FORMAT_INTENSITY_FLOAT32, - fetch_texel_1d_f_intensity_f32, - fetch_texel_2d_f_intensity_f32, - fetch_texel_3d_f_intensity_f32, - store_texel_intensity_f32 - }, - { - MESA_FORMAT_INTENSITY_FLOAT16, - fetch_texel_1d_f_intensity_f16, - fetch_texel_2d_f_intensity_f16, - fetch_texel_3d_f_intensity_f16, - store_texel_intensity_f16 - }, - { - MESA_FORMAT_DUDV8, - fetch_texel_1d_dudv8, - fetch_texel_2d_dudv8, - fetch_texel_3d_dudv8, - NULL - }, - { - MESA_FORMAT_SIGNED_RGBA8888, - fetch_texel_1d_signed_rgba8888, - fetch_texel_2d_signed_rgba8888, - fetch_texel_3d_signed_rgba8888, - store_texel_signed_rgba8888 - }, - { - MESA_FORMAT_SIGNED_RGBA8888_REV, - fetch_texel_1d_signed_rgba8888_rev, - fetch_texel_2d_signed_rgba8888_rev, - fetch_texel_3d_signed_rgba8888_rev, - store_texel_signed_rgba8888_rev - }, - { - MESA_FORMAT_SIGNED_RGBA_16, - NULL, /* XXX to do */ - NULL, - NULL, - NULL + MESA_FORMAT_NONE, + fetch_null_texelf, + fetch_null_texelf, + fetch_null_texelf, + store_null_texel }, + { MESA_FORMAT_RGBA8888, fetch_texel_1d_f_rgba8888, @@ -563,56 +354,271 @@ texfetch_funcs[MESA_FORMAT_COUNT] = fetch_texel_2d_f_z32, fetch_texel_3d_f_z32, store_texel_z32 - } + }, + { + MESA_FORMAT_S8, + NULL, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_SRGB8, + fetch_texel_1d_srgb8, + fetch_texel_2d_srgb8, + fetch_texel_3d_srgb8, + store_texel_srgb8 + }, + { + MESA_FORMAT_SRGBA8, + fetch_texel_1d_srgba8, + fetch_texel_2d_srgba8, + fetch_texel_3d_srgba8, + store_texel_srgba8 + }, + { + MESA_FORMAT_SARGB8, + fetch_texel_1d_sargb8, + fetch_texel_2d_sargb8, + fetch_texel_3d_sargb8, + store_texel_sargb8 + }, + { + MESA_FORMAT_SL8, + fetch_texel_1d_sl8, + fetch_texel_2d_sl8, + fetch_texel_3d_sl8, + store_texel_sl8 + }, + { + MESA_FORMAT_SLA8, + fetch_texel_1d_sla8, + fetch_texel_2d_sla8, + fetch_texel_3d_sla8, + store_texel_sla8 + }, + { + MESA_FORMAT_SRGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt5, + NULL, + NULL + }, + + { + MESA_FORMAT_RGB_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt5, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FLOAT32, + fetch_texel_1d_f_rgba_f32, + fetch_texel_2d_f_rgba_f32, + fetch_texel_3d_f_rgba_f32, + store_texel_rgba_f32 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + fetch_texel_1d_f_rgba_f16, + fetch_texel_2d_f_rgba_f16, + fetch_texel_3d_f_rgba_f16, + store_texel_rgba_f16 + }, + { + MESA_FORMAT_RGB_FLOAT32, + fetch_texel_1d_f_rgb_f32, + fetch_texel_2d_f_rgb_f32, + fetch_texel_3d_f_rgb_f32, + store_texel_rgb_f32 + }, + { + MESA_FORMAT_RGB_FLOAT16, + fetch_texel_1d_f_rgb_f16, + fetch_texel_2d_f_rgb_f16, + fetch_texel_3d_f_rgb_f16, + store_texel_rgb_f16 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + fetch_texel_1d_f_alpha_f32, + fetch_texel_2d_f_alpha_f32, + fetch_texel_3d_f_alpha_f32, + store_texel_alpha_f32 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + fetch_texel_1d_f_alpha_f16, + fetch_texel_2d_f_alpha_f16, + fetch_texel_3d_f_alpha_f16, + store_texel_alpha_f16 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + fetch_texel_1d_f_luminance_f32, + fetch_texel_2d_f_luminance_f32, + fetch_texel_3d_f_luminance_f32, + store_texel_luminance_f32 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + fetch_texel_1d_f_luminance_f16, + fetch_texel_2d_f_luminance_f16, + fetch_texel_3d_f_luminance_f16, + store_texel_luminance_f16 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + fetch_texel_1d_f_luminance_alpha_f32, + fetch_texel_2d_f_luminance_alpha_f32, + fetch_texel_3d_f_luminance_alpha_f32, + store_texel_luminance_alpha_f32 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + fetch_texel_1d_f_luminance_alpha_f16, + fetch_texel_2d_f_luminance_alpha_f16, + fetch_texel_3d_f_luminance_alpha_f16, + store_texel_luminance_alpha_f16 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + fetch_texel_1d_f_intensity_f32, + fetch_texel_2d_f_intensity_f32, + fetch_texel_3d_f_intensity_f32, + store_texel_intensity_f32 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + fetch_texel_1d_f_intensity_f16, + fetch_texel_2d_f_intensity_f16, + fetch_texel_3d_f_intensity_f16, + store_texel_intensity_f16 + }, + { + MESA_FORMAT_DUDV8, + fetch_texel_1d_dudv8, + fetch_texel_2d_dudv8, + fetch_texel_3d_dudv8, + NULL + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + fetch_texel_1d_signed_rgba8888, + fetch_texel_2d_signed_rgba8888, + fetch_texel_3d_signed_rgba8888, + store_texel_signed_rgba8888 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + fetch_texel_1d_signed_rgba8888_rev, + fetch_texel_2d_signed_rgba8888_rev, + fetch_texel_3d_signed_rgba8888_rev, + store_texel_signed_rgba8888_rev + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + NULL, /* XXX to do */ + NULL, + NULL, + NULL + }, }; static FetchTexelFuncF _mesa_get_texel_fetch_func(gl_format format, GLuint dims) { - FetchTexelFuncF f = NULL; - GLuint i; - /* XXX replace loop with direct table lookup */ - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - if (texfetch_funcs[i].Name == format) { - switch (dims) { - case 1: - f = texfetch_funcs[i].Fetch1D; - break; - case 2: - f = texfetch_funcs[i].Fetch2D; - break; - case 3: - f = texfetch_funcs[i].Fetch3D; - break; - } - if (!f) - f = fetch_null_texelf; - return f; - } +#ifdef DEBUG + /* check that the table entries are sorted by format name */ + gl_format fmt; + for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) { + assert(texfetch_funcs[fmt].Name == fmt); + } +#endif + + assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); + assert(format < MESA_FORMAT_COUNT); + + switch (dims) { + case 1: + return texfetch_funcs[format].Fetch1D; + case 2: + return texfetch_funcs[format].Fetch2D; + case 3: + return texfetch_funcs[format].Fetch3D; + default: + assert(0 && "bad dims in _mesa_get_texel_fetch_func"); + return NULL; } - return NULL; } StoreTexelFunc _mesa_get_texel_store_func(gl_format format) { - GLuint i; - /* XXX replace loop with direct table lookup */ - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - if (texfetch_funcs[i].Name == format) { - if (texfetch_funcs[i].StoreTexel) - return texfetch_funcs[i].StoreTexel; - else - return store_null_texel; - } - } - return NULL; + assert(format < MESA_FORMAT_COUNT); + return texfetch_funcs[format].StoreTexel; } - /** * Adaptor for fetching a GLchan texel from a float-valued texture. */ -- cgit v1.2.3 From e65b11525ada0e80943a92fe659cad986ec8c613 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 10:47:53 -0600 Subject: st/mesa: refactor depth/stencil format selection code --- src/mesa/state_tracker/st_format.c | 57 ++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index d7f5b1ea247..b9f0c1fde69 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -420,6 +420,49 @@ default_depth_format(struct pipe_screen *screen, } +static enum pipe_format +default_depth_stencil_format(struct pipe_screen *screen, + enum pipe_texture_target target, + unsigned tex_usage, + unsigned geom_flags) +{ + static const enum pipe_format zsFormats[] = { + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM + }; + uint i; + for (i = 0; i < Elements(zsFormats); i++) { + if (screen->is_format_supported( screen, zsFormats[i], target, + tex_usage, geom_flags )) { + return zsFormats[i]; + } + } + return PIPE_FORMAT_NONE; +} + + +static enum pipe_format +default_stencil_format(struct pipe_screen *screen, + enum pipe_texture_target target, + unsigned tex_usage, + unsigned geom_flags) +{ + static const enum pipe_format sFormats[] = { + PIPE_FORMAT_S8_USCALED, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM + }; + uint i; + for (i = 0; i < Elements(sFormats); i++) { + if (screen->is_format_supported( screen, sFormats[i], target, + tex_usage, geom_flags )) { + return sFormats[i]; + } + } + return PIPE_FORMAT_NONE; +} + + /** * Given an OpenGL internalFormat value for a texture or surface, return * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match. @@ -577,21 +620,11 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX8_EXT: case GL_STENCIL_INDEX16_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8_USCALED; - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24_UNORM_S8_USCALED; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8_USCALED_Z24_UNORM; - return PIPE_FORMAT_NONE; + return default_stencil_format(screen, target, tex_usage, geom_flags); case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) - return PIPE_FORMAT_Z24_UNORM_S8_USCALED; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8_USCALED_Z24_UNORM; - return PIPE_FORMAT_NONE; + return default_depth_stencil_format(screen, target, tex_usage, geom_flags); case GL_SRGB_EXT: case GL_SRGB8_EXT: -- cgit v1.2.3 From 1143221cfd4c42e7767f8ccaefb00e145b7d5efe Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 11:04:04 -0600 Subject: st/mesa: consolidate code for finding supported formats --- src/mesa/state_tracker/st_format.c | 149 ++++++++++++++----------------------- 1 file changed, 57 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index b9f0c1fde69..875b65c5b52 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -302,6 +302,28 @@ st_pipe_format_to_mesa_format(enum pipe_format format) } +/** + * Return first supported format from the given list. + */ +static enum pipe_format +find_supported_format(struct pipe_screen *screen, + const enum pipe_format formats[], + uint num_formats, + enum pipe_texture_target target, + unsigned tex_usage, + unsigned geom_flags) +{ + uint i; + for (i = 0; i < num_formats; i++) { + if (screen->is_format_supported(screen, formats[i], target, + tex_usage, geom_flags)) { + return formats[i]; + } + } + return PIPE_FORMAT_NONE; +} + + /** * Find an RGBA format supported by the context/winsys. */ @@ -317,15 +339,11 @@ default_rgba_format(struct pipe_screen *screen, PIPE_FORMAT_A8B8G8R8_UNORM, PIPE_FORMAT_B5G6R5_UNORM }; - uint i; - for (i = 0; i < Elements(colorFormats); i++) { - if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) { - return colorFormats[i]; - } - } - return PIPE_FORMAT_NONE; + return find_supported_format(screen, colorFormats, Elements(colorFormats), + target, tex_usage, geom_flags); } + /** * Find an RGB format supported by the context/winsys. */ @@ -344,13 +362,8 @@ default_rgb_format(struct pipe_screen *screen, PIPE_FORMAT_A8B8G8R8_UNORM, PIPE_FORMAT_B5G6R5_UNORM }; - uint i; - for (i = 0; i < Elements(colorFormats); i++) { - if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) { - return colorFormats[i]; - } - } - return PIPE_FORMAT_NONE; + return find_supported_format(screen, colorFormats, Elements(colorFormats), + target, tex_usage, geom_flags); } /** @@ -367,15 +380,11 @@ default_srgba_format(struct pipe_screen *screen, PIPE_FORMAT_A8R8G8B8_SRGB, PIPE_FORMAT_A8B8G8R8_SRGB, }; - uint i; - for (i = 0; i < Elements(colorFormats); i++) { - if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) { - return colorFormats[i]; - } - } - return PIPE_FORMAT_NONE; + return find_supported_format(screen, colorFormats, Elements(colorFormats), + target, tex_usage, geom_flags); } + /** * Search list of formats for first RGBA format with >8 bits/channel. */ @@ -395,74 +404,6 @@ default_deep_rgba_format(struct pipe_screen *screen, } -/** - * Find an Z format supported by the context/winsys. - */ -static enum pipe_format -default_depth_format(struct pipe_screen *screen, - enum pipe_texture_target target, - unsigned tex_usage, - unsigned geom_flags) -{ - static const enum pipe_format zFormats[] = { - PIPE_FORMAT_Z16_UNORM, - PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_FORMAT_S8_USCALED_Z24_UNORM - }; - uint i; - for (i = 0; i < Elements(zFormats); i++) { - if (screen->is_format_supported( screen, zFormats[i], target, tex_usage, geom_flags )) { - return zFormats[i]; - } - } - return PIPE_FORMAT_NONE; -} - - -static enum pipe_format -default_depth_stencil_format(struct pipe_screen *screen, - enum pipe_texture_target target, - unsigned tex_usage, - unsigned geom_flags) -{ - static const enum pipe_format zsFormats[] = { - PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_FORMAT_S8_USCALED_Z24_UNORM - }; - uint i; - for (i = 0; i < Elements(zsFormats); i++) { - if (screen->is_format_supported( screen, zsFormats[i], target, - tex_usage, geom_flags )) { - return zsFormats[i]; - } - } - return PIPE_FORMAT_NONE; -} - - -static enum pipe_format -default_stencil_format(struct pipe_screen *screen, - enum pipe_texture_target target, - unsigned tex_usage, - unsigned geom_flags) -{ - static const enum pipe_format sFormats[] = { - PIPE_FORMAT_S8_USCALED, - PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_FORMAT_S8_USCALED_Z24_UNORM - }; - uint i; - for (i = 0; i < Elements(sFormats); i++) { - if (screen->is_format_supported( screen, sFormats[i], target, - tex_usage, geom_flags )) { - return sFormats[i]; - } - } - return PIPE_FORMAT_NONE; -} - - /** * Given an OpenGL internalFormat value for a texture or surface, return * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match. @@ -613,18 +554,42 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_Z32_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT: - return default_depth_format( screen, target, tex_usage, geom_flags ); + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_Z16_UNORM, + PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM + }; + return find_supported_format(screen, formats, Elements(formats), + target, tex_usage, geom_flags); + } case GL_STENCIL_INDEX: case GL_STENCIL_INDEX1_EXT: case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX8_EXT: case GL_STENCIL_INDEX16_EXT: - return default_stencil_format(screen, target, tex_usage, geom_flags); + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_S8_USCALED, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM + }; + return find_supported_format(screen, formats, Elements(formats), + target, tex_usage, geom_flags); + } case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - return default_depth_stencil_format(screen, target, tex_usage, geom_flags); + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM + }; + return find_supported_format(screen, formats, Elements(formats), + target, tex_usage, geom_flags); + } case GL_SRGB_EXT: case GL_SRGB8_EXT: -- cgit v1.2.3 From 50d77c79fbcdf6a33691bfa120d54528d28091a4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 11:33:26 -0600 Subject: gallium: fix comment language, remove dangling comment --- src/gallium/include/pipe/p_defines.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 0a4bd584aec..48edfbfcce7 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -291,10 +291,10 @@ enum pipe_transfer_usage { #define PIPE_BIND_TRANSFER_READ (1 << 10) /* get_transfer */ #define PIPE_BIND_CUSTOM (1 << 16) /* state-tracker/winsys usages */ -/* The first two flags were previously part of the amorphous +/* The first two flags above were previously part of the amorphous * TEXTURE_USAGE, most of which are now descriptions of the ways a - * particular texture can be bound to the gallium pipeline. These two - * do not fit within that and probably need to be migrated to some + * particular texture can be bound to the gallium pipeline. The two flags + * below do not fit within that and probably need to be migrated to some * other place. * * It seems like scanout is used by the Xorg state tracker to ask for @@ -304,7 +304,7 @@ enum pipe_transfer_usage { * * The shared flag is quite underspecified, but certainly isn't a * binding flag - it seems more like a message to the winsys to create - * a shareable allocation. Could it mean that this texture is a valid argument for + * a shareable allocation. */ #define PIPE_BIND_SCANOUT (1 << 14) /* */ #define PIPE_BIND_SHARED (1 << 15) /* get_texture_handle ??? */ -- cgit v1.2.3 From 8bee4c7718a3bd57e3d99f0913d9081cd13fe5fd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 18:22:22 +0100 Subject: llvmpipe: Use resource_is_texture() consistently. Otherwise slightly difference order causes assertion failures. Also remove mentions of PIPE_BIND_SCANOUT/PIPE_BIND_SHARED. They are not propoer bind flags and will likely be deprecated. If surfaces should be passed to the winsys then they should have the DISPLAY_TARGET flag set, which is a proper bind flag. --- src/gallium/drivers/llvmpipe/lp_screen.c | 4 +--- src/gallium/drivers/llvmpipe/lp_texture.c | 37 +++++++++++++------------------ 2 files changed, 16 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index f453b9fe5ae..7d2cd0c7679 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -194,9 +194,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, return FALSE; } - if(tex_usage & (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED)) { + if(tex_usage & PIPE_BIND_DISPLAY_TARGET) { if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format)) return FALSE; } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 4fce02ac713..336a4e4c016 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -193,20 +193,20 @@ llvmpipe_resource_create(struct pipe_screen *_screen, assert(lpr->base.bind); - if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED)) { - /* displayable surface */ - if (!llvmpipe_displaytarget_layout(screen, lpr)) - goto fail; - assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE); - } - else if (lpr->base.bind & (PIPE_BIND_SAMPLER_VIEW | - PIPE_BIND_DEPTH_STENCIL)) { - /* texture map */ - if (!llvmpipe_texture_layout(screen, lpr)) - goto fail; - assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE); + if (resource_is_texture(&lpr->base)) { + if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) { + /* displayable surface */ + if (!llvmpipe_displaytarget_layout(screen, lpr)) + goto fail; + assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE); + } + else { + /* texture map */ + if (!llvmpipe_texture_layout(screen, lpr)) + goto fail; + assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE); + } + assert(lpr->layout[0]); } else { /* other data (vertex buffer, const buffer, etc) */ @@ -221,10 +221,6 @@ llvmpipe_resource_create(struct pipe_screen *_screen, goto fail; } - if (resource_is_texture(&lpr->base)) { - assert(lpr->layout[0]); - } - lpr->id = id_counter++; return &lpr->base; @@ -393,10 +389,7 @@ llvmpipe_resource_data(struct pipe_resource *resource) { struct llvmpipe_resource *lpr = llvmpipe_resource(resource); - assert((lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED | - PIPE_BIND_SAMPLER_VIEW)) == 0); + assert(!resource_is_texture(resource)); return lpr->data; } -- cgit v1.2.3 From 63aa9b505a2439399af3e6ed47c5a0b1b791fba8 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Apr 2010 13:00:48 -0400 Subject: gallivm: make sure we return the correct type when approximating log's --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 8e8fcccf564..d6967633172 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -1502,8 +1502,10 @@ lp_build_log2_approx(struct lp_build_context *bld, res = LLVMBuildAdd(bld->builder, logmant, logexp, ""); } - if(p_exp) + if(p_exp) { + exp = LLVMConstBitCast(exp, vec_type); *p_exp = exp; + } if(p_floor_log2) *p_floor_log2 = logexp; -- cgit v1.2.3 From 3a423dcf9dfa725a4e5dca60f0f2b02599d2ed9b Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Apr 2010 13:43:37 -0400 Subject: gallivm: fix nested break statemants --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 44f8aec1bf0..b87817dd0d4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -232,6 +232,8 @@ static void lp_exec_bgnloop(struct lp_exec_mask *mask) mask->break_mask = LLVMConstAllOnes(mask->int_vec_type); if (mask->cond_stack_size == 0) mask->cond_mask = LLVMConstAllOnes(mask->int_vec_type); + + mask->break_stack[mask->break_stack_size++] = mask->break_mask; mask->loop_stack[mask->loop_stack_size++] = mask->loop_block; mask->loop_block = lp_build_insert_new_block(mask->bld->builder, "bgnloop"); LLVMBuildBr(mask->bld->builder, mask->loop_block); @@ -246,7 +248,6 @@ static void lp_exec_break(struct lp_exec_mask *mask) mask->exec_mask, "break"); - mask->break_stack[mask->break_stack_size++] = mask->break_mask; if (mask->break_stack_size > 1) { mask->break_mask = LLVMBuildAnd(mask->bld->builder, mask->break_mask, @@ -304,7 +305,7 @@ static void lp_exec_endloop(struct lp_exec_mask *mask) mask->cont_mask = mask->cont_stack[--mask->cont_stack_size]; } if (mask->break_stack_size) { - mask->break_mask = mask->cont_stack[--mask->break_stack_size]; + mask->break_mask = mask->break_stack[--mask->break_stack_size]; } lp_exec_mask_update(mask); -- cgit v1.2.3 From 6d2e09fdc23e2573e9466f60db20ef4ac04b367d Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Apr 2010 13:45:25 -0400 Subject: gallivm: fix nested cont statements --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index b87817dd0d4..e55e3dce674 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -234,6 +234,7 @@ static void lp_exec_bgnloop(struct lp_exec_mask *mask) mask->cond_mask = LLVMConstAllOnes(mask->int_vec_type); mask->break_stack[mask->break_stack_size++] = mask->break_mask; + mask->cont_stack[mask->cont_stack_size++] = mask->cont_mask; mask->loop_stack[mask->loop_stack_size++] = mask->loop_block; mask->loop_block = lp_build_insert_new_block(mask->bld->builder, "bgnloop"); LLVMBuildBr(mask->bld->builder, mask->loop_block); @@ -264,7 +265,6 @@ static void lp_exec_continue(struct lp_exec_mask *mask) mask->exec_mask, ""); - mask->cont_stack[mask->cont_stack_size++] = mask->cont_mask; if (mask->cont_stack_size > 1) { mask->cont_mask = LLVMBuildAnd(mask->bld->builder, mask->cont_mask, -- cgit v1.2.3 From 18a4a83ddab7655253fdb71d37393a32adcda488 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Apr 2010 13:56:54 -0400 Subject: gallivm: update comments --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index e55e3dce674..53a5ce0cd87 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -169,8 +169,7 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context static void lp_exec_mask_update(struct lp_exec_mask *mask) { if (mask->loop_stack_size) { - /*for loops we need to update the entire mask at - * runtime */ + /*for loops we need to update the entire mask at runtime */ LLVMValueRef tmp; assert(mask->break_mask); tmp = LLVMBuildAnd(mask->bld->builder, @@ -249,6 +248,10 @@ static void lp_exec_break(struct lp_exec_mask *mask) mask->exec_mask, "break"); + /* mask->break_stack_size > 1 implies that we encountered a break + * statemant already and if that's the case we want to make sure + * our mask is a combination of the previous break and the current + * execution mask */ if (mask->break_stack_size > 1) { mask->break_mask = LLVMBuildAnd(mask->bld->builder, mask->break_mask, @@ -300,10 +303,11 @@ static void lp_exec_endloop(struct lp_exec_mask *mask) LLVMPositionBuilderAtEnd(mask->bld->builder, endloop); mask->loop_block = mask->loop_stack[--mask->loop_stack_size]; - /* pop the break mask */ + /* pop the cont mask */ if (mask->cont_stack_size) { mask->cont_mask = mask->cont_stack[--mask->cont_stack_size]; } + /* pop the break mask */ if (mask->break_stack_size) { mask->break_mask = mask->break_stack[--mask->break_stack_size]; } @@ -311,6 +315,11 @@ static void lp_exec_endloop(struct lp_exec_mask *mask) lp_exec_mask_update(mask); } +/* stores val into an address pointed to by dst. + * mask->exec_mask is used to figure out which bits of val + * should be stored into the address + * (0 means don't store this bit, 1 means do store). + */ static void lp_exec_mask_store(struct lp_exec_mask *mask, LLVMValueRef val, LLVMValueRef dst) -- cgit v1.2.3 From ccdc6b5913885866e100780bfd661672c9a5d23c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 19:23:40 +0100 Subject: llvmpipe: Fix rendering to non 32bpp formats. Tiled layout always used 32bpp, therefore linear/tiled strides are not related. --- src/gallium/drivers/llvmpipe/lp_texture.c | 12 ++++++++---- src/gallium/drivers/llvmpipe/lp_tile_image.c | 22 ++++++++-------------- src/gallium/drivers/llvmpipe/lp_tile_image.h | 8 ++++++-- 3 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 336a4e4c016..f766ab2300a 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -991,14 +991,16 @@ llvmpipe_get_texture_image(struct llvmpipe_resource *lpr, x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } else { lp_tiled_to_linear(other_data, target_data, x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } } @@ -1087,7 +1089,8 @@ llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr, if (convert) { lp_tiled_to_linear(tiled_image, linear_image, x, y, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } if (new_layout != cur_layout) @@ -1135,7 +1138,8 @@ llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr, if (convert) { lp_linear_to_tiled(linear_image, tiled_image, x, y, TILE_SIZE, TILE_SIZE, lpr->base.format, - lpr->row_stride[level]); + lpr->row_stride[level], + lpr->tiles_per_row[level]); } if (new_layout != cur_layout) diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c b/src/gallium/drivers/llvmpipe/lp_tile_image.c index 0852150ba72..af3d1573270 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_image.c +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c @@ -122,14 +122,15 @@ tile_4_4_uint16(const uint16_t *src, uint16_t *dst, unsigned src_stride) /** * Convert a tiled image into a linear image. - * \param src_stride source row stride in bytes (bytes per row of tiles) * \param dst_stride dest row stride in bytes */ void lp_tiled_to_linear(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned dst_stride) + enum pipe_format format, + unsigned dst_stride, + unsigned tiles_per_row) { assert(x % TILE_SIZE == 0); assert(y % TILE_SIZE == 0); @@ -141,9 +142,7 @@ lp_tiled_to_linear(const void *src, void *dst, */ if (util_format_is_depth_or_stencil(format)) { const uint bpp = util_format_get_blocksize(format); - const uint src_stride = dst_stride * TILE_VECTOR_WIDTH; const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT; - const uint tiles_per_row = src_stride / (tile_w * tile_h * bpp); dst_stride /= bpp; /* convert from bytes to words */ @@ -191,8 +190,6 @@ lp_tiled_to_linear(const void *src, void *dst, const uint bpp = 4; const uint tile_w = TILE_SIZE, tile_h = TILE_SIZE; const uint bytes_per_tile = tile_w * tile_h * bpp; - const uint src_stride = dst_stride * tile_w; - const uint tiles_per_row = src_stride / bytes_per_tile; uint i, j; for (j = 0; j < height; j += tile_h) { @@ -215,13 +212,14 @@ lp_tiled_to_linear(const void *src, void *dst, /** * Convert a linear image into a tiled image. * \param src_stride source row stride in bytes - * \param dst_stride dest row stride in bytes (bytes per row of tiles) */ void lp_linear_to_tiled(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned src_stride) + enum pipe_format format, + unsigned src_stride, + unsigned tiles_per_row) { assert(x % TILE_SIZE == 0); assert(y % TILE_SIZE == 0); @@ -232,9 +230,7 @@ lp_linear_to_tiled(const void *src, void *dst, if (util_format_is_depth_or_stencil(format)) { const uint bpp = util_format_get_blocksize(format); - const uint dst_stride = src_stride * TILE_VECTOR_WIDTH; const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT; - const uint tiles_per_row = dst_stride / (tile_w * tile_h * bpp); src_stride /= bpp; /* convert from bytes to words */ @@ -281,8 +277,6 @@ lp_linear_to_tiled(const void *src, void *dst, const uint bpp = 4; const uint tile_w = TILE_SIZE, tile_h = TILE_SIZE; const uint bytes_per_tile = tile_w * tile_h * bpp; - const uint dst_stride = src_stride * tile_w; - const uint tiles_per_row = dst_stride / bytes_per_tile; uint i, j; for (j = 0; j < height; j += TILE_SIZE) { @@ -320,10 +314,10 @@ test_tiled_linear_conversion(void *data, /*unsigned tiled_stride = wt * TILE_SIZE * TILE_SIZE * 4;*/ lp_linear_to_tiled(data, tiled, 0, 0, width, height, format, - stride); + stride, wt); lp_tiled_to_linear(tiled, data, 0, 0, width, height, format, - stride); + stride, wt); free(tiled); } diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.h b/src/gallium/drivers/llvmpipe/lp_tile_image.h index d74621925d5..8de8efc6c16 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_image.h +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.h @@ -33,14 +33,18 @@ void lp_tiled_to_linear(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned dst_stride); + enum pipe_format format, + unsigned dst_stride, + unsigned tiles_per_row); void lp_linear_to_tiled(const void *src, void *dst, unsigned x, unsigned y, unsigned width, unsigned height, - enum pipe_format format, unsigned src_stride); + enum pipe_format format, + unsigned src_stride, + unsigned tiles_per_row); void -- cgit v1.2.3 From cdaceaafee01867d289c2b72fed9c7a200a9e350 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 19:24:30 +0100 Subject: llvmpipe: Portability fixes. --- src/gallium/drivers/llvmpipe/lp_rast.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_texture.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 4046701b85a..0a41b6406bd 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -123,8 +123,8 @@ lp_rast_end( struct lp_rasterizer *rast ) rast->curr_scene = NULL; if (0) - printf("Post render scene: tile read: %d tile write: %d\n", - tile_read_count, tile_write_count); + debug_printf("Post render scene: tile read: %d tile write: %d\n", + tile_read_count, tile_write_count); } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index f766ab2300a..336b487bd4e 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -85,7 +85,7 @@ alloc_layout_array(unsigned num_slices, unsigned width, unsigned height) assert(LP_TEX_LAYOUT_NONE == 0); /* calloc'ing LP_TEX_LAYOUT_NONE here */ return (enum lp_texture_layout *) - calloc(num_slices * tx * ty, sizeof(enum lp_texture_layout)); + CALLOC(num_slices * tx * ty, sizeof(enum lp_texture_layout)); } @@ -265,7 +265,7 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, /* free layout flag arrays */ for (level = 0; level < Elements(lpr->tiled); level++) { - free(lpr->layout[level]); + FREE(lpr->layout[level]); lpr->layout[level] = NULL; } } -- cgit v1.2.3 From f836a5f60b700fca051c6f7cc36fb77965226408 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 12:44:40 -0600 Subject: gallium/docs: many updates to screen.rst Put PIPE_BIND_ and PIPE_TEXTURE_GEOM_ prefixes on token names so that they can be found with grep. This needs to be done in more places. Corrected/improved a lot of information and grammer. I don't know how to properly format everything - someone else can take care of that. --- src/gallium/docs/source/screen.rst | 154 ++++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index b6efd1d40cf..05688cc1f23 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -3,16 +3,19 @@ Screen A screen is an object representing the context-independent part of a device. -Useful Flags ------------- +Flags and enumerations +---------------------- + +XXX some of these don't belong in this section. + .. _pipe_cap: -PIPE_CAP -^^^^^^^^ +PIPE_CAP_* +^^^^^^^^^^ -Pipe capabilities help expose hardware functionality not explicitly required -by Gallium. For floating-point values, use :ref:`get_paramf`, and for boolean +Capability queries return information about the features and limits of the +driver/GPU. For floating-point values, use :ref:`get_paramf`, and for boolean or integer values, use :ref:`get_param`. The integer capabilities: @@ -56,6 +59,19 @@ The integer capabilities: to any shader stage using ``set_constant_buffer``. If 0 or 1, the pipe will only permit binding one constant buffer per shader, and the shaders will not permit two-dimensional access to constants. + +If a value greater than 0 is returned, the driver can have multiple +constant buffers bound to shader stages. The CONST register file can +be accessed with two-dimensional indices, like in the example below. + +DCL CONST[0][0..7] # declare first 8 vectors of constbuf 0 +DCL CONST[3][0] # declare first vector of constbuf 3 +MOV OUT[0], CONST[0][3] # copy vector 3 of constbuf 0 + +For backwards compatibility, one-dimensional access to CONST register +file is still supported. In that case, the constbuf index is assumed +to be 0. + * ``MAX_CONST_BUFFER_SIZE``: Maximum byte size of a single constant buffer. * ``INDEP_BLEND_ENABLE``: Whether per-rendertarget blend enabling and channel masks are supported. If 0, then the first rendertarget's blend mask is @@ -85,64 +101,54 @@ The floating-point capabilities: * ``GUARD_BAND_LEFT``, ``GUARD_BAND_TOP``, ``GUARD_BAND_RIGHT``, ``GUARD_BAND_BOTTOM``: XXX -XXX Is there a better home for this? vvv - -If 0 is returned, the driver is not aware of multiple constant buffers, -supports binding of only one constant buffer, and does not support -two-dimensional CONST register file access in TGSI shaders. - -If a value greater than 0 is returned, the driver can have multiple -constant buffers bound to shader stages. The CONST register file can -be accessed with two-dimensional indices, like in the example below. - -DCL CONST[0][0..7] # declare first 8 vectors of constbuf 0 -DCL CONST[3][0] # declare first vector of constbuf 3 -MOV OUT[0], CONST[0][3] # copy vector 3 of constbuf 0 -For backwards compatibility, one-dimensional access to CONST register -file is still supported. In that case, the constbuf index is assumed -to be 0. .. _pipe_bind: -PIPE_BIND -^^^^^^^^^ +PIPE_BIND_* +^^^^^^^^^^^ -These flags control resource creation. Resources may be used in different roles +These flags indicate how a resource will be used and are specified at resource +creation time. Resources may be used in different roles during their lifecycle. Bind flags are cumulative and may be combined to create -a resource which can be used as multiple things. -Depending on the pipe driver's memory management, depending on these bind flags +a resource which can be used for multiple things. +Depending on the pipe driver's memory management and these bind flags, resources might be created and handled quite differently. -* ``RENDER_TARGET``: A color buffer or pixel buffer which will be rendered to. -* ``DISPLAY_TARGET``: A sharable buffer that can be given to another process. -* ``DEPTH_STENCIL``: A depth (Z) buffer or stencil buffer. Gallium does - not explicitly provide for stencil-only buffers, so any stencil buffer - validated here is implicitly also a depth buffer. -* ``SAMPLER_VIEW``: A texture that may be sampled from in a fragment or vertex - shader. -* ``VERTEX_BUFFER``: A vertex buffer. -* ``INDEX_BUFFER``: An element buffer. -* ``CONSTANT_BUFFER``: A buffer of shader constants. -* ``BLIT_SOURCE``: A blit source, as given to surface_copy. -* ``BLIT_DESTINATION``: A blit destination, as given to surface_copy and surface_fill. -* ``TRANSFER_WRITE``: A transfer object which will be written to. -* ``TRANSFER_READ``: A transfer object which will be read from. -* ``CUSTOM``: -* ``SCANOUT``: A front color buffer or scanout buffer. -* ``SHARED``: +* ``PIPE_BIND_RENDER_TARGET``: A color buffer or pixel buffer which will be + rendered to. Any surface/resource attached to pipe_framebuffer_state::cbufs + must have this flag set. +* ``PIPE_BIND_DEPTH_STENCIL``: A depth (Z) buffer and/or stencil buffer. Any + depth/stencil surface/resource attached to pipe_framebuffer_state::zsbuf must + have this flag set. +* ``PIPE_BIND_DISPLAY_TARGET``: A sharable buffer that can be given to another + process. +* ``PIPE_BIND_SAMPLER_VIEW``: A texture that may be sampled from in a fragment + or vertex shader. +* ``PIPE_BIND_VERTEX_BUFFER``: A vertex buffer. +* ``PIPE_BIND_INDEX_BUFFER``: An vertex index/element buffer. +* ``PIPE_BIND_CONSTANT_BUFFER``: A buffer of shader constants. +* ``PIPE_BIND_BLIT_SOURCE``: A blit source, as given to surface_copy. +* ``PIPE_BIND_BLIT_DESTINATION``: A blit destination, as given to surface_copy + and surface_fill. +* ``PIPE_BIND_TRANSFER_WRITE``: A transfer object which will be written to. +* ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from. +* ``PIPE_BIND_CUSTOM``: +* ``PIPE_BIND_SCANOUT``: A front color buffer or scanout buffer. +* ``PIPE_BIND_SHARED``: .. _pipe_usage: -PIPE_USAGE -^^^^^^^^^^ +PIPE_USAGE_* +^^^^^^^^^^^^ + +The PIPE_USAGE enums are hints about the expected usage pattern of a resource. -The PIPE_USAGE enums are hints about the expected lifecycle of a resource. -* ``DEFAULT``: Expect many uploads to the resource, intermixed with draws. -* ``DYNAMIC``: Expect many uploads to the resource, intermixed with draws. -* ``STATIC``: Same as immutable (?) -* ``IMMUTABLE``: Resource will not be changed after first upload. -* ``STREAM``: Upload will be followed by draw, followed by upload, ... +* ``PIPE_USAGE_DEFAULT``: Expect many uploads to the resource, intermixed with draws. +* ``PIPE_USAGE_DYNAMIC``: Expect many uploads to the resource, intermixed with draws. +* ``PIPE_USAGE_STATIC``: Same as immutable (?) +* ``PIPE_USAGE_IMMUTABLE``: Resource will not be changed after first upload. +* ``PIPE_USAGE_STREAM``: Upload will be followed by draw, followed by upload, ... @@ -162,7 +168,7 @@ For example, a compressed format might only be used for POT textures. Methods ------- -XXX moar; got bored +XXX to-do get_name ^^^^^^^^ @@ -204,9 +210,15 @@ and/or front-buffer rendering. is_format_supported ^^^^^^^^^^^^^^^^^^^ -See if a format can be used in a specific manner. +Determine if a resource in the given format can be used in a specific manner. -**tex_usage** is a bitmask of :ref:`PIPE_BIND` flags. +**format** the resource format + +**target** one of the PIPE_TEXTURE_x flags + +**bindings** is a bitmask of :ref:`PIPE_BIND` flags. + +**geom_flags** is a bitmask of PIPE_TEXTURE_GEOM_x flags. Returns TRUE if all usages can be satisfied. @@ -214,15 +226,35 @@ Returns TRUE if all usages can be satisfied. .. _resource_create: resource_create -^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^ + +Create a new resource from a template. +The following fields of the pipe_resource must be specified in the template: + +target + +format + +width0 + +height0 + +depth0 + +last_level + +nr_samples + +usage + +bind + +flags + -Given a template of texture setup, create a resource. -The way a resource may be used is specifed by bind flags, :ref:`pipe_bind`. -and hints are used to indicate to the driver what access pattern might be -likely, :ref:`pipe_usage`. resource_destroy -^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^ Destroy a resource. A resource is destroyed if it has no more references. -- cgit v1.2.3 From cb384ae8b2028016d66ebf92c9cb2ae3be7d3595 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 19:51:10 +0100 Subject: gallium/docs: Unswap PIPE_BIND_SHARED's comment. --- src/gallium/docs/source/screen.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 05688cc1f23..c5815f8939c 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -121,8 +121,8 @@ resources might be created and handled quite differently. * ``PIPE_BIND_DEPTH_STENCIL``: A depth (Z) buffer and/or stencil buffer. Any depth/stencil surface/resource attached to pipe_framebuffer_state::zsbuf must have this flag set. -* ``PIPE_BIND_DISPLAY_TARGET``: A sharable buffer that can be given to another - process. +* ``PIPE_BIND_DISPLAY_TARGET``: A surface that can be presented to screen. Arguments to + pipe_screen::flush_front_buffer must have this flag set. * ``PIPE_BIND_SAMPLER_VIEW``: A texture that may be sampled from in a fragment or vertex shader. * ``PIPE_BIND_VERTEX_BUFFER``: A vertex buffer. @@ -135,7 +135,8 @@ resources might be created and handled quite differently. * ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from. * ``PIPE_BIND_CUSTOM``: * ``PIPE_BIND_SCANOUT``: A front color buffer or scanout buffer. -* ``PIPE_BIND_SHARED``: +* ``PIPE_BIND_SHARED``: A sharable buffer that can be given to another + process. .. _pipe_usage: -- cgit v1.2.3 From c059565054e80bd6306e1c3a2c7b85ef33082d9f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Apr 2010 20:38:36 +0100 Subject: llvmpipe: Undo zs tiling changes. tile_w/tile_h have different meaning there. This partialy reverts commit ccdc6b5913885866e100780bfd661672c9a5d23c. --- src/gallium/drivers/llvmpipe/lp_tile_image.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c b/src/gallium/drivers/llvmpipe/lp_tile_image.c index af3d1573270..7a2cc3e6b5e 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_image.c +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c @@ -142,7 +142,9 @@ lp_tiled_to_linear(const void *src, void *dst, */ if (util_format_is_depth_or_stencil(format)) { const uint bpp = util_format_get_blocksize(format); + const uint src_stride = dst_stride * TILE_VECTOR_WIDTH; const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT; + const uint tiles_per_row = src_stride / (tile_w * tile_h * bpp); dst_stride /= bpp; /* convert from bytes to words */ @@ -230,7 +232,9 @@ lp_linear_to_tiled(const void *src, void *dst, if (util_format_is_depth_or_stencil(format)) { const uint bpp = util_format_get_blocksize(format); + const uint dst_stride = src_stride * TILE_VECTOR_WIDTH; const uint tile_w = TILE_VECTOR_WIDTH, tile_h = TILE_VECTOR_HEIGHT; + const uint tiles_per_row = dst_stride / (tile_w * tile_h * bpp); src_stride /= bpp; /* convert from bytes to words */ -- cgit v1.2.3 From 234286c0f8b7d30ed49223c648d4c73c1a517ab3 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 22 Apr 2010 12:47:41 -0700 Subject: DRI2: add config query extension Add a new DRI2 configuration query extension. Allows for DRI2 client code to query for common DRI2 configuration options. --- include/GL/internal/dri_interface.h | 14 ++++++++ src/glx/dri_common.c | 5 +++ src/glx/glxclient.h | 4 +++ src/mesa/drivers/dri/common/dri_util.c | 46 +++++++++++++++++++++++++++ src/mesa/drivers/dri/common/dri_util.h | 4 +++ src/mesa/drivers/dri/intel/intel_screen.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_screen.c | 1 + src/mesa/drivers/dri/radeon/radeon_screen.c | 2 ++ src/mesa/drivers/dri/radeon/radeon_screen.h | 2 +- 9 files changed, 78 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index fa9b7c4bf21..a952a1db9b3 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -812,4 +812,18 @@ struct __DRIimageLookupExtensionRec { void *loaderPrivate); }; +/** + * This extension allows for common DRI2 options + */ +#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY" +#define __DRI2_CONFIG_QUERY_VERSION 1 + +typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension; +struct __DRI2configQueryExtensionRec { + __DRIextension base; + + int (*configQueryb)(__DRIscreen *screen, const char *var, GLboolean *val); + int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val); + int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val); +}; #endif diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index e4034161bb3..dbc6082313b 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -403,6 +403,11 @@ dri2BindExtensions(__GLXscreenConfigs *psc) /* internal driver extension, no GL extension exposed */ } #endif + +#ifdef __DRI2_CONFIG_QUERY + if ((strcmp(extensions[i]->name, __DRI2_CONFIG_QUERY) == 0)) + psc->config = (__DRI2configQueryExtension *) extensions[i]; +#endif } } diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 8e5dc785dd9..e4b2c63f775 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -549,6 +549,10 @@ struct __GLXscreenConfigsRec const __DRI2flushExtension *f; #endif +#ifdef __DRI2_CONFIG_QUERY + const __DRI2configQueryExtension *config; +#endif + #endif /** diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index f1bbd386128..16d4cc5e174 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -467,6 +467,41 @@ dri2CreateNewDrawable(__DRIscreen *screen, return pdraw; } +static int +dri2ConfigQueryb(__DRIscreen *screen, const char *var, GLboolean *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_BOOL)) + return -1; + + *val = driQueryOptionb(&screen->optionCache, var); + + return 0; +} + +static int +dri2ConfigQueryi(__DRIscreen *screen, const char *var, GLint *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_INT) && + !driCheckOption(&screen->optionCache, var, DRI_ENUM)) + return -1; + + *val = driQueryOptioni(&screen->optionCache, var); + + return 0; +} + +static int +dri2ConfigQueryf(__DRIscreen *screen, const char *var, GLfloat *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_FLOAT)) + return -1; + + *val = driQueryOptionf(&screen->optionCache, var); + + return 0; +} + + static void dri_get_drawable(__DRIdrawable *pdp) { pdp->refcount++; @@ -739,6 +774,7 @@ dri2CreateNewScreen(int scrn, int fd, static const __DRIextension *emptyExtensionList[] = { NULL }; __DRIscreen *psp; drmVersionPtr version; + driOptionCache options; if (driDriverAPI.InitScreen2 == NULL) return NULL; @@ -771,6 +807,9 @@ dri2CreateNewScreen(int scrn, int fd, psp->DriverAPI = driDriverAPI; + driParseOptionInfo(&options, __dri2ConfigOptions, __dri2NConfigOptions); + driParseConfigFiles(&psp->optionCache, &options, psp->myNum, "dri2"); + return psp; } @@ -813,6 +852,13 @@ const __DRIdri2Extension driDRI2Extension = { dri2CreateNewContext, }; +const __DRI2configQueryExtension dri2ConfigQueryExtension = { + { __DRI2_CONFIG_QUERY, __DRI2_CONFIG_QUERY_VERSION }, + dri2ConfigQueryb, + dri2ConfigQueryi, + dri2ConfigQueryf, +}; + static int driFrameTracking(__DRIdrawable *drawable, GLboolean enable) { diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 038a81604fc..0fe6f1e246c 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -51,6 +51,7 @@ #include #include #include +#include "xmlconfig.h" #include "main/glheader.h" #include "GL/internal/glcore.h" #include "GL/internal/dri_interface.h" @@ -70,6 +71,7 @@ extern const __DRIcopySubBufferExtension driCopySubBufferExtension; extern const __DRIswapControlExtension driSwapControlExtension; extern const __DRIframeTrackingExtension driFrameTrackingExtension; extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension; +extern const __DRI2configQueryExtension dri2ConfigQueryExtension; /** * Used by DRI_VALIDATE_DRAWABLE_INFO @@ -527,6 +529,8 @@ struct __DRIscreenRec { /* The lock actually in use, old sarea or DRI2 */ drmLock *lock; + + driOptionCache optionCache; }; extern void diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 5e3f40836d0..ea739a413e0 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -225,6 +225,7 @@ static const __DRIextension *intelScreenExtensions[] = { &intelTexBufferExtension.base, &intelFlushExtension.base, &intelImageExtension.base, + &dri2ConfigQueryExtension.base, NULL }; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 18db12f6261..78987f633cc 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -236,6 +236,7 @@ static const struct __DRItexBufferExtensionRec nouveau_texbuffer_extension = { static const __DRIextension *nouveau_screen_extensions[] = { &nouveau_flush_extension.base, &nouveau_texbuffer_extension.base, + &dri2ConfigQueryExtension.base, NULL }; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index fca0f8173b9..f8dc814ff01 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -1235,6 +1235,8 @@ radeonCreateScreen( __DRIscreen *sPriv ) screen->extensions[i++] = &r600texOffsetExtension.base; #endif + screen->extensions[i++] = &dri2ConfigQueryExtension.base; + screen->extensions[i++] = NULL; sPriv->extensions = screen->extensions; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 5e6d432e11d..0d7e335fa3a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -105,7 +105,7 @@ typedef struct radeon_screen { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[16]; + const __DRIextension *extensions[17]; int num_gb_pipes; int num_z_pipes; -- cgit v1.2.3 From 45e2b51c853471b79004a954ce3092a253b20b77 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 22 Apr 2010 12:49:03 -0700 Subject: DRI2/GLX: check for vblank_mode in DRI2 GLX code Re-add support for the vblank_mode environment and configuration variable. Useful for benchmarking and app control. --- src/glx/dri2_glx.c | 41 ++++++++++++++++++++++++++++++++-- src/mesa/drivers/dri/common/dri_util.c | 11 +++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 3a53ce91b38..1faaf08f366 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -47,7 +47,12 @@ #include "xf86drm.h" #include "dri2.h" #include "dri_common.h" -#include "../../mesa/drivers/dri/common/dri_util.h" + +/* From xmlpool/options.h, user exposed so should be stable */ +#define DRI_CONF_VBLANK_NEVER 0 +#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1 +#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2 +#define DRI_CONF_VBLANK_ALWAYS_SYNC 3 #undef DRI2_MINOR #define DRI2_MINOR 1 @@ -177,6 +182,7 @@ dri2CreateDrawable(__GLXscreenConfigs * psc, __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; __GLXdisplayPrivate *dpyPriv; __GLXDRIdisplayPrivate *pdp; + GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; pdraw = Xmalloc(sizeof(*pdraw)); if (!pdraw) @@ -187,7 +193,22 @@ dri2CreateDrawable(__GLXscreenConfigs * psc, pdraw->base.drawable = drawable; pdraw->base.psc = psc; pdraw->bufferCount = 0; - pdraw->swap_interval = 1; + pdraw->swap_interval = 1; /* default may be overridden below */ + + if (psc->config) + psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode); + + switch (vblank_mode) { + case DRI_CONF_VBLANK_NEVER: + case DRI_CONF_VBLANK_DEF_INTERVAL_0: + pdraw->swap_interval = 0; + break; + case DRI_CONF_VBLANK_DEF_INTERVAL_1: + case DRI_CONF_VBLANK_ALWAYS_SYNC: + default: + pdraw->swap_interval = 1; + break; + } DRI2CreateDrawable(psc->dpy, xDrawable); @@ -474,7 +495,23 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable, static void dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval) { + __GLXscreenConfigs *psc = pdraw->psc; __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; + + if (psc->config) + psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode); + + switch (vblank_mode) { + case DRI_CONF_VBLANK_NEVER: + return; + case DRI_CONF_VBLANK_ALWAYS_SYNC: + if (interval <= 0) + return; + break; + default: + break; + } DRI2SwapInterval(priv->base.psc->dpy, pdraw->xDrawable, interval); priv->swap_interval = interval; diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 16d4cc5e174..8b3d8c27ce4 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -31,6 +31,17 @@ #include "dri_util.h" #include "drm_sarea.h" #include "utils.h" +#include "vblank.h" +#include "xmlpool.h" + +PUBLIC const char __dri2ConfigOptions[] = + DRI_CONF_BEGIN + DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1) + DRI_CONF_SECTION_END + DRI_CONF_END; + +static const uint __dri2NConfigOptions = 1; #ifndef GLX_OML_sync_control typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t *numerator, int32_t *denominator); -- cgit v1.2.3 From e9bcad4c33c8c39356ee37445768c0e4a6b3f9a2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 14:34:22 -0600 Subject: st/mesa: fix binding flags in st_ChooseTextureFormat() See comment for more info. --- src/mesa/state_tracker/st_format.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 875b65c5b52..3e767507eef 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -36,6 +36,7 @@ #include "main/context.h" #include "main/texstore.h" #include "main/enums.h" +#include "main/image.h" #include "main/macros.h" #include "pipe/p_context.h" @@ -672,12 +673,24 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type) { enum pipe_format pFormat; + uint usage = PIPE_BIND_SAMPLER_VIEW; (void) format; (void) type; + /* GL textures may wind up being render targets, but we don't know + * that in advance. Specify potential render target flags now. + * An alternative would be to destroy and re-create a texture when + * we first start rendering to it. + */ + if (_mesa_is_depth_format(internalFormat) || + _mesa_is_depthstencil_format(internalFormat)) + usage |= PIPE_BIND_DEPTH_STENCIL; + else + usage |= PIPE_BIND_RENDER_TARGET; + pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, - PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); + PIPE_TEXTURE_2D, usage); if (pFormat == PIPE_FORMAT_NONE) return MESA_FORMAT_NONE; -- cgit v1.2.3 From 17249ae8e0e459dea250733a0b3e45036cdb67bd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 14:35:21 -0600 Subject: st/mesa: assert that binding flags are properly set for drawing surfaces --- src/mesa/state_tracker/st_atom_framebuffer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 1cd55463379..52c507da3b3 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -153,6 +153,16 @@ update_framebuffer_state( struct st_context *st ) pipe_surface_reference(&framebuffer->zsbuf, NULL); } +#ifdef DEBUG + /* Make sure the resource binding flags were set properly */ + for (i = 0; i < framebuffer->nr_cbufs; i++) { + assert(framebuffer->cbufs[i]->texture->bind & PIPE_BIND_RENDER_TARGET); + } + if (framebuffer->zsbuf) { + assert(framebuffer->zsbuf->texture->bind & PIPE_BIND_DEPTH_STENCIL); + } +#endif + cso_set_framebuffer(st->cso_context, framebuffer); } -- cgit v1.2.3 From 19b26cb0a2c7a8fa2f462fa16a1b55a68d85604b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 14:35:54 -0600 Subject: gallivm: remove Z/stencil special case code in lp_build_sample_offset() Fixes progs/tests/zreaddraw.c and progs/demos/shadowtex.c --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 54 ++++----------------------- 1 file changed, 8 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index eb75b9b393d..e1b029a879f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -181,54 +181,16 @@ lp_build_sample_offset(struct lp_build_context *bld, LLVMValueRef offset; x_stride = lp_build_const_vec(bld->type, format_desc->block.bits/8); + offset = lp_build_mul(bld, x, x_stride); - if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { - LLVMValueRef x_lo, x_hi; - LLVMValueRef y_lo, y_hi; - LLVMValueRef x_stride_lo, x_stride_hi; - LLVMValueRef y_stride_lo, y_stride_hi; - LLVMValueRef x_offset_lo, x_offset_hi; - LLVMValueRef y_offset_lo, y_offset_hi; - LLVMValueRef offset_lo, offset_hi; - - /* XXX 1D & 3D addressing not done yet */ - assert(!z); - assert(!z_stride); - - x_lo = LLVMBuildAnd(bld->builder, x, bld->one, ""); - y_lo = LLVMBuildAnd(bld->builder, y, bld->one, ""); - - x_hi = LLVMBuildLShr(bld->builder, x, bld->one, ""); - y_hi = LLVMBuildLShr(bld->builder, y, bld->one, ""); - - x_stride_lo = x_stride; - y_stride_lo = lp_build_const_vec(bld->type, 2*format_desc->block.bits/8); - - x_stride_hi = lp_build_const_vec(bld->type, 4*format_desc->block.bits/8); - y_stride_hi = LLVMBuildShl(bld->builder, y_stride, bld->one, ""); - - x_offset_lo = lp_build_mul(bld, x_lo, x_stride_lo); - y_offset_lo = lp_build_mul(bld, y_lo, y_stride_lo); - offset_lo = lp_build_add(bld, x_offset_lo, y_offset_lo); - - x_offset_hi = lp_build_mul(bld, x_hi, x_stride_hi); - y_offset_hi = lp_build_mul(bld, y_hi, y_stride_hi); - offset_hi = lp_build_add(bld, x_offset_hi, y_offset_hi); - - offset = lp_build_add(bld, offset_hi, offset_lo); + if (y && y_stride) { + LLVMValueRef y_offset = lp_build_mul(bld, y, y_stride); + offset = lp_build_add(bld, offset, y_offset); } - else { - offset = lp_build_mul(bld, x, x_stride); - - if (y && y_stride) { - LLVMValueRef y_offset = lp_build_mul(bld, y, y_stride); - offset = lp_build_add(bld, offset, y_offset); - } - - if (z && z_stride) { - LLVMValueRef z_offset = lp_build_mul(bld, z, z_stride); - offset = lp_build_add(bld, offset, z_offset); - } + + if (z && z_stride) { + LLVMValueRef z_offset = lp_build_mul(bld, z, z_stride); + offset = lp_build_add(bld, offset, z_offset); } return offset; -- cgit v1.2.3 From d888812324719723de3256612886dd61de3bd282 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Apr 2010 14:39:03 -0600 Subject: gallium: use better param name --- src/gallium/include/pipe/p_screen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 06ab4a848a4..beff1ae8a92 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -93,13 +93,13 @@ struct pipe_screen { /** * Check if the given pipe_format is supported as a texture or * drawing surface. - * \param tex_usage bitmask of PIPE_BIND_* + * \param bindings bitmask of PIPE_BIND_* * \param geom_flags bitmask of PIPE_TEXTURE_GEOM_* */ boolean (*is_format_supported)( struct pipe_screen *, enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned bindings, unsigned geom_flags ); /** -- cgit v1.2.3 From 355370e30b083e6fd130c259f4378530c715142c Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Thu, 22 Apr 2010 21:52:15 +0200 Subject: radeon: 9800 SE has only one quadpipe Although these cards have 2 pipelines on the silicon only the first passed the QA and the other should be disabled. http://www.digital-daily.com/video/ati-radeon9800se/ http://www.rojakpot.com/showarticle.aspx?artno=101&pgno=1 Signed-off-by: Tormod Volden --- src/mesa/drivers/dri/radeon/radeon_screen.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 4d7255f47e7..f2a51868b25 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -1136,6 +1136,7 @@ radeonCreateScreen( __DRIscreen *sPriv ) /* pipe overrides */ switch (dri_priv->deviceID) { case PCI_CHIP_R300_AD: /* 9500 with 1 quadpipe verified by: Reid Linnemann */ + case PCI_CHIP_R350_AH: /* 9800 SE only have 1 quadpipe */ case PCI_CHIP_RV410_5E4C: /* RV410 SE only have 1 quadpipe */ case PCI_CHIP_RV410_5E4F: /* RV410 SE only have 1 quadpipe */ screen->num_gb_pipes = 1; @@ -1343,6 +1344,7 @@ radeonCreateScreen2(__DRIscreen *sPriv) /* pipe overrides */ switch (device_id) { case PCI_CHIP_R300_AD: /* 9500 with 1 quadpipe verified by: Reid Linnemann */ + case PCI_CHIP_R350_AH: /* 9800 SE only have 1 quadpipe */ case PCI_CHIP_RV410_5E4C: /* RV410 SE only have 1 quadpipe */ case PCI_CHIP_RV410_5E4F: /* RV410 SE only have 1 quadpipe */ screen->num_gb_pipes = 1; -- cgit v1.2.3 From ded2374e67bdc2c24e868775d2ff77b39b339d56 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Apr 2010 17:31:55 -0400 Subject: gallivm: implement indirect addressing over constants implement indirect addressing (ARL and ARR instructions) when used with CONST's. indirect addressing over other vars (temps, inputs, outputs) is not supported yet. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 50 ++++++++++++++++++------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 53a5ce0cd87..72ed8c089a8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -125,6 +125,7 @@ struct lp_build_tgsi_soa_context LLVMValueRef immediates[LP_MAX_IMMEDIATES][NUM_CHANNELS]; LLVMValueRef temps[LP_MAX_TEMPS][NUM_CHANNELS]; + LLVMValueRef addr[LP_MAX_TEMPS][NUM_CHANNELS]; struct lp_build_mask_context *mask; struct lp_exec_mask exec_mask; @@ -371,6 +372,7 @@ emit_fetch( const struct tgsi_full_src_register *reg = &inst->Src[index]; unsigned swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index ); LLVMValueRef res; + LLVMValueRef addr; switch (swizzle) { case TGSI_SWIZZLE_X: @@ -378,11 +380,34 @@ emit_fetch( case TGSI_SWIZZLE_Z: case TGSI_SWIZZLE_W: + if (reg->Register.Indirect) { + LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->base.type); + unsigned swizzle = tgsi_util_get_src_register_swizzle( ®->Indirect, chan_index ); + addr = LLVMBuildLoad(bld->base.builder, + bld->addr[reg->Indirect.Index][swizzle], + ""); + /* for indexing we want integers */ + addr = LLVMBuildFPToSI(bld->base.builder, addr, + int_vec_type, ""); + addr = LLVMBuildExtractElement(bld->base.builder, + addr, LLVMConstInt(LLVMInt32Type(), 0, 0), + ""); + } + switch (reg->Register.File) { case TGSI_FILE_CONSTANT: { LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), reg->Register.Index*4 + swizzle, 0); - LLVMValueRef scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr, &index, 1, ""); - LLVMValueRef scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, ""); + LLVMValueRef scalar, scalar_ptr; + + if (reg->Register.Indirect) { + /*lp_build_printf(bld->base.builder, + "\taddr = %d\n", addr);*/ + addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0)); + index = lp_build_add(&bld->base, index, addr); + } + scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr, &index, 1, ""); + scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, ""); + res = lp_build_broadcast_scalar(&bld->base, scalar); break; } @@ -510,8 +535,8 @@ emit_store( break; case TGSI_FILE_ADDRESS: - /* FIXME */ - assert(0); + lp_exec_mask_store(&bld->exec_mask, value, + bld->addr[reg->Indirect.Index][chan_index]); break; case TGSI_FILE_PREDICATE: @@ -724,6 +749,11 @@ emit_declaration( bld->outputs[idx][i] = lp_build_alloca(&bld->base); break; + case TGSI_FILE_ADDRESS: + for (i = 0; i < NUM_CHANNELS; i++) + bld->addr[idx][i] = lp_build_alloca(&bld->base); + break; + default: /* don't need to declare other vars */ break; @@ -780,17 +810,13 @@ emit_instruction( } switch (inst->Instruction.Opcode) { -#if 0 case TGSI_OPCODE_ARL: - /* FIXME */ FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { tmp0 = emit_fetch( bld, inst, 0, chan_index ); - emit_flr(bld, 0, 0); - emit_f2it( bld, 0 ); + tmp0 = lp_build_floor(&bld->base, tmp0); dst0[chan_index] = tmp0; } break; -#endif case TGSI_OPCODE_MOV: FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { @@ -1360,17 +1386,13 @@ emit_instruction( return FALSE; break; -#if 0 case TGSI_OPCODE_ARR: - /* FIXME */ FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { tmp0 = emit_fetch( bld, inst, 0, chan_index ); - emit_rnd( bld, 0, 0 ); - emit_f2it( bld, 0 ); + tmp0 = lp_build_round(&bld->base, tmp0); dst0[chan_index] = tmp0; } break; -#endif case TGSI_OPCODE_BRA: /* deprecated */ -- cgit v1.2.3 From 021e0dc78b15fab29e761012860276c2597c8d8f Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Apr 2010 18:36:07 -0400 Subject: gallivm: implement indirect addressing over temporaries a bit more involved than indirect addressing over consts, but still fairly reasonable. we allocate an array instead of individual alloca's, and we do it only if the shader does indirect addressing. --- src/gallium/auxiliary/draw/draw_llvm.c | 3 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 4 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 105 +++++++++++++++--------- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 +- 4 files changed, 74 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 9d110317698..5e8bef4f5ea 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -252,7 +252,8 @@ generate_vs(struct draw_llvm *llvm, NULL /*pos*/, inputs, outputs, - NULL/*sampler*/); + NULL/*sampler*/, + &llvm->draw->vs.vertex_shader->info); } #if DEBUG_STORE diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 63b938bfa98..2eac5da6c69 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -39,6 +39,7 @@ struct tgsi_token; +struct tgsi_shader_info; struct lp_type; struct lp_build_context; struct lp_build_mask_context; @@ -78,7 +79,8 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, const LLVMValueRef *pos, const LLVMValueRef (*inputs)[4], LLVMValueRef (*outputs)[4], - struct lp_build_sampler_soa *sampler); + struct lp_build_sampler_soa *sampler, + struct tgsi_shader_info *info); #endif /* LP_BLD_TGSI_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 72ed8c089a8..df2e24c2c90 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -46,6 +46,7 @@ #include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_util.h" #include "tgsi/tgsi_exec.h" +#include "tgsi/tgsi_scan.h" #include "lp_bld_type.h" #include "lp_bld_const.h" #include "lp_bld_arit.h" @@ -127,6 +128,11 @@ struct lp_build_tgsi_soa_context LLVMValueRef temps[LP_MAX_TEMPS][NUM_CHANNELS]; LLVMValueRef addr[LP_MAX_TEMPS][NUM_CHANNELS]; + /* we allocate an array of temps if we have indirect + * addressing and then the temps above is unused */ + LLVMValueRef temps_array; + boolean has_indirect_addressing; + struct lp_build_mask_context *mask; struct lp_exec_mask exec_mask; }; @@ -358,6 +364,23 @@ emit_ddy(struct lp_build_tgsi_soa_context *bld, return lp_build_sub(&bld->base, src_top, src_bottom); } +static LLVMValueRef +get_temp_ptr(struct lp_build_tgsi_soa_context *bld, + unsigned index, + unsigned swizzle, + boolean is_indirect, + LLVMValueRef addr) +{ + if (!bld->has_indirect_addressing) { + return bld->temps[index][swizzle]; + } else { + LLVMValueRef lindex = + LLVMConstInt(LLVMInt32Type(), index*4 + swizzle, 0); + if (is_indirect) + lindex = lp_build_add(&bld->base, lindex, addr); + return LLVMBuildGEP(bld->base.builder, bld->temps_array, &lindex, 1, ""); + } +} /** * Register fetch. @@ -392,6 +415,7 @@ emit_fetch( addr = LLVMBuildExtractElement(bld->base.builder, addr, LLVMConstInt(LLVMInt32Type(), 0, 0), ""); + addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0)); } switch (reg->Register.File) { @@ -402,7 +426,6 @@ emit_fetch( if (reg->Register.Indirect) { /*lp_build_printf(bld->base.builder, "\taddr = %d\n", addr);*/ - addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0)); index = lp_build_add(&bld->base, index, addr); } scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr, &index, 1, ""); @@ -422,11 +445,16 @@ emit_fetch( assert(res); break; - case TGSI_FILE_TEMPORARY: - res = LLVMBuildLoad(bld->base.builder, bld->temps[reg->Register.Index][swizzle], ""); + case TGSI_FILE_TEMPORARY: { + LLVMValueRef temp_ptr = get_temp_ptr(bld, reg->Register.Index, + swizzle, + reg->Register.Indirect, + addr); + res = LLVMBuildLoad(bld->base.builder, temp_ptr, ""); if(!res) return bld->base.undef; break; + } default: assert( 0 ); @@ -504,6 +532,7 @@ emit_store( LLVMValueRef value) { const struct tgsi_full_dst_register *reg = &inst->Dst[index]; + LLVMValueRef addr; switch( inst->Instruction.Saturate ) { case TGSI_SAT_NONE: @@ -523,16 +552,35 @@ emit_store( assert(0); } + if (reg->Register.Indirect) { + LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->base.type); + unsigned swizzle = tgsi_util_get_src_register_swizzle( ®->Indirect, chan_index ); + addr = LLVMBuildLoad(bld->base.builder, + bld->addr[reg->Indirect.Index][swizzle], + ""); + /* for indexing we want integers */ + addr = LLVMBuildFPToSI(bld->base.builder, addr, + int_vec_type, ""); + addr = LLVMBuildExtractElement(bld->base.builder, + addr, LLVMConstInt(LLVMInt32Type(), 0, 0), + ""); + addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0)); + } + switch( reg->Register.File ) { case TGSI_FILE_OUTPUT: lp_exec_mask_store(&bld->exec_mask, value, bld->outputs[reg->Register.Index][chan_index]); break; - case TGSI_FILE_TEMPORARY: - lp_exec_mask_store(&bld->exec_mask, value, - bld->temps[reg->Register.Index][chan_index]); + case TGSI_FILE_TEMPORARY: { + LLVMValueRef temp_ptr = get_temp_ptr(bld, reg->Register.Index, + chan_index, + reg->Register.Indirect, + addr); + lp_exec_mask_store(&bld->exec_mask, value, temp_ptr); break; + } case TGSI_FILE_ADDRESS: lp_exec_mask_store(&bld->exec_mask, value, @@ -691,30 +739,6 @@ emit_kilp(struct lp_build_tgsi_soa_context *bld, lp_build_mask_update(bld->mask, mask); } - -/** - * Check if inst src/dest regs use indirect addressing into temporary - * register file. - */ -static boolean -indirect_temp_reference(const struct tgsi_full_instruction *inst) -{ - uint i; - for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { - const struct tgsi_full_src_register *reg = &inst->Src[i]; - if (reg->Register.File == TGSI_FILE_TEMPORARY && - reg->Register.Indirect) - return TRUE; - } - for (i = 0; i < inst->Instruction.NumDstRegs; i++) { - const struct tgsi_full_dst_register *reg = &inst->Dst[i]; - if (reg->Register.File == TGSI_FILE_TEMPORARY && - reg->Register.Indirect) - return TRUE; - } - return FALSE; -} - static int emit_declaration( struct lp_build_tgsi_soa_context *bld, @@ -740,8 +764,16 @@ emit_declaration( for (idx = first; idx <= last; ++idx) { switch (decl->Declaration.File) { case TGSI_FILE_TEMPORARY: - for (i = 0; i < NUM_CHANNELS; i++) - bld->temps[idx][i] = lp_build_alloca(&bld->base); + if (bld->has_indirect_addressing) { + LLVMValueRef val = LLVMConstInt(LLVMInt32Type(), + last*4 + 4, 0); + bld->temps_array = LLVMBuildArrayAlloca(bld->base.builder, + lp_build_vec_type(bld->base.type), + val, ""); + } else { + for (i = 0; i < NUM_CHANNELS; i++) + bld->temps[idx][i] = lp_build_alloca(&bld->base); + } break; case TGSI_FILE_OUTPUT: @@ -787,10 +819,6 @@ emit_instruction( LLVMValueRef res; LLVMValueRef dst0[NUM_CHANNELS]; - /* we can't handle indirect addressing into temp register file yet */ - if (indirect_temp_reference(inst)) - return FALSE; - /* * Stores and write masks are handled in a general fashion after the long * instruction opcode switch statement. @@ -1742,7 +1770,8 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, const LLVMValueRef *pos, const LLVMValueRef (*inputs)[NUM_CHANNELS], LLVMValueRef (*outputs)[NUM_CHANNELS], - struct lp_build_sampler_soa *sampler) + struct lp_build_sampler_soa *sampler, + struct tgsi_shader_info *info) { struct lp_build_tgsi_soa_context bld; struct tgsi_parse_context parse; @@ -1758,6 +1787,8 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, bld.outputs = outputs; bld.consts_ptr = consts_ptr; bld.sampler = sampler; + bld.has_indirect_addressing = info->opcode_count[TGSI_OPCODE_ARR] > 0 || + info->opcode_count[TGSI_OPCODE_ARL] > 0; lp_exec_mask_init(&bld.exec_mask, &bld.base); diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 551c3757bbb..2c4303a8957 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -474,7 +474,7 @@ generate_fs(struct llvmpipe_context *lp, lp_build_tgsi_soa(builder, tokens, type, &mask, consts_ptr, interp->pos, interp->inputs, - outputs, sampler); + outputs, sampler, &shader->info); for (attrib = 0; attrib < shader->info.num_outputs; ++attrib) { for(chan = 0; chan < NUM_CHANNELS; ++chan) { -- cgit v1.2.3 From 64516430be1cbe4904613903887a8178f4b4fc60 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Apr 2010 13:40:28 -0700 Subject: i965: Fix scissoring when width or height is 0. We would run into trouble due to the hardware using inclusive numbers and the subtraction to handle that producing negative (meaning large positive) coordinates. Bug #27643. --- src/mesa/drivers/dri/i965/brw_sf_state.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 9712c31afea..1a6c8218fd1 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -76,7 +76,20 @@ static void upload_sf_vp(struct brw_context *brw) * Note that the hardware's coordinates are inclusive, while Mesa's min is * inclusive but max is exclusive. */ - if (render_to_fbo) { + + if (ctx->DrawBuffer->_Xmin == ctx->DrawBuffer->_Xmax || + ctx->DrawBuffer->_Ymin == ctx->DrawBuffer->_Ymax) { + /* If the scissor was out of bounds and got clamped to 0 + * width/height at the bounds, the subtraction of 1 from + * maximums could produce a negative number and thus not clip + * anything. Instead, just provide a min > max scissor inside + * the bounds, which produces the expected no rendering. + */ + sfv.scissor.xmin = 1; + sfv.scissor.xmax = 0; + sfv.scissor.ymin = 1; + sfv.scissor.ymax = 0; + } else if (render_to_fbo) { /* texmemory: Y=0=bottom */ sfv.scissor.xmin = ctx->DrawBuffer->_Xmin; sfv.scissor.xmax = ctx->DrawBuffer->_Xmax - 1; -- cgit v1.2.3 From b2e52e727849bd78f8600931261ae69c1b29d6a6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Apr 2010 15:24:26 -0700 Subject: i965: Fix assertion for surface tile offset usage on Ironlake. Fixes assertion failure in fbo-generatemipmap-npot. --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 6b9e5668862..e51a1a0e26a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -588,7 +588,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw, tile_base = ((key.draw_y / 32) * (32 * pitch)); tile_base += (key.draw_x - tile_x) / (128 / key.cpp) * 4096; } - assert(intel->is_g4x || (tile_x == 0 && tile_y == 0)); + assert(brw->has_surface_tile_offset || (tile_x == 0 && tile_y == 0)); assert(tile_x % 4 == 0); assert(tile_y % 2 == 0); /* Note that the low bits of these fields are missing, so -- cgit v1.2.3 From 749a8825a00c841b677eabace88d8d3f2ad7af13 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 23 Apr 2010 00:59:12 -0700 Subject: llvmpipe: Remove unused variable. --- src/gallium/drivers/llvmpipe/lp_test_blend.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c index 818f7a9a562..fae7bf3fcf2 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c @@ -154,7 +154,6 @@ add_blend_test(LLVMModuleRef module, enum vector_mode mode, struct lp_type type) { - LLVMTypeRef ret_type; LLVMTypeRef vec_type; LLVMTypeRef args[4]; LLVMValueRef func; @@ -165,7 +164,6 @@ add_blend_test(LLVMModuleRef module, LLVMBasicBlockRef block; LLVMBuilderRef builder; - ret_type = LLVMInt64Type(); vec_type = lp_build_vec_type(type); args[3] = args[2] = args[1] = args[0] = LLVMPointerType(vec_type, 0); -- cgit v1.2.3 From c37e275e778e8c944e3dfad159b1eb94c601af60 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 23 Apr 2010 11:14:13 +0200 Subject: glx/dri2: Fix build with dri2proto which doesn't define X_DRI2SwapInterval. --- src/glx/dri2_glx.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 3a53ce91b38..fa2b9878537 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -204,12 +204,14 @@ dri2CreateDrawable(__GLXscreenConfigs * psc, return NULL; } +#ifdef X_DRI2SwapInterval /* * Make sure server has the same swap interval we do for the new * drawable. */ if (pdp->swapAvailable) DRI2SwapInterval(psc->dpy, xDrawable, pdraw->swap_interval); +#endif return &pdraw->base; } -- cgit v1.2.3 From eb4dc547885994cc7961f7996c33ff484f664964 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Fri, 23 Apr 2010 11:56:06 +0200 Subject: r600: don't enable depth test if there is no depth buffer If there is no depth buffer bound to current context don't enable depth test. GL states that if depth test is enabled without depth buffer it's as if depth buffer always pass. Signed-off-by: Jerome Glisse --- src/mesa/drivers/dri/r600/r700_state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 12eaebbc16b..0d7cb8ecfe5 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -252,12 +252,15 @@ void r700UpdateShaderStates(GLcontext * ctx) static void r700SetDepthState(GLcontext * ctx) { + struct radeon_renderbuffer *rrb; context_t *context = R700_CONTEXT(ctx); R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw); R600_STATECHANGE(context, db); - if (ctx->Depth.Test) + rrb = radeon_get_depthbuffer(&context->radeon); + + if (ctx->Depth.Test && rrb && rrb->bo) { SETbit(r700->DB_DEPTH_CONTROL.u32All, Z_ENABLE_bit); if (ctx->Depth.Mask) -- cgit v1.2.3 From 71dfbb608acca74268cd6c93b121913a374f6b58 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 09:03:10 -0600 Subject: llvmpipe: move LP_MAX_TEXTURE_x_LEVELS, etc to lp_tile_size.h --- src/gallium/drivers/llvmpipe/lp_scene.h | 2 -- src/gallium/drivers/llvmpipe/lp_texture.h | 7 +------ src/gallium/drivers/llvmpipe/lp_tile_size.h | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h index ac0717db6a1..273fc02b7c1 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.h +++ b/src/gallium/drivers/llvmpipe/lp_scene.h @@ -44,8 +44,6 @@ struct lp_scene_queue; /* We're limited to 2K by 2K for 32bit fixed point rasterization. * Will need a 64-bit version for larger framebuffers. */ -#define MAXHEIGHT 2048 -#define MAXWIDTH 2048 #define TILES_X (MAXWIDTH / TILE_SIZE) #define TILES_Y (MAXHEIGHT / TILE_SIZE) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 858975bcee0..3026afe0a5b 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -31,12 +31,7 @@ #include "pipe/p_state.h" #include "util/u_debug.h" - - -#define LP_MAX_TEXTURE_2D_LEVELS 12 /* 2K x 2K for now */ -#define LP_MAX_TEXTURE_3D_LEVELS 10 /* 512 x 512 x 512 for now */ - -#define LP_MAX_TEXTURE_LEVELS LP_MAX_TEXTURE_2D_LEVELS +#include "lp_tile_size.h" enum lp_texture_usage diff --git a/src/gallium/drivers/llvmpipe/lp_tile_size.h b/src/gallium/drivers/llvmpipe/lp_tile_size.h index f0b983c0632..64d5dc18a3b 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_size.h +++ b/src/gallium/drivers/llvmpipe/lp_tile_size.h @@ -36,4 +36,22 @@ #define TILE_SIZE (1 << TILE_ORDER) +/** + * Max texture sizes + */ +#define LP_MAX_TEXTURE_2D_LEVELS 12 /* 2K x 2K for now */ +#define LP_MAX_TEXTURE_3D_LEVELS 10 /* 512 x 512 x 512 for now */ + + +/** This must be the larger of LP_MAX_TEXTURE_2D/3D_LEVELS */ +#define LP_MAX_TEXTURE_LEVELS LP_MAX_TEXTURE_2D_LEVELS + + +/** + * Max drawing surface size is the max texture size + */ +#define MAXHEIGHT (1 << (LP_MAX_TEXTURE_LEVELS - 1)) +#define MAXWIDTH (1 << (LP_MAX_TEXTURE_LEVELS - 1)) + + #endif -- cgit v1.2.3 From 2de31f2bf2b9c68aaa76a63fa0d0d3e0731ccfb5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 09:07:55 -0600 Subject: llvmpipe: rename lp_tile_size.h to lp_limits.h Collect the various driver limits in one place since. --- src/gallium/drivers/llvmpipe/lp_limits.h | 61 +++++++++++++++++++++++++++++ src/gallium/drivers/llvmpipe/lp_surface.c | 2 +- src/gallium/drivers/llvmpipe/lp_texture.c | 1 - src/gallium/drivers/llvmpipe/lp_texture.h | 2 +- src/gallium/drivers/llvmpipe/lp_tile_size.h | 57 --------------------------- src/gallium/drivers/llvmpipe/lp_tile_soa.h | 2 +- 6 files changed, 64 insertions(+), 61 deletions(-) create mode 100644 src/gallium/drivers/llvmpipe/lp_limits.h delete mode 100644 src/gallium/drivers/llvmpipe/lp_tile_size.h (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h b/src/gallium/drivers/llvmpipe/lp_limits.h new file mode 100644 index 00000000000..75be000f2fe --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_limits.h @@ -0,0 +1,61 @@ +/************************************************************************** + * + * Copyright 2010 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 THE AUTHORS 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. + * + **************************************************************************/ + +/** + * Implementation limits for LLVMpipe driver. + */ + +#ifndef LP_LIMITS_H +#define LP_LIMITS_H + + +/** + * Tile size (width and height). This needs to be a power of two. + */ +#define TILE_ORDER 6 +#define TILE_SIZE (1 << TILE_ORDER) + + +/** + * Max texture sizes + */ +#define LP_MAX_TEXTURE_2D_LEVELS 12 /* 2K x 2K for now */ +#define LP_MAX_TEXTURE_3D_LEVELS 10 /* 512 x 512 x 512 for now */ + + +/** This must be the larger of LP_MAX_TEXTURE_2D/3D_LEVELS */ +#define LP_MAX_TEXTURE_LEVELS LP_MAX_TEXTURE_2D_LEVELS + + +/** + * Max drawing surface size is the max texture size + */ +#define MAXHEIGHT (1 << (LP_MAX_TEXTURE_LEVELS - 1)) +#define MAXWIDTH (1 << (LP_MAX_TEXTURE_LEVELS - 1)) + + +#endif /* LP_LIMITS_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index 1a116989d4c..ca03440d5d6 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -28,9 +28,9 @@ #include "util/u_rect.h" #include "lp_context.h" #include "lp_flush.h" +#include "lp_limits.h" #include "lp_surface.h" #include "lp_texture.h" -#include "lp_tile_size.h" /** diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 336b487bd4e..0c66f4ad503 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -47,7 +47,6 @@ #include "lp_tile_image.h" #include "lp_texture.h" #include "lp_setup.h" -#include "lp_tile_size.h" #include "state_tracker/sw_winsys.h" diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 3026afe0a5b..7d0ae263e51 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -31,7 +31,7 @@ #include "pipe/p_state.h" #include "util/u_debug.h" -#include "lp_tile_size.h" +#include "lp_limits.h" enum lp_texture_usage diff --git a/src/gallium/drivers/llvmpipe/lp_tile_size.h b/src/gallium/drivers/llvmpipe/lp_tile_size.h deleted file mode 100644 index 64d5dc18a3b..00000000000 --- a/src/gallium/drivers/llvmpipe/lp_tile_size.h +++ /dev/null @@ -1,57 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 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 THE AUTHORS 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. - * - **************************************************************************/ - -#ifndef LP_TILE_SIZE_H -#define LP_TILE_SIZE_H - - -/** - * Tile size (width and height). This needs to be a power of two. - */ -#define TILE_ORDER 6 -#define TILE_SIZE (1 << TILE_ORDER) - - -/** - * Max texture sizes - */ -#define LP_MAX_TEXTURE_2D_LEVELS 12 /* 2K x 2K for now */ -#define LP_MAX_TEXTURE_3D_LEVELS 10 /* 512 x 512 x 512 for now */ - - -/** This must be the larger of LP_MAX_TEXTURE_2D/3D_LEVELS */ -#define LP_MAX_TEXTURE_LEVELS LP_MAX_TEXTURE_2D_LEVELS - - -/** - * Max drawing surface size is the max texture size - */ -#define MAXHEIGHT (1 << (LP_MAX_TEXTURE_LEVELS - 1)) -#define MAXWIDTH (1 << (LP_MAX_TEXTURE_LEVELS - 1)) - - -#endif diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.h b/src/gallium/drivers/llvmpipe/lp_tile_soa.h index 9d6a88afec5..634d8dfb1ce 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.h +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.h @@ -30,7 +30,7 @@ #include "pipe/p_compiler.h" #include "tgsi/tgsi_exec.h" /* for NUM_CHANNELS */ -#include "lp_tile_size.h" +#include "lp_limits.h" #ifdef __cplusplus extern "C" { -- cgit v1.2.3 From 4a72ec49f671015cd556ca2efbe5327f8e02fb28 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 09:10:18 -0600 Subject: llvmpipe: rename MAXWIDTH, MAXHEIGHT --- src/gallium/drivers/llvmpipe/lp_limits.h | 4 ++-- src/gallium/drivers/llvmpipe/lp_scene.h | 4 ++-- src/gallium/drivers/llvmpipe/lp_state_surface.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h b/src/gallium/drivers/llvmpipe/lp_limits.h index 75be000f2fe..21776b2d9d9 100644 --- a/src/gallium/drivers/llvmpipe/lp_limits.h +++ b/src/gallium/drivers/llvmpipe/lp_limits.h @@ -54,8 +54,8 @@ /** * Max drawing surface size is the max texture size */ -#define MAXHEIGHT (1 << (LP_MAX_TEXTURE_LEVELS - 1)) -#define MAXWIDTH (1 << (LP_MAX_TEXTURE_LEVELS - 1)) +#define LP_MAX_HEIGHT (1 << (LP_MAX_TEXTURE_LEVELS - 1)) +#define LP_MAX_WIDTH (1 << (LP_MAX_TEXTURE_LEVELS - 1)) #endif /* LP_LIMITS_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h index 273fc02b7c1..5166a636a1b 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.h +++ b/src/gallium/drivers/llvmpipe/lp_scene.h @@ -44,8 +44,8 @@ struct lp_scene_queue; /* We're limited to 2K by 2K for 32bit fixed point rasterization. * Will need a 64-bit version for larger framebuffers. */ -#define TILES_X (MAXWIDTH / TILE_SIZE) -#define TILES_Y (MAXHEIGHT / TILE_SIZE) +#define TILES_X (LP_MAX_WIDTH / TILE_SIZE) +#define TILES_Y (LP_MAX_HEIGHT / TILE_SIZE) #define CMD_BLOCK_MAX 128 diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c index 7d86c5750c5..63b8f27b39c 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c @@ -52,8 +52,8 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe, boolean changed = !util_framebuffer_state_equal(&lp->framebuffer, fb); - assert(fb->width <= MAXWIDTH); - assert(fb->height <= MAXHEIGHT); + assert(fb->width <= LP_MAX_WIDTH); + assert(fb->height <= LP_MAX_HEIGHT); if (changed) { -- cgit v1.2.3 From 158f9d56e0ae9ab5d879b8db32e672eebb667e2a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 09:13:03 -0600 Subject: llvmpipe: increase max 2D texture / surface size to 4K x 4K --- src/gallium/drivers/llvmpipe/lp_limits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h b/src/gallium/drivers/llvmpipe/lp_limits.h index 21776b2d9d9..9ab1b4b36e3 100644 --- a/src/gallium/drivers/llvmpipe/lp_limits.h +++ b/src/gallium/drivers/llvmpipe/lp_limits.h @@ -43,7 +43,7 @@ /** * Max texture sizes */ -#define LP_MAX_TEXTURE_2D_LEVELS 12 /* 2K x 2K for now */ +#define LP_MAX_TEXTURE_2D_LEVELS 13 /* 4K x 4K for now */ #define LP_MAX_TEXTURE_3D_LEVELS 10 /* 512 x 512 x 512 for now */ -- cgit v1.2.3 From 405f925d4e5fa74961754af93e7fb309774551cc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Apr 2010 16:56:55 +0100 Subject: sw/xlib: Fallback to XPutImage when shmget fails. After continuously running regression tests on Ubuntu for 2 days, shmget mysteriously starts to fail. Even when the X server is reset. This allow rendering to proceed, albeit using a slower presentation path. --- src/gallium/winsys/sw/xlib/xlib_sw_winsys.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c index ec4f919d082..278a191a0e5 100644 --- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c @@ -385,13 +385,12 @@ xm_displaytarget_create(struct sw_winsys *winsys, if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) { - xm_dt->shminfo.shmid = -1; - xm_dt->shminfo.shmaddr = (char *) -1; - xm_dt->shm = TRUE; - xm_dt->data = alloc_shm(xm_dt, size); - if(!xm_dt->data) - goto no_data; + if(!xm_dt->data) { + xm_dt->shminfo.shmid = -1; + xm_dt->shminfo.shmaddr = (char *) -1; + xm_dt->shm = TRUE; + } } if(!xm_dt->data) { -- cgit v1.2.3 From 99bee1570bc23d8070c7ac3da67e46bdb2e6ec0d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Apr 2010 17:03:10 +0100 Subject: mesa/st: Remove dead members. --- src/mesa/state_tracker/st_context.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index dfee490b54a..3637f6e75f0 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -201,7 +201,6 @@ struct st_framebuffer { GLframebuffer Base; void *Private; - GLuint InitWidth, InitHeight; struct st_framebuffer_iface *iface; enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; -- cgit v1.2.3 From d7996beb4ca01ba9ca83e71d2833278cb4df3a75 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Apr 2010 17:04:06 +0100 Subject: softpipe: YUV textures should be supported. --- src/gallium/drivers/softpipe/sp_screen.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 7b1e058ac83..52ccb32530c 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -155,10 +155,6 @@ softpipe_is_format_supported( struct pipe_screen *screen, target == PIPE_TEXTURE_CUBE); switch(format) { - case PIPE_FORMAT_YUYV: - case PIPE_FORMAT_UYVY: - return FALSE; - case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: -- cgit v1.2.3 From f73feb9cd6095d82b87e7022c351408e6e232797 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Apr 2010 17:07:14 +0100 Subject: st/xlib: Try to propagate failure to create framebuffer. Doesn't help much, since it is ignored by st_framebuffer_validate. --- src/gallium/state_trackers/glx/xlib/xm_st.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index 294b593bf77..1c678b4f760 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -125,7 +125,7 @@ xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi, /** * Remove outdated textures and create the requested ones. */ -static void +static boolean xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi, unsigned width, unsigned height, unsigned mask) @@ -183,12 +183,16 @@ xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi, xstfb->textures[i] = xstfb->screen->resource_create(xstfb->screen, &templ); + if (!xstfb->textures[i]) + return FALSE; } } xstfb->texture_width = width; xstfb->texture_height = height; xstfb->texture_mask = mask; + + return TRUE; } static boolean @@ -200,6 +204,7 @@ xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); unsigned statt_mask, new_mask, i; boolean resized; + boolean ret; statt_mask = 0x0; for (i = 0; i < count; i++) @@ -212,8 +217,10 @@ xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, /* revalidate textures */ if (resized || new_mask) { - xmesa_st_framebuffer_validate_textures(stfbi, - xstfb->buffer->width, xstfb->buffer->height, statt_mask); + ret = xmesa_st_framebuffer_validate_textures(stfbi, + xstfb->buffer->width, xstfb->buffer->height, statt_mask); + if (!ret) + return ret; if (!resized) { enum st_attachment_type back, front; -- cgit v1.2.3 From 00f8e5764d5b41714704c94575a5b6f873340a2f Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 23 Apr 2010 19:26:03 +0100 Subject: llvmpipe: update for half float formats --- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 65810b6f8ff..4e9cd7e123f 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -58,7 +58,7 @@ def is_format_supported(format): channel = format.channels[i] if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT): return False - if channel.type == FLOAT and channel.size not in (32 ,64): + if channel.type == FLOAT and channel.size not in (16, 32 ,64): return False if format.colorspace not in ('rgb', 'srgb'): -- cgit v1.2.3 From f855193796b834e9f06775f8a7130837d1f86f95 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 10:12:30 -0600 Subject: llvmpipe: rename texture refs to resource refs --- src/gallium/drivers/llvmpipe/lp_scene.c | 38 ++++++++++++++++++++------------- src/gallium/drivers/llvmpipe/lp_scene.h | 20 ++++++++--------- src/gallium/drivers/llvmpipe/lp_setup.c | 2 +- 3 files changed, 34 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index 182e7cb2303..0b185c4c412 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -35,6 +35,14 @@ #include "lp_debug.h" +/** List of texture references */ +struct texture_ref { + struct pipe_resource *texture; + struct texture_ref *prev, *next; /**< linked list w/ u_simple_list.h */ +}; + + + struct lp_scene * lp_scene_create( struct pipe_context *pipe, struct lp_scene_queue *queue ) @@ -57,7 +65,7 @@ lp_scene_create( struct pipe_context *pipe, scene->data.head = scene->data.tail = CALLOC_STRUCT(data_block); - make_empty_list(&scene->textures); + make_empty_list(&scene->resources); pipe_mutex_init(scene->mutex); @@ -178,10 +186,10 @@ lp_scene_reset(struct lp_scene *scene ) /* Release texture refs */ { - struct texture_ref *ref, *next, *ref_list = &scene->textures; + struct resource_ref *ref, *next, *ref_list = &scene->resources; for (ref = ref_list->next; ref != ref_list; ref = next) { next = next_elem(ref); - pipe_resource_reference(&ref->texture, NULL); + pipe_resource_reference(&ref->resource, NULL); FREE(ref); } make_empty_list(ref_list); @@ -247,32 +255,32 @@ lp_scene_bin_size( const struct lp_scene *scene, unsigned x, unsigned y ) /** - * Add a reference to a texture by the scene. + * Add a reference to a resource by the scene. */ void -lp_scene_texture_reference( struct lp_scene *scene, - struct pipe_resource *texture ) +lp_scene_add_resource_reference(struct lp_scene *scene, + struct pipe_resource *resource) { - struct texture_ref *ref = CALLOC_STRUCT(texture_ref); + struct resource_ref *ref = CALLOC_STRUCT(resource_ref); if (ref) { - struct texture_ref *ref_list = &scene->textures; - pipe_resource_reference(&ref->texture, texture); + struct resource_ref *ref_list = &scene->resources; + pipe_resource_reference(&ref->resource, resource); insert_at_tail(ref_list, ref); } } /** - * Does this scene have a reference to the given texture? + * Does this scene have a reference to the given resource? */ boolean -lp_scene_is_resource_referenced( const struct lp_scene *scene, - const struct pipe_resource *texture ) +lp_scene_is_resource_referenced(const struct lp_scene *scene, + const struct pipe_resource *resource) { - const struct texture_ref *ref_list = &scene->textures; - const struct texture_ref *ref; + const struct resource_ref *ref_list = &scene->resources; + const struct resource_ref *ref; foreach (ref, ref_list) { - if (ref->texture == texture) + if (ref->resource == resource) return TRUE; } return FALSE; diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h index 5166a636a1b..3e2bd0e7b38 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.h +++ b/src/gallium/drivers/llvmpipe/lp_scene.h @@ -95,10 +95,10 @@ struct data_block_list { }; -/** List of texture references */ -struct texture_ref { - struct pipe_resource *texture; - struct texture_ref *prev, *next; /**< linked list w/ u_simple_list.h */ +/** List of resource references */ +struct resource_ref { + struct pipe_resource *resource; + struct resource_ref *prev, *next; /**< linked list w/ u_simple_list.h */ }; @@ -116,8 +116,8 @@ struct lp_scene { /** the framebuffer to render the scene into */ struct pipe_framebuffer_state fb; - /** list of textures referenced by the scene commands */ - struct texture_ref textures; + /** list of resources referenced by the scene commands */ + struct resource_ref resources; boolean write_depth; boolean has_color_clear; @@ -162,11 +162,11 @@ unsigned lp_scene_data_size( const struct lp_scene *scene ); unsigned lp_scene_bin_size( const struct lp_scene *scene, unsigned x, unsigned y ); -void lp_scene_texture_reference( struct lp_scene *scene, - struct pipe_resource *texture ); +void lp_scene_add_resource_reference(struct lp_scene *scene, + struct pipe_resource *resource); -boolean lp_scene_is_resource_referenced( const struct lp_scene *scene, - const struct pipe_resource *texture ); +boolean lp_scene_is_resource_referenced(const struct lp_scene *scene, + const struct pipe_resource *resource ); /** diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 6be13c60a57..210c7b8a908 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -715,7 +715,7 @@ lp_setup_update_state( struct lp_setup_context *setup ) */ for (i = 0; i < Elements(setup->fs.current_tex); i++) { if (setup->fs.current_tex[i]) - lp_scene_texture_reference(scene, setup->fs.current_tex[i]); + lp_scene_add_resource_reference(scene, setup->fs.current_tex[i]); } } } -- cgit v1.2.3 From 3643841079a1413695172d0e5dd5e0a5f2e22945 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 11:58:52 -0600 Subject: mesa: faster, simpler is_compressed_format() --- src/mesa/main/teximage.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index b31ca86f11d..b7cd5ab2f9a 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -358,30 +358,36 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) /** - * Test if it is a supported compressed format. - * + * Test if a texture format is a supported compressed format. * \param internalFormat the internal format token provided by the user. - * - * \ret GL_TRUE if \p internalFormat is a supported compressed format, or - * GL_FALSE otherwise. - * - * Currently only GL_COMPRESSED_RGB_FXT1_3DFX and GL_COMPRESSED_RGBA_FXT1_3DFX - * are supported. + * \return GL_TRUE if compressed, GL_FALSE if uncompressed */ static GLboolean is_compressed_format(GLcontext *ctx, GLenum internalFormat) { - GLint supported[100]; /* 100 should be plenty */ - GLuint i, n; - - n = _mesa_get_compressed_formats(ctx, supported, GL_TRUE); - ASSERT(n < 100); - for (i = 0; i < n; i++) { - if ((GLint) internalFormat == supported[i]) { - return GL_TRUE; - } + switch (internalFormat) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return ctx->Extensions.EXT_texture_compression_s3tc; + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + return ctx->Extensions.S3_s3tc; + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return ctx->Extensions.EXT_texture_sRGB + && ctx->Extensions.EXT_texture_compression_s3tc; + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return ctx->Extensions.TDFX_texture_compression_FXT1; + default: + return GL_FALSE; } - return GL_FALSE; } -- cgit v1.2.3 From c34feadd1c2fa5c62022c1f48ee675b25a985ac6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 12:01:50 -0600 Subject: mesa: make is_compressed_format() non-static --- src/mesa/main/image.c | 34 ++++++++++++++++++++++++++++++++++ src/mesa/main/image.h | 2 ++ src/mesa/main/teximage.c | 42 ++++-------------------------------------- 3 files changed, 40 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index dc8d97728bf..8aef306fd81 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -750,6 +750,40 @@ _mesa_is_dudv_format(GLenum format) } +/** + * Test if an image format is a supported compressed format. + * \param format the internal format token provided by the user. + * \return GL_TRUE if compressed, GL_FALSE if uncompressed + */ +GLboolean +_mesa_is_compressed_format(GLcontext *ctx, GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return ctx->Extensions.EXT_texture_compression_s3tc; + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + return ctx->Extensions.S3_s3tc; + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return ctx->Extensions.EXT_texture_sRGB + && ctx->Extensions.EXT_texture_compression_s3tc; + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return ctx->Extensions.TDFX_texture_compression_FXT1; + default: + return GL_FALSE; + } +} + + /** * Return the address of a specific pixel in an image (1D, 2D or 3D). * diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 9b34be0dfaa..3947bbc2786 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -75,6 +75,8 @@ _mesa_is_depthstencil_format(GLenum format); extern GLboolean _mesa_is_dudv_format(GLenum format); +extern GLboolean +_mesa_is_compressed_format(GLcontext *ctx, GLenum format); extern GLvoid * _mesa_image_address( GLuint dimensions, diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index b7cd5ab2f9a..e0c5cf9c375 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -357,40 +357,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) } -/** - * Test if a texture format is a supported compressed format. - * \param internalFormat the internal format token provided by the user. - * \return GL_TRUE if compressed, GL_FALSE if uncompressed - */ -static GLboolean -is_compressed_format(GLcontext *ctx, GLenum internalFormat) -{ - switch (internalFormat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return ctx->Extensions.EXT_texture_compression_s3tc; - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return ctx->Extensions.S3_s3tc; - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return ctx->Extensions.EXT_texture_sRGB - && ctx->Extensions.EXT_texture_compression_s3tc; - case GL_COMPRESSED_RGB_FXT1_3DFX: - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return ctx->Extensions.TDFX_texture_compression_FXT1; - default: - return GL_FALSE; - } -} - - /** * For cube map faces, return a face index in [0,5]. * For other targets return 0; @@ -1355,7 +1321,7 @@ texture_error_check( GLcontext *ctx, GLenum target, } /* additional checks for compressed textures */ - if (is_compressed_format(ctx, internalFormat)) { + if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target) && !isProxy) { _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%d(target)", dimensions); @@ -1721,7 +1687,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, return GL_TRUE; } - if (is_compressed_format(ctx, internalFormat)) { + if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%d(target)", dimensions); @@ -3119,7 +3085,7 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions, maxTextureSize = 1 << (maxLevels - 1); /* This will detect any invalid internalFormat value */ - if (!is_compressed_format(ctx, internalFormat)) + if (!_mesa_is_compressed_format(ctx, internalFormat)) return GL_INVALID_ENUM; /* This should really never fail */ @@ -3224,7 +3190,7 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, maxTextureSize = 1 << (maxLevels - 1); /* this will catch any invalid compressed format token */ - if (!is_compressed_format(ctx, format)) + if (!_mesa_is_compressed_format(ctx, format)) return GL_INVALID_ENUM; if (width < 1 || width > maxTextureSize) -- cgit v1.2.3 From a8c78f3aa13ee6a370f79c8d5936c75ba29ec193 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 12:15:06 -0600 Subject: st/mesa: get rid of default_deep_rgba_format() This special-case code used to be used for the accum buffer but the accum buffer implementation was changed some time ago. --- src/mesa/state_tracker/st_format.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 3e767507eef..180118d69df 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -386,25 +386,6 @@ default_srgba_format(struct pipe_screen *screen, } -/** - * Search list of formats for first RGBA format with >8 bits/channel. - */ -static enum pipe_format -default_deep_rgba_format(struct pipe_screen *screen, - enum pipe_texture_target target, - unsigned tex_usage, - unsigned geom_flags) -{ - if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) { - return PIPE_FORMAT_R16G16B16A16_SNORM; - } - if (tex_usage & PIPE_BIND_RENDER_TARGET) - return default_rgba_format(screen, target, tex_usage, geom_flags); - else - return PIPE_FORMAT_NONE; -} - - /** * Given an OpenGL internalFormat value for a texture or surface, return * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match. @@ -431,10 +412,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_COMPRESSED_RGB: return default_rgb_format( screen, target, tex_usage, geom_flags ); case GL_RGBA16: - if (tex_usage & PIPE_BIND_RENDER_TARGET) - return default_deep_rgba_format( screen, target, tex_usage, geom_flags ); - else - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_RGBA4: case GL_RGBA2: -- cgit v1.2.3 From 70df04404bc4459f3a7f527c8b847ea06a51b599 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 12:28:55 -0600 Subject: st/mesa: don't set RENDER_TARGET/DEPTH_STENCIL flag for compressed textures --- src/mesa/state_tracker/st_format.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 180118d69df..2e40659b19e 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -661,11 +661,13 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, * An alternative would be to destroy and re-create a texture when * we first start rendering to it. */ - if (_mesa_is_depth_format(internalFormat) || - _mesa_is_depthstencil_format(internalFormat)) - usage |= PIPE_BIND_DEPTH_STENCIL; - else - usage |= PIPE_BIND_RENDER_TARGET; + if (!_mesa_is_compressed_format(ctx, internalFormat)) { + if (_mesa_is_depth_format(internalFormat) || + _mesa_is_depthstencil_format(internalFormat)) + usage |= PIPE_BIND_DEPTH_STENCIL; + else + usage |= PIPE_BIND_RENDER_TARGET; + } pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, PIPE_TEXTURE_2D, usage); -- cgit v1.2.3 From c09f3705196f1472871782d23d588e9fd14a50c7 Mon Sep 17 00:00:00 2001 From: Stephen Johnson Date: Fri, 23 Apr 2010 19:34:21 +0100 Subject: draw: use FREE() instead of free() --- src/gallium/auxiliary/draw/draw_llvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 5e8bef4f5ea..936753f66b9 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -205,7 +205,7 @@ draw_llvm_create(struct draw_context *draw) void draw_llvm_destroy(struct draw_llvm *llvm) { - free(llvm); + FREE(llvm); } struct draw_llvm_variant * -- cgit v1.2.3 From ad7d36e91933a49ce3f6ed2c14ae585a8a84fdf5 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Thu, 22 Apr 2010 09:30:42 -0700 Subject: Fix __glXInitializeVisualConfigFromTags's handling of unrecognized fbconfig tags. __glXInitializeVisualConfigFromTags doesn't skip the payload of unrecognized tags. Instead, it treats the value as if it were the next tag, which can happen if the server's GLX extension is not Mesa's. For example, this falls down when NVIDIA sends a GLX_FLOAT_COMPONENTS_NV = 0 pair, causing __glXInitializeVisualConfigFromTags to bail out early. Signed-off-by: Aaron Plattner Signed-off-by: Ian Romanick --- src/glx/glxext.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 5289354a521..6d6f89e79a2 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -539,6 +539,8 @@ __glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, i = count; break; default: + /* Ignore the unrecognized tag's value */ + bp++; break; } } -- cgit v1.2.3 From eb2bd2158ed8c1983ef427ea792dc159a2144c08 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 13:05:13 -0600 Subject: st/mesa: replace 'usage' with 'bindings' to be consistent Plus, update comments and formatting. --- src/mesa/state_tracker/st_cb_fbo.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 1ba1fe1b972..e59ece7e966 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -422,23 +422,19 @@ st_finish_render_texture(GLcontext *ctx, /** - * Validate a renderbuffer attachment for a particular usage. + * Validate a renderbuffer attachment for a particular set of bindings. */ - static GLboolean st_validate_attachment(struct pipe_screen *screen, const struct gl_renderbuffer_attachment *att, - GLuint usage) + unsigned bindings) { - const struct st_texture_object *stObj = - st_texture_object(att->Texture); + const struct st_texture_object *stObj = st_texture_object(att->Texture); - /** - * Only validate texture attachments for now, since + /* Only validate texture attachments for now, since * st_renderbuffer_alloc_storage makes sure that * the format is supported. */ - if (att->Type != GL_TEXTURE) return GL_TRUE; @@ -446,10 +442,10 @@ st_validate_attachment(struct pipe_screen *screen, return GL_FALSE; return screen->is_format_supported(screen, stObj->pt->format, - PIPE_TEXTURE_2D, - usage, 0); + PIPE_TEXTURE_2D, bindings, 0); } + /** * Check that the framebuffer configuration is valid in terms of what * the driver can support. -- cgit v1.2.3 From 8283db88414f600e66510de713382c36899d4b03 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 13:12:55 -0600 Subject: st/mesa: replace 'usage' with 'bindings' --- src/mesa/state_tracker/st_cb_texture.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index ed113b5dbc3..5b7d8c0aae1 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -208,17 +208,25 @@ do_memcpy(void *dest, const void *src, size_t n) /** - * Return default texture usage bitmask for the given texture format. + * Return default texture resource binding bitmask for the given format. */ static GLuint -default_usage(enum pipe_format fmt) +default_bindings(struct st_context *st, enum pipe_format format) { - GLuint usage = PIPE_BIND_SAMPLER_VIEW; - if (util_format_is_depth_or_stencil(fmt)) - usage |= PIPE_BIND_DEPTH_STENCIL; + struct pipe_screen *screen = st->pipe->screen; + const unsigned target = PIPE_TEXTURE_2D; + const unsigned geom = 0x0; + unsigned bindings; + + if (util_format_is_depth_or_stencil(format)) + bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DEPTH_STENCIL; + else + bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; + + if (screen->is_format_supported(screen, format, target, bindings, geom)) + return bindings; else - usage |= PIPE_BIND_RENDER_TARGET; - return usage; + return PIPE_BIND_SAMPLER_VIEW; } @@ -246,7 +254,7 @@ guess_and_alloc_texture(struct st_context *st, GLuint width = stImage->base.Width2; /* size w/out border */ GLuint height = stImage->base.Height2; GLuint depth = stImage->base.Depth2; - GLuint i, usage; + GLuint i, bindings; enum pipe_format fmt; DBG("%s\n", __FUNCTION__); @@ -311,7 +319,7 @@ guess_and_alloc_texture(struct st_context *st, fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat); - usage = default_usage(fmt); + bindings = default_bindings(st, fmt); stObj->pt = st_texture_create(st, gl_target_to_pipe(stObj->base.Target), @@ -320,7 +328,7 @@ guess_and_alloc_texture(struct st_context *st, width, height, depth, - usage); + bindings); DBG("%s - success\n", __FUNCTION__); } @@ -1850,7 +1858,7 @@ st_finalize_texture(GLcontext *ctx, if (!stObj->pt) { const enum pipe_format fmt = st_mesa_format_to_pipe_format(firstImage->base.TexFormat); - GLuint usage = default_usage(fmt); + GLuint bindings = default_bindings(ctx->st, fmt); stObj->pt = st_texture_create(ctx->st, gl_target_to_pipe(stObj->base.Target), @@ -1859,7 +1867,7 @@ st_finalize_texture(GLcontext *ctx, firstImage->base.Width2, firstImage->base.Height2, firstImage->base.Depth2, - usage); + bindings); if (!stObj->pt) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); -- cgit v1.2.3 From 4aa4fe8e2103ee43e77f404ef790125dd4d690e5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 13:13:27 -0600 Subject: st/mesa: re-do binding flags in st_ChooseTextureFormat(), again Try to specify render target bindings flags first. If that fails, try again with just sampler view binding. Note that we try to create the texture resource with render target binding flags later when we allocate the texture. Then, in FBO validation, we check if we can actually render to the textures. If that fails, we generate GL_FRAMEBUFFER_UNSUPPORTED_EXT. Changes suggested by Jose. --- src/mesa/state_tracker/st_format.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 2e40659b19e..fa6dd2d6363 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -651,28 +651,33 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type) { enum pipe_format pFormat; - uint usage = PIPE_BIND_SAMPLER_VIEW; + uint bindings; (void) format; (void) type; /* GL textures may wind up being render targets, but we don't know * that in advance. Specify potential render target flags now. - * An alternative would be to destroy and re-create a texture when - * we first start rendering to it. */ - if (!_mesa_is_compressed_format(ctx, internalFormat)) { - if (_mesa_is_depth_format(internalFormat) || - _mesa_is_depthstencil_format(internalFormat)) - usage |= PIPE_BIND_DEPTH_STENCIL; - else - usage |= PIPE_BIND_RENDER_TARGET; - } + if (_mesa_is_depth_format(internalFormat) || + _mesa_is_depthstencil_format(internalFormat)) + bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DEPTH_STENCIL; + else + bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, - PIPE_TEXTURE_2D, usage); - if (pFormat == PIPE_FORMAT_NONE) + PIPE_TEXTURE_2D, bindings); + + if (pFormat == PIPE_FORMAT_NONE) { + /* try choosing format again, this time without render target bindings */ + pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, + PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); + } + + if (pFormat == PIPE_FORMAT_NONE) { + /* no luck at all */ return MESA_FORMAT_NONE; + } return st_pipe_format_to_mesa_format(pFormat); } -- cgit v1.2.3 From 2ce1d6696b1415fcc340bcf888904e43c2792c68 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Apr 2010 21:52:44 +0100 Subject: gallium: s/free/FREE/ and same for friends. Based on Stephen Johnson's feedback. --- src/gallium/auxiliary/util/u_surfaces.c | 2 +- src/gallium/drivers/failover/fo_context.c | 2 +- src/gallium/drivers/failover/fo_state.c | 32 ++++++++++++++--------------- src/gallium/drivers/i965/brw_curbe.c | 2 +- src/gallium/drivers/i965/brw_state_batch.c | 4 ++-- src/gallium/drivers/identity/id_context.c | 6 +++--- src/gallium/drivers/identity/id_drm.c | 2 +- src/gallium/drivers/llvmpipe/lp_scene.c | 2 +- src/gallium/drivers/trace/tr_context.c | 4 ++-- src/gallium/drivers/trace/tr_drm.c | 2 +- src/gallium/winsys/i915/sw/i915_sw_buffer.c | 2 +- 11 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_surfaces.c b/src/gallium/auxiliary/util/u_surfaces.c index 0be4609a207..0248120f557 100644 --- a/src/gallium/auxiliary/util/u_surfaces.c +++ b/src/gallium/auxiliary/util/u_surfaces.c @@ -105,7 +105,7 @@ util_surfaces_destroy(struct util_surfaces *us, struct pipe_resource *pt, void ( if(ps) destroy_surface(ps); } - free(us->u.array); + FREE(us->u.array); us->u.array = NULL; } } diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c index 236c50f4d98..9515cd8938c 100644 --- a/src/gallium/drivers/failover/fo_context.c +++ b/src/gallium/drivers/failover/fo_context.c @@ -39,7 +39,7 @@ static void failover_destroy( struct pipe_context *pipe ) { struct failover_context *failover = failover_context( pipe ); - free( failover ); + FREE( failover ); } diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index b682ce6750e..ff6c59f4109 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -53,7 +53,7 @@ static void * failover_create_blend_state( struct pipe_context *pipe, const struct pipe_blend_state *blend ) { - struct fo_state *state = malloc(sizeof(struct fo_state)); + struct fo_state *state = MALLOC(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); state->sw_state = failover->sw->create_blend_state(failover->sw, blend); @@ -85,7 +85,7 @@ failover_delete_blend_state( struct pipe_context *pipe, failover->hw->delete_blend_state(failover->hw, state->hw_state); state->sw_state = 0; state->hw_state = 0; - free(state); + FREE(state); } static void @@ -129,7 +129,7 @@ static void * failover_create_depth_stencil_state(struct pipe_context *pipe, const struct pipe_depth_stencil_alpha_state *templ) { - struct fo_state *state = malloc(sizeof(struct fo_state)); + struct fo_state *state = MALLOC(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); state->sw_state = failover->sw->create_depth_stencil_alpha_state(failover->sw, templ); @@ -161,7 +161,7 @@ failover_delete_depth_stencil_state(struct pipe_context *pipe, failover->hw->delete_depth_stencil_alpha_state(failover->hw, state->hw_state); state->sw_state = 0; state->hw_state = 0; - free(state); + FREE(state); } static void @@ -181,7 +181,7 @@ static void * failover_create_fs_state(struct pipe_context *pipe, const struct pipe_shader_state *templ) { - struct fo_state *state = malloc(sizeof(struct fo_state)); + struct fo_state *state = MALLOC(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); state->sw_state = failover->sw->create_fs_state(failover->sw, templ); @@ -212,14 +212,14 @@ failover_delete_fs_state(struct pipe_context *pipe, failover->hw->delete_fs_state(failover->hw, state->hw_state); state->sw_state = 0; state->hw_state = 0; - free(state); + FREE(state); } static void * failover_create_vs_state(struct pipe_context *pipe, const struct pipe_shader_state *templ) { - struct fo_state *state = malloc(sizeof(struct fo_state)); + struct fo_state *state = MALLOC(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); state->sw_state = failover->sw->create_vs_state(failover->sw, templ); @@ -252,7 +252,7 @@ failover_delete_vs_state(struct pipe_context *pipe, failover->hw->delete_vs_state(failover->hw, state->hw_state); state->sw_state = 0; state->hw_state = 0; - free(state); + FREE(state); } @@ -262,7 +262,7 @@ failover_create_vertex_elements_state( struct pipe_context *pipe, unsigned count, const struct pipe_vertex_element *velems ) { - struct fo_state *state = malloc(sizeof(struct fo_state)); + struct fo_state *state = MALLOC(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); state->sw_state = failover->sw->create_vertex_elements_state(failover->sw, count, velems); @@ -295,7 +295,7 @@ failover_delete_vertex_elements_state( struct pipe_context *pipe, failover->hw->delete_vertex_elements_state(failover->hw, state->hw_state); state->sw_state = 0; state->hw_state = 0; - free(state); + FREE(state); } static void @@ -315,7 +315,7 @@ static void * failover_create_rasterizer_state(struct pipe_context *pipe, const struct pipe_rasterizer_state *templ) { - struct fo_state *state = malloc(sizeof(struct fo_state)); + struct fo_state *state = MALLOC(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); state->sw_state = failover->sw->create_rasterizer_state(failover->sw, templ); @@ -348,7 +348,7 @@ failover_delete_rasterizer_state(struct pipe_context *pipe, failover->hw->delete_rasterizer_state(failover->hw, state->hw_state); state->sw_state = 0; state->hw_state = 0; - free(state); + FREE(state); } @@ -369,7 +369,7 @@ static void * failover_create_sampler_state(struct pipe_context *pipe, const struct pipe_sampler_state *templ) { - struct fo_state *state = malloc(sizeof(struct fo_state)); + struct fo_state *state = MALLOC(sizeof(struct fo_state)); struct failover_context *failover = failover_context(pipe); state->sw_state = failover->sw->create_sampler_state(failover->sw, templ); @@ -443,7 +443,7 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler) failover->hw->delete_sampler_state(failover->hw, state->hw_state); state->sw_state = 0; state->hw_state = 0; - free(state); + FREE(state); } @@ -452,7 +452,7 @@ failover_create_sampler_view(struct pipe_context *pipe, struct pipe_resource *texture, const struct pipe_sampler_view *templ) { - struct fo_sampler_view *view = malloc(sizeof(struct fo_sampler_view)); + struct fo_sampler_view *view = MALLOC(sizeof(struct fo_sampler_view)); struct failover_context *failover = failover_context(pipe); view->sw = failover->sw->create_sampler_view(failover->sw, texture, templ); @@ -478,7 +478,7 @@ failover_sampler_view_destroy(struct pipe_context *pipe, failover->hw->sampler_view_destroy(failover->hw, fo_view->hw); pipe_resource_reference(&fo_view->base.texture, NULL); - free(fo_view); + FREE(fo_view); } static void diff --git a/src/gallium/drivers/i965/brw_curbe.c b/src/gallium/drivers/i965/brw_curbe.c index 323af16b145..a701de33f5d 100644 --- a/src/gallium/drivers/i965/brw_curbe.c +++ b/src/gallium/drivers/i965/brw_curbe.c @@ -168,7 +168,7 @@ static enum pipe_error prepare_curbe_buffer(struct brw_context *brw) if (sz == 0) { if (brw->curbe.last_buf) { - free(brw->curbe.last_buf); + FREE(brw->curbe.last_buf); brw->curbe.last_buf = NULL; brw->curbe.last_bufsz = 0; } diff --git a/src/gallium/drivers/i965/brw_state_batch.c b/src/gallium/drivers/i965/brw_state_batch.c index 7d212e5c247..ce5ed0a9ed2 100644 --- a/src/gallium/drivers/i965/brw_state_batch.c +++ b/src/gallium/drivers/i965/brw_state_batch.c @@ -84,8 +84,8 @@ void brw_clear_batch_cache( struct brw_context *brw ) while (item) { struct brw_cached_batch_item *next = item->next; - free((void *)item->header); - free(item); + FREE((void *)item->header); + FREE(item); item = next; } diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 630cdb5e491..0bc8bf21966 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -42,7 +42,7 @@ identity_destroy(struct pipe_context *_pipe) pipe->destroy(pipe); - free(id_pipe); + FREE(id_pipe); } static void @@ -708,7 +708,7 @@ identity_create_sampler_view(struct pipe_context *pipe, struct identity_resource *id_resource = identity_resource(texture); struct pipe_context *pipe_unwrapped = id_pipe->pipe; struct pipe_resource *texture_unwrapped = id_resource->resource; - struct identity_sampler_view *view = malloc(sizeof(struct identity_sampler_view)); + struct identity_sampler_view *view = MALLOC(sizeof(struct identity_sampler_view)); view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped, texture_unwrapped, @@ -736,7 +736,7 @@ identity_sampler_view_destroy(struct pipe_context *pipe, view_unwrapped); pipe_resource_reference(&view->texture, NULL); - free(view); + FREE(view); } static struct pipe_transfer * diff --git a/src/gallium/drivers/identity/id_drm.c b/src/gallium/drivers/identity/id_drm.c index d332c36af26..a9d41af18c7 100644 --- a/src/gallium/drivers/identity/id_drm.c +++ b/src/gallium/drivers/identity/id_drm.c @@ -68,7 +68,7 @@ identity_drm_destroy(struct drm_api *_api) struct drm_api *api = id_api->api; api->destroy(api); - free(id_api); + FREE(id_api); } struct drm_api * diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index 0b185c4c412..71d9529230b 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -74,7 +74,7 @@ lp_scene_create( struct pipe_context *pipe, /** - * Free all data associated with the given scene, and free(scene). + * Free all data associated with the given scene, and the scene itself. */ void lp_scene_destroy(struct lp_scene *scene) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 8216c06260f..71ba1e909df 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1142,12 +1142,12 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, trace_dump_arg_end(); if (num_buffers) { - struct pipe_vertex_buffer *_buffers = malloc(num_buffers * sizeof(*_buffers)); + struct pipe_vertex_buffer *_buffers = MALLOC(num_buffers * sizeof(*_buffers)); memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers)); for (i = 0; i < num_buffers; i++) _buffers[i].buffer = trace_resource_unwrap(tr_ctx, buffers[i].buffer); pipe->set_vertex_buffers(pipe, num_buffers, _buffers); - free(_buffers); + FREE(_buffers); } else { pipe->set_vertex_buffers(pipe, num_buffers, NULL); } diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c index eaa47df4066..0dc8cca2648 100644 --- a/src/gallium/drivers/trace/tr_drm.c +++ b/src/gallium/drivers/trace/tr_drm.c @@ -73,7 +73,7 @@ trace_drm_destroy(struct drm_api *_api) if (api->destroy) api->destroy(api); - free(tr_api); + FREE(tr_api); } struct drm_api * diff --git a/src/gallium/winsys/i915/sw/i915_sw_buffer.c b/src/gallium/winsys/i915/sw/i915_sw_buffer.c index 9a27da5e1a2..df175688861 100644 --- a/src/gallium/winsys/i915/sw/i915_sw_buffer.c +++ b/src/gallium/winsys/i915/sw/i915_sw_buffer.c @@ -27,7 +27,7 @@ i915_sw_buffer_create(struct i915_winsys *iws, buf->magic = 0xDEAD1337; buf->name = name; buf->type = type; - buf->ptr = calloc(size, 1); + buf->ptr = CALLOC(size, 1); if (!buf->ptr) goto err; -- cgit v1.2.3 From 7159303dbf5ae4023e41dd188f3391807f5b892b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 22 Apr 2010 18:20:06 +0100 Subject: gallium: Add option to not print options --- src/gallium/auxiliary/util/u_debug.c | 42 +++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index dd044973f96..0de38e791d6 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -74,6 +74,24 @@ void debug_print_blob( const char *name, #endif +static boolean +debug_get_option_should_print(void) +{ + static boolean first = TRUE; + static boolean value = FALSE; + + if (!first) + return value; + + /* Oh hey this will call into this function, + * but its cool since we set first to false + */ + first = FALSE; + value = debug_get_bool_option("GALLIUM_PRINT_OPTIONS", TRUE); + /* XXX should we print this option? Currently it wont */ + return value; +} + const char * debug_get_option(const char *name, const char *dfault) { @@ -82,8 +100,9 @@ debug_get_option(const char *name, const char *dfault) result = os_get_option(name); if(!result) result = dfault; - - debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? result : "(null)"); + + if (debug_get_option_should_print()) + debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? result : "(null)"); return result; } @@ -109,7 +128,8 @@ debug_get_bool_option(const char *name, boolean dfault) else result = TRUE; - debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? "TRUE" : "FALSE"); + if (debug_get_option_should_print()) + debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? "TRUE" : "FALSE"); return result; } @@ -142,8 +162,9 @@ debug_get_num_option(const char *name, long dfault) } result *= sign; } - - debug_printf("%s: %s = %li\n", __FUNCTION__, name, result); + + if (debug_get_option_should_print()) + debug_printf("%s: %s = %li\n", __FUNCTION__, name, result); return result; } @@ -176,11 +197,12 @@ debug_get_flags_option(const char *name, } } - if (str) { - debug_printf("%s: %s = 0x%lx (%s)\n", __FUNCTION__, name, result, str); - } - else { - debug_printf("%s: %s = 0x%lx\n", __FUNCTION__, name, result); + if (debug_get_option_should_print()) { + if (str) { + debug_printf("%s: %s = 0x%lx (%s)\n", __FUNCTION__, name, result, str); + } else { + debug_printf("%s: %s = 0x%lx\n", __FUNCTION__, name, result); + } } return result; -- cgit v1.2.3 From 89aaaab79f407dd691e0a98167f48a0860ec791a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 22 Apr 2010 18:19:39 +0100 Subject: gallium: Add static get option helpers --- src/gallium/auxiliary/util/u_debug.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index b6d0b508e30..ec3371a9b25 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -303,6 +303,39 @@ debug_get_flags_option(const char *name, const struct debug_named_value *flags, unsigned long dfault); +#define DEBUG_GET_ONCE_BOOL_OPTION(sufix, name, dfault) \ +static boolean \ +debug_get_option_ ## sufix (void) \ +{ \ + static boolean first = TRUE; \ + static boolean value; \ + if (first && !(first = FALSE)) \ + value = debug_get_bool_option(name, dfault); \ + return value; \ +} + +#define DEBUG_GET_ONCE_NUM_OPTION(sufix, name, dfault) \ +static long \ +debug_get_option_ ## sufix (void) \ +{ \ + static boolean first = TRUE; \ + static long value; \ + if (first && !(first = FALSE)) \ + value = debug_get_num_option(name, dfault); \ + return value; \ +} + +#define DEBUG_GET_ONCE_FLAGS_OPTION(sufix, name, flags, dfault) \ +static unsigned long \ +debug_get_option_ ## sufix (void) \ +{ \ + static boolean first = TRUE; \ + static unsigned long value; \ + if (first && !(first = FALSE)) \ + value = debug_get_flags_option(name, flags, dfault); \ + return value; \ +} + unsigned long debug_memory_begin(void); -- cgit v1.2.3 From 1820d240cd0b517ca1d73f1e8e0a528ca8d5b092 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 22 Apr 2010 18:20:31 +0100 Subject: gallium: Convert some uses of get option to static --- src/gallium/auxiliary/draw/draw_pt.c | 13 ++++++++++--- src/gallium/auxiliary/draw/draw_vs.c | 4 ++-- src/gallium/winsys/sw/xlib/xlib_sw_winsys.c | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index b5876bb1bdb..c40c25dc3a1 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -37,6 +37,13 @@ #include "util/u_math.h" #include "util/u_prim.h" + +DEBUG_GET_ONCE_BOOL_OPTION(draw_fse, "DRAW_FSE", FALSE); +DEBUG_GET_ONCE_BOOL_OPTION(draw_no_fse, "DRAW_NO_FSE", FALSE); +#ifdef HAVE_LLVM +DEBUG_GET_ONCE_BOOL_OPTION(draw_use_llvm, "DRAW_USE_LLVM", TRUE); +#endif + static unsigned trim( unsigned count, unsigned first, unsigned incr ) { if (count < first) @@ -122,8 +129,8 @@ draw_pt_arrays(struct draw_context *draw, boolean draw_pt_init( struct draw_context *draw ) { - draw->pt.test_fse = debug_get_bool_option("DRAW_FSE", FALSE); - draw->pt.no_fse = debug_get_bool_option("DRAW_NO_FSE", FALSE); + draw->pt.test_fse = debug_get_option_draw_fse(); + draw->pt.no_fse = debug_get_option_draw_no_fse(); draw->pt.front.vcache = draw_pt_vcache( draw ); if (!draw->pt.front.vcache) @@ -142,7 +149,7 @@ boolean draw_pt_init( struct draw_context *draw ) return FALSE; #if HAVE_LLVM - draw->use_llvm = debug_get_bool_option("DRAW_USE_LLVM", TRUE); + draw->use_llvm = debug_get_option_draw_use_llvm(); if (draw->use_llvm) draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw ); #else diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index cfd51540241..0c059573505 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -46,7 +46,7 @@ #include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_exec.h" - +DEBUG_GET_ONCE_BOOL_OPTION(gallium_dump_vs, "GALLIUM_DUMP_VS", FALSE); void draw_vs_set_constants(struct draw_context *draw, @@ -157,7 +157,7 @@ draw_delete_vertex_shader(struct draw_context *draw, boolean draw_vs_init( struct draw_context *draw ) { - draw->dump_vs = debug_get_bool_option("GALLIUM_DUMP_VS", FALSE); + draw->dump_vs = debug_get_option_gallium_dump_vs(); draw->vs.machine = tgsi_exec_machine_create(); if (!draw->vs.machine) diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c index 278a191a0e5..679af611bfc 100644 --- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c @@ -48,6 +48,8 @@ #include #include +DEBUG_GET_ONCE_BOOL_OPTION(xlib_no_shm, "XLIB_NO_SHM", FALSE); + /** * Display target for Xlib winsys. * Low-level OS/window system memory buffer @@ -383,7 +385,7 @@ xm_displaytarget_create(struct sw_winsys *winsys, xm_dt->stride = align(util_format_get_stride(format, width), alignment); size = xm_dt->stride * nblocksy; - if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) + if (!debug_get_option_xlib_no_shm()) { xm_dt->data = alloc_shm(xm_dt, size); if(!xm_dt->data) { -- cgit v1.2.3 From 06441af657a1956a5b2a700a70a2b59b0488ee84 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 10:57:34 -0600 Subject: gallium/draw: remove old comment --- src/gallium/auxiliary/draw/draw_pipe_wide_line.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c index 265a420d01e..ab167065815 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c @@ -54,7 +54,6 @@ static INLINE struct wideline_stage *wideline_stage( struct draw_stage *stage ) /** * Draw a wide line by drawing a quad (two triangles). - * XXX need to disable polygon stipple. */ static void wideline_line( struct draw_stage *stage, struct prim_header *header ) -- cgit v1.2.3 From 67f928eef38f65462dcb286c0beb17ac02041562 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 15:39:43 -0600 Subject: gallium/failover: include u_memory.h for MALLOC, FREE --- src/gallium/drivers/failover/fo_state.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index ff6c59f4109..272e683067e 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -29,6 +29,7 @@ */ #include "util/u_inlines.h" +#include "util/u_memory.h" #include "fo_context.h" -- cgit v1.2.3 From 57fc2e7802d1903848c2d7799f7e36308818b2e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 13:38:13 -0600 Subject: mesa: simplify some code in _mesa_generate_mipmap() --- src/mesa/main/mipmap.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 51f7edfab12..c0c29f78893 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1581,7 +1581,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_image *dstImage; GLint srcWidth, srcHeight, srcDepth; GLint dstWidth, dstHeight, dstDepth; - GLint border, bytesPerTexel; + GLint border; GLboolean nextLevel; /* get src image parameters */ @@ -1623,33 +1623,24 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, dstImage->FetchTexelc = srcImage->FetchTexelc; dstImage->FetchTexelf = srcImage->FetchTexelf; - /* Alloc new teximage data buffer. - * Setup src and dest data pointers. - */ - if (_mesa_is_format_compressed(dstImage->TexFormat)) { - GLuint dstCompressedSize = - _mesa_format_image_size(dstImage->TexFormat, dstImage->Width, - dstImage->Height, dstImage->Depth); - ASSERT(dstCompressedSize > 0); - - dstImage->Data = _mesa_alloc_texmemory(dstCompressedSize); + /* Alloc new teximage data buffer */ + { + GLuint size = _mesa_format_image_size(dstImage->TexFormat, + dstWidth, dstHeight, dstDepth); + dstImage->Data = _mesa_alloc_texmemory(size); if (!dstImage->Data) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); return; } + } + + /* Setup src and dest data pointers */ + if (_mesa_is_format_compressed(dstImage->TexFormat)) { /* srcData and dstData are already set */ ASSERT(srcData); ASSERT(dstData); } else { - bytesPerTexel = _mesa_get_format_bytes(dstImage->TexFormat); - ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0); - dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight - * dstDepth * bytesPerTexel); - if (!dstImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); - return; - } srcData = (const GLubyte *) srcImage->Data; dstData = (GLubyte *) dstImage->Data; } -- cgit v1.2.3 From 76c7ad2e7d387feefe58dc2116b613fe11a8b273 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 14:00:50 -0600 Subject: st/mesa: clean-up: use st_context() everywhere --- src/mesa/state_tracker/st_atom_pixeltransfer.c | 15 +++-- src/mesa/state_tracker/st_cb_accum.c | 4 +- src/mesa/state_tracker/st_cb_bitmap.c | 22 ++++--- src/mesa/state_tracker/st_cb_blit.c | 2 +- src/mesa/state_tracker/st_cb_clear.c | 13 ++-- src/mesa/state_tracker/st_cb_condrender.c | 4 +- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_cb_eglimage.c | 4 +- src/mesa/state_tracker/st_cb_fbo.c | 19 ++++-- src/mesa/state_tracker/st_cb_feedback.c | 4 +- src/mesa/state_tracker/st_cb_flush.c | 4 +- src/mesa/state_tracker/st_cb_queryobj.c | 10 +-- src/mesa/state_tracker/st_cb_rasterpos.c | 6 +- src/mesa/state_tracker/st_cb_readpixels.c | 11 ++-- src/mesa/state_tracker/st_cb_texture.c | 90 ++++++++++++++------------ src/mesa/state_tracker/st_debug.c | 2 +- src/mesa/state_tracker/st_draw.c | 23 ++++--- src/mesa/state_tracker/st_draw_feedback.c | 8 +-- src/mesa/state_tracker/st_format.c | 5 +- src/mesa/state_tracker/st_gen_mipmap.c | 4 +- 20 files changed, 138 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index e8e67f80305..29c4d092bf0 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -115,7 +115,8 @@ make_state_key(GLcontext *ctx, struct state_key *key) static struct pipe_resource * create_color_map_texture(GLcontext *ctx) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_resource *pt; enum pipe_format format; const uint texSize = 256; /* simple, and usually perfect */ @@ -125,7 +126,7 @@ create_color_map_texture(GLcontext *ctx) PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); /* create texture for color map/table */ - pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, + pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, texSize, texSize, 1, PIPE_BIND_SAMPLER_VIEW); return pt; } @@ -137,7 +138,8 @@ create_color_map_texture(GLcontext *ctx) static void load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_transfer *transfer; const GLuint rSize = ctx->PixelMaps.RtoR.Size; const GLuint gSize = ctx->PixelMaps.GtoG.Size; @@ -185,7 +187,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt) static struct gl_fragment_program * get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct prog_instruction inst[MAX_INST]; struct gl_program_parameter_list *params; struct gl_fragment_program *fp; @@ -256,8 +258,9 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key) /* create the colormap/texture now if not already done */ if (!st->pixel_xfer.pixelmap_texture) { st->pixel_xfer.pixelmap_texture = create_color_map_texture(ctx); - st->pixel_xfer.pixelmap_sampler_view = st_create_texture_sampler_view(ctx->st->pipe, - st->pixel_xfer.pixelmap_texture); + st->pixel_xfer.pixelmap_sampler_view = + st_create_texture_sampler_view(st->pipe, + st->pixel_xfer.pixelmap_texture); } /* with a little effort, we can do four pixel map look-ups with diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 2732969d956..0101837f999 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -223,7 +223,7 @@ accum_return(GLcontext *ctx, GLfloat value, struct st_renderbuffer *acc_strb, struct st_renderbuffer *color_strb) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; const GLubyte *colormask = ctx->Color.ColorMask[0]; enum pipe_transfer_usage usage; struct pipe_transfer *color_trans; @@ -287,7 +287,7 @@ accum_return(GLcontext *ctx, GLfloat value, static void st_Accum(GLcontext *ctx, GLenum op, GLfloat value) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_renderbuffer *acc_strb = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); struct st_renderbuffer *color_strb diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 12bba050a61..797c0ba7f55 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -114,6 +114,7 @@ struct bitmap_cache static struct st_fragment_program * make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex) { + struct st_context *st = st_context(ctx); struct st_fragment_program *stfp; struct gl_program *p; GLuint ic = 0; @@ -145,7 +146,7 @@ make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex) p->Instructions[ic].Opcode = OPCODE_KIL; p->Instructions[ic].SrcReg[0].File = PROGRAM_TEMPORARY; - if (ctx->st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM) + if (st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM) p->Instructions[ic].SrcReg[0].Swizzle = SWIZZLE_XXXX; p->Instructions[ic].SrcReg[0].Index = 0; @@ -187,7 +188,7 @@ find_free_bit(uint bitfield) static struct st_fragment_program * combined_bitmap_fragment_program(GLcontext *ctx) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_fragment_program *stfp = st->fp; if (!stfp->bitmap_program) { @@ -258,7 +259,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_transfer *transfer; ubyte *dest; struct pipe_resource *pt; @@ -272,7 +274,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, /** * Create texture to hold bitmap pattern. */ - pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, ctx->st->bitmap.tex_format, + pt = st_texture_create(st, PIPE_TEXTURE_2D, st->bitmap.tex_format, 0, width, height, 1, PIPE_BIND_SAMPLER_VIEW); if (!pt) { @@ -280,7 +282,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, return NULL; } - transfer = st_no_flush_get_tex_transfer(st_context(ctx), pt, 0, 0, 0, + transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, width, height); @@ -288,7 +290,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, /* Put image into texture transfer */ memset(dest, 0xff, height * transfer->stride); - unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap, + unpack_bitmap(st, 0, 0, width, height, unpack, bitmap, dest, transfer->stride); _mesa_unmap_pbo_source(ctx, unpack); @@ -400,9 +402,9 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_sampler_view *sv, const GLfloat *color) { - struct st_context *st = ctx->st; - struct pipe_context *pipe = ctx->st->pipe; - struct cso_context *cso = ctx->st->cso_context; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; + struct cso_context *cso = st->cso_context; struct st_fragment_program *stfp; GLuint maxSize; GLuint offset; @@ -732,7 +734,7 @@ static void st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_resource *pt; if (width == 0 || height == 0) diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index d6fdfaccd63..1c8dc0c07fb 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -68,7 +68,7 @@ st_BlitFramebuffer(GLcontext *ctx, { const GLbitfield depthStencil = (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; const uint pFilter = ((filter == GL_NEAREST) ? PIPE_TEX_MIPFILTER_NEAREST diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 2f77aff7a6c..736180ddc6c 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -109,11 +109,10 @@ st_destroy_clear(struct st_context *st) * Coords are clip coords with y=0=bottom. */ static void -draw_quad(GLcontext *ctx, +draw_quad(struct st_context *st, float x0, float y0, float x1, float y1, GLfloat z, const GLfloat color[4]) { - struct st_context *st = ctx->st; struct pipe_context *pipe = st->pipe; /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as @@ -193,7 +192,7 @@ static void clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); const struct gl_framebuffer *fb = ctx->DrawBuffer; const GLfloat fb_width = (GLfloat) fb->Width; const GLfloat fb_height = (GLfloat) fb->Height; @@ -295,7 +294,7 @@ clear_with_quad(GLcontext *ctx, cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); /* draw quad matching scissor rect (XXX verify coord round-off) */ - draw_quad(ctx, x0, y0, x1, y1, + draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor); /* Restore pipe state */ @@ -448,7 +447,7 @@ st_Clear(GLcontext *ctx, GLbitfield mask) { static const GLbitfield BUFFER_BITS_DS = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct gl_renderbuffer *depthRb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; struct gl_renderbuffer *stencilRb @@ -530,8 +529,8 @@ st_Clear(GLcontext *ctx, GLbitfield mask) mask & BUFFER_BIT_DEPTH, mask & BUFFER_BIT_STENCIL); } else if (clear_buffers) - ctx->st->pipe->clear(ctx->st->pipe, clear_buffers, ctx->Color.ClearColor, - ctx->Depth.Clear, ctx->Stencil.Clear); + st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColor, + ctx->Depth.Clear, ctx->Stencil.Clear); if (mask & BUFFER_BIT_ACCUM) st_clear_accum_buffer(ctx, diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c index 8483b93bd85..b509d43b7c6 100644 --- a/src/mesa/state_tracker/st_cb_condrender.c +++ b/src/mesa/state_tracker/st_cb_condrender.c @@ -51,7 +51,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q, GLenum mode) { struct st_query_object *stq = st_query_object(q); - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; uint m; switch (mode) { @@ -82,7 +82,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q, static void st_EndConditionalRender(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; (void) q; pipe->render_condition(pipe, NULL, 0); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 2c18ded2abf..e059002f157 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -858,7 +858,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLint dstx, GLint dsty) { struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer); - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; enum pipe_transfer_usage usage; struct pipe_transfer *ptDraw; ubyte *drawMap; diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index a924f872232..0fa1848e232 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -74,7 +74,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLeglImageOES image_handle) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_renderbuffer *strb = st_renderbuffer(rb); struct pipe_surface *ps; unsigned usage; @@ -138,7 +138,7 @@ st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target, struct gl_texture_image *texImage, GLeglImageOES image_handle) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_surface *ps; unsigned usage; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index e59ece7e966..e5c956d561d 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -64,7 +64,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; struct st_renderbuffer *strb = st_renderbuffer(rb); enum pipe_format format; @@ -312,9 +313,9 @@ st_render_texture(GLcontext *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = ctx->st->pipe->screen; + struct pipe_screen *screen = pipe->screen; struct st_renderbuffer *strb; struct gl_renderbuffer *rb; struct pipe_resource *pt = st_get_texobj_resource(att->Texture); @@ -403,12 +404,13 @@ static void st_finish_render_texture(GLcontext *ctx, struct gl_renderbuffer_attachment *att) { + struct st_context *st = st_context(ctx); struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer); if (!strb) return; - st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL ); + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); strb->rtt = NULL; @@ -455,7 +457,8 @@ st_validate_attachment(struct pipe_screen *screen, static void st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; const struct gl_renderbuffer *depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; const struct gl_renderbuffer *stencilRb = @@ -496,6 +499,7 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) static void st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) { + struct st_context *st = st_context(ctx); GLframebuffer *fb = ctx->DrawBuffer; GLuint i; @@ -505,7 +509,7 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) /* add the renderbuffers on demand */ for (i = 0; i < fb->_NumColorDrawBuffers; i++) { gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i]; - st_manager_add_color_renderbuffer(ctx->st, fb, idx); + st_manager_add_color_renderbuffer(st, fb, idx); } } @@ -516,12 +520,13 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) static void st_ReadBuffer(GLcontext *ctx, GLenum buffer) { + struct st_context *st = st_context(ctx); GLframebuffer *fb = ctx->ReadBuffer; (void) buffer; /* add the renderbuffer on demand */ - st_manager_add_color_renderbuffer(ctx->st, fb, fb->_ColorReadBufferIndex); + st_manager_add_color_renderbuffer(st, fb, fb->_ColorReadBufferIndex); } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 37b1fb55f4a..c85d3da84a2 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -80,7 +80,7 @@ static void feedback_vertex(GLcontext *ctx, const struct draw_context *draw, const struct vertex_header *v) { - const struct st_context *st = ctx->st; + const struct st_context *st = st_context(ctx); GLfloat win[4]; const GLfloat *color, *texcoord; GLuint slot; @@ -271,7 +271,7 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw) static void st_RenderMode(GLcontext *ctx, GLenum newMode ) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct draw_context *draw = st->draw; if (newMode == GL_RENDER) { diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 415e8f3d2a2..8c9959f9544 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -115,7 +115,7 @@ void st_finish( struct st_context *st ) */ static void st_glFlush(GLcontext *ctx) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); /* Don't call st_finish() here. It is not the state tracker's * responsibilty to inject sleeps in the hope of avoiding buffer @@ -135,7 +135,7 @@ static void st_glFlush(GLcontext *ctx) */ static void st_glFinish(GLcontext *ctx) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); st_finish(st); diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index c66729b1244..1896663932c 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -61,7 +61,7 @@ st_NewQueryObject(GLcontext *ctx, GLuint id) static void st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); if (stq->pq) { @@ -76,7 +76,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q) static void st_BeginQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); switch (q->Target) { @@ -96,7 +96,7 @@ st_BeginQuery(GLcontext *ctx, struct gl_query_object *q) static void st_EndQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); pipe->end_query(pipe, stq->pq); @@ -106,7 +106,7 @@ st_EndQuery(GLcontext *ctx, struct gl_query_object *q) static void st_WaitQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); /* this function should only be called if we don't have a ready result */ @@ -128,7 +128,7 @@ st_WaitQuery(GLcontext *ctx, struct gl_query_object *q) static void st_CheckQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); assert(!q->Ready); /* we should not get called if Ready is TRUE */ q->Ready = pipe->get_query_result(pipe, stq->pq, FALSE, &q->Result); diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 752b411b5fc..843f3200278 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -133,7 +133,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) { struct rastpos_stage *rs = rastpos_stage(stage); GLcontext *ctx = rs->ctx; - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); const GLfloat height = (GLfloat) ctx->DrawBuffer->Height; const GLuint *outputMapping = st->vertex_result_to_slot; const GLfloat *pos; @@ -221,7 +221,7 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) static void st_RasterPos(GLcontext *ctx, const GLfloat v[4]) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct draw_context *draw = st->draw; struct rastpos_stage *rs; @@ -239,7 +239,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) draw_set_rasterize_stage(st->draw, st->rastpos_stage); /* make sure everything's up to date */ - st_validate_state(ctx->st); + st_validate_state(st); /* This will get set only if rastpos_point(), above, gets called */ ctx->Current.RasterPosValid = GL_FALSE; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 67c3b9adbb9..69950ac44bb 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -63,7 +63,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, GLvoid *pixels) { struct gl_framebuffer *fb = ctx->ReadBuffer; - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer); struct pipe_transfer *pt; ubyte *stmap; @@ -220,7 +220,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, /*printf("st_fast_readpixels combo %d\n", (GLint) combo);*/ { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct pipe_transfer *trans; const GLubyte *map; GLubyte *dst; @@ -322,7 +322,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *pack, GLvoid *dest) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; GLfloat temp[MAX_WIDTH][4]; const GLbitfield transferOps = ctx->_ImageTransferState; GLsizei i, j; @@ -337,7 +338,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* XXX convolution not done yet */ assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0); - st_validate_state(ctx->st); + st_validate_state(st); /* Do all needed clipping here, so that we can forget about it later */ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) { @@ -349,7 +350,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, if (!dest) return; - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); if (format == GL_STENCIL_INDEX || format == GL_DEPTH_STENCIL) { diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 5b7d8c0aae1..613fff019d9 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -120,17 +120,18 @@ static void st_DeleteTextureObject(GLcontext *ctx, struct gl_texture_object *texObj) { + struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(texObj); if (stObj->pt) pipe_resource_reference(&stObj->pt, NULL); if (stObj->sampler_view) { - if (stObj->sampler_view->context != ctx->st->pipe) { + if (stObj->sampler_view->context != st->pipe) { /* Take "ownership" of this texture sampler view by setting * its context pointer to this context. This avoids potential * crashes when the texture object is shared among contexts * and the original/owner context has already been destroyed. */ - stObj->sampler_view->context = ctx->st->pipe; + stObj->sampler_view->context = st->pipe; } pipe_sampler_view_reference(&stObj->sampler_view, NULL); } @@ -389,7 +390,8 @@ compress_with_blit(GLcontext * ctx, { const GLuint dstImageOffsets[1] = {0}; struct st_texture_image *stImage = st_texture_image(texImage); - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; gl_format mesa_format; struct pipe_resource templ; @@ -466,7 +468,7 @@ compress_with_blit(GLcontext * ctx, /* copy / compress image */ - util_blit_pixels_tex(ctx->st->blit, + util_blit_pixels_tex(st->blit, src_view, /* sampler view (src) */ 0, 0, /* src x0, y0 */ width, height, /* src x1, y1 */ @@ -501,7 +503,8 @@ st_TexImage(GLcontext * ctx, struct gl_texture_image *texImage, GLsizei imageSize, GLboolean compressed_src) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; struct st_texture_object *stObj = st_texture_object(texObj); struct st_texture_image *stImage = st_texture_image(texImage); GLint postConvWidth, postConvHeight; @@ -596,13 +599,13 @@ st_TexImage(GLcontext * ctx, } if (!stObj->pt) { - guess_and_alloc_texture(ctx->st, stObj, stImage); + guess_and_alloc_texture(st, stObj, stImage); if (!stObj->pt) { /* Probably out of memory. * Try flushing any pending rendering, then retry. */ - st_finish(ctx->st); - guess_and_alloc_texture(ctx->st, stObj, stImage); + st_finish(st); + guess_and_alloc_texture(st, stObj, stImage); if (!stObj->pt) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); return; @@ -667,7 +670,7 @@ st_TexImage(GLcontext * ctx, else transfer_usage = PIPE_TRANSFER_WRITE; - texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + texImage->Data = st_texture_image_map(st, stImage, 0, transfer_usage, 0, 0, stImage->base.Width, stImage->base.Height); @@ -748,9 +751,9 @@ st_TexImage(GLcontext * ctx, if (stImage->pt && i + 1 < depth) { /* unmap this slice */ - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); /* map next slice of 3D texture */ - texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1, + texImage->Data = st_texture_image_map(st, stImage, i + 1, transfer_usage, 0, 0, stImage->base.Width, stImage->base.Height); @@ -763,7 +766,7 @@ done: _mesa_unmap_teximage_pbo(ctx, unpack); if (stImage->pt && texImage->Data) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -840,7 +843,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; struct st_texture_image *stImage = st_texture_image(texImage); struct st_texture_object *stObj = st_texture_object(texObj); @@ -864,7 +868,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, } /* blit/render/decompress */ - util_blit_pixels_tex(ctx->st->blit, + util_blit_pixels_tex(st->blit, src_view, /* pipe_resource (src) */ 0, 0, /* src x0, y0 */ width, height, /* src x1, y1 */ @@ -936,6 +940,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage, GLboolean compressed_dst) { + struct st_context *st = st_context(ctx); struct st_texture_image *stImage = st_texture_image(texImage); const GLuint dstImageStride = _mesa_image_image_stride(&ctx->Pack, texImage->Width, texImage->Height, @@ -962,10 +967,10 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, */ unsigned face = _mesa_tex_target_to_face(target); - st_teximage_flush_before_map(ctx->st, stImage->pt, face, level, + st_teximage_flush_before_map(st, stImage->pt, face, level, PIPE_TRANSFER_READ); - texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_READ, 0, 0, stImage->base.Width, stImage->base.Height); @@ -1000,9 +1005,9 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, if (stImage->pt && i + 1 < depth) { /* unmap this slice */ - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); /* map next slice of 3D texture */ - texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1, + texImage->Data = st_texture_image_map(st, stImage, i + 1, PIPE_TRANSFER_READ, 0, 0, stImage->base.Width, stImage->base.Height); @@ -1014,7 +1019,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, /* Unmap */ if (stImage->pt) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -1052,7 +1057,8 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; struct st_texture_image *stImage = st_texture_image(texImage); GLuint dstRowStride; const GLuint srcImageStride = @@ -1100,9 +1106,9 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(ctx->st, stImage->pt, face, level, + st_teximage_flush_before_map(st, stImage->pt, face, level, transfer_usage); - texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset, + texImage->Data = st_texture_image_map(st, stImage, zoffset, transfer_usage, xoffset, yoffset, width, height); @@ -1130,9 +1136,9 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, if (stImage->pt && i + 1 < depth) { /* unmap this slice */ - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); /* map next slice of 3D texture */ - texImage->Data = st_texture_image_map(ctx->st, stImage, + texImage->Data = st_texture_image_map(st, stImage, zoffset + i + 1, transfer_usage, xoffset, yoffset, @@ -1145,7 +1151,7 @@ done: _mesa_unmap_teximage_pbo(ctx, packing); if (stImage->pt && texImage->Data) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -1216,6 +1222,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { + struct st_context *st = st_context(ctx); struct st_texture_image *stImage = st_texture_image(texImage); int srcBlockStride; int dstBlockStride; @@ -1226,9 +1233,9 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, unsigned face = _mesa_tex_target_to_face(target); pformat = stImage->pt->format; - st_teximage_flush_before_map(ctx->st, stImage->pt, face, level, + st_teximage_flush_before_map(st, stImage->pt, face, level, PIPE_TRANSFER_WRITE); - texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_WRITE, xoffset, yoffset, width, height); @@ -1260,7 +1267,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, } if (stImage->pt) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -1296,7 +1303,8 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, GLint srcX, GLint srcY, GLsizei width, GLsizei height) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_transfer *src_trans; GLvoid *texDest; enum pipe_transfer_usage transfer_usage; @@ -1324,10 +1332,10 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(ctx->st, stImage->pt, 0, 0, + st_teximage_flush_before_map(st, stImage->pt, 0, 0, transfer_usage); - texDest = st_texture_image_map(ctx->st, stImage, 0, transfer_usage, + texDest = st_texture_image_map(st, stImage, 0, transfer_usage, destX, destY, width, height); if (baseFormat == GL_DEPTH_COMPONENT || @@ -1402,7 +1410,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, free(tempSrc); } - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); pipe->transfer_destroy(pipe, src_trans); } @@ -1498,7 +1506,8 @@ st_copy_texsubimage(GLcontext *ctx, const GLenum texBaseFormat = texImage->_BaseFormat; struct gl_framebuffer *fb = ctx->ReadBuffer; struct st_renderbuffer *strb; - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; enum pipe_format dest_format, src_format; GLboolean use_fallback = GL_TRUE; @@ -1508,11 +1517,11 @@ st_copy_texsubimage(GLcontext *ctx, GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); /* any rendering in progress must flushed before we grab the fb image */ - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); /* make sure finalize_textures has been called? */ - if (0) st_validate_state(ctx->st); + if (0) st_validate_state(st); /* determine if copying depth or color data */ if (texBaseFormat == GL_DEPTH_COMPONENT || @@ -1629,7 +1638,7 @@ st_copy_texsubimage(GLcontext *ctx, srcY0 = srcY; srcY1 = srcY0 + height; } - util_blit_pixels_writemask(ctx->st->blit, + util_blit_pixels_writemask(st->blit, strb->surface, st_get_renderbuffer_sampler_view(strb, pipe), srcX, srcY0, @@ -1796,6 +1805,7 @@ st_finalize_texture(GLcontext *ctx, struct gl_texture_object *tObj, GLboolean *needFlush) { + struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(tObj); const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; GLuint blockSize, face; @@ -1849,7 +1859,7 @@ st_finalize_texture(GLcontext *ctx, { pipe_resource_reference(&stObj->pt, NULL); pipe_sampler_view_reference(&stObj->sampler_view, NULL); - ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER; + st->dirty.st |= ST_NEW_FRAMEBUFFER; } } @@ -1858,9 +1868,9 @@ st_finalize_texture(GLcontext *ctx, if (!stObj->pt) { const enum pipe_format fmt = st_mesa_format_to_pipe_format(firstImage->base.TexFormat); - GLuint bindings = default_bindings(ctx->st, fmt); + GLuint bindings = default_bindings(st, fmt); - stObj->pt = st_texture_create(ctx->st, + stObj->pt = st_texture_create(st, gl_target_to_pipe(stObj->base.Target), fmt, stObj->lastLevel, @@ -1886,7 +1896,7 @@ st_finalize_texture(GLcontext *ctx, /* Need to import images in main memory or held in other textures. */ if (stImage && stObj->pt != stImage->pt) { - copy_image_data_to_texture(ctx->st, stObj, level, stImage); + copy_image_data_to_texture(st, stObj, level, stImage); *needFlush = GL_TRUE; } } diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 5dbabfa5c2f..175bf9e6f97 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -75,7 +75,7 @@ void st_print_current(void) { GET_CURRENT_CONTEXT(ctx); - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); #if 0 int i; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a3620359dbf..4137596bd40 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -347,7 +347,8 @@ setup_interleaved_attribs(GLcontext *ctx, struct pipe_vertex_buffer *vbuffer, struct pipe_vertex_element velements[]) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; GLuint attr; const GLubyte *offset0 = NULL; @@ -412,7 +413,8 @@ setup_non_interleaved_attribs(GLcontext *ctx, struct pipe_vertex_buffer vbuffer[], struct pipe_vertex_element velements[]) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; GLuint attr; for (attr = 0; attr < vpv->num_inputs; attr++) { @@ -543,7 +545,8 @@ st_draw_vbo(GLcontext *ctx, GLuint min_index, GLuint max_index) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; const struct st_vertex_program *vp; const struct st_vp_varient *vpv; struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; @@ -566,16 +569,16 @@ st_draw_vbo(GLcontext *ctx, vertDataEdgeFlags = arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj && arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj->Name; - if (vertDataEdgeFlags != ctx->st->vertdata_edgeflags) { - ctx->st->vertdata_edgeflags = vertDataEdgeFlags; - ctx->st->dirty.st |= ST_NEW_EDGEFLAGS_DATA; + if (vertDataEdgeFlags != st->vertdata_edgeflags) { + st->vertdata_edgeflags = vertDataEdgeFlags; + st->dirty.st |= ST_NEW_EDGEFLAGS_DATA; } - st_validate_state(ctx->st); + st_validate_state(st); /* must get these after state validation! */ - vp = ctx->st->vp; - vpv = ctx->st->vp_varient; + vp = st->vp; + vpv = st->vp_varient; #if 0 if (MESA_VERBOSE & VERBOSE_GLSL) { @@ -624,7 +627,7 @@ st_draw_vbo(GLcontext *ctx, #endif pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); - cso_set_vertex_elements(ctx->st->cso_context, num_velements, velements); + cso_set_vertex_elements(st->cso_context, num_velements, velements); if (num_vbuffers == 0 || num_velements == 0) return; diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 0889f1a522d..a1f70e86936 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -55,7 +55,7 @@ static void set_feedback_vertex_format(GLcontext *ctx) { #if 0 - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct vertex_info vinfo; GLuint i; @@ -99,7 +99,7 @@ st_feedback_draw_vbo(GLcontext *ctx, GLuint min_index, GLuint max_index) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; struct draw_context *draw = st->draw; const struct st_vertex_program *vp; @@ -115,13 +115,13 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(draw); - st_validate_state(ctx->st); + st_validate_state(st); if (!index_bounds_valid) vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index); /* must get these after state validation! */ - vp = ctx->st->vp; + vp = st->vp; vs = &st->vp_varient->tgsi; if (!st->vp_varient->draw_shader) { diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index fa6dd2d6363..c149c5cf0b8 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -650,6 +650,7 @@ gl_format st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type) { + struct pipe_screen *screen = st_context(ctx)->pipe->screen; enum pipe_format pFormat; uint bindings; @@ -665,12 +666,12 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, else bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; - pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, + pFormat = st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, bindings); if (pFormat == PIPE_FORMAT_NONE) { /* try choosing format again, this time without render target bindings */ - pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, + pFormat = st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 5b7a9620379..36782146c57 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -106,7 +106,7 @@ static void fallback_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct pipe_resource *pt = st_get_texobj_resource(texObj); const uint baseLevel = texObj->BaseLevel; const uint lastLevel = pt->last_level; @@ -211,7 +211,7 @@ void st_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(texObj); struct pipe_resource *pt = st_get_texobj_resource(texObj); const uint baseLevel = texObj->BaseLevel; -- cgit v1.2.3 From 51523f1144ea5475a5cb08ddf95c80e1b737cafb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 14:12:00 -0600 Subject: st/mesa: remove unneeded #includes and add/update comments --- src/mesa/state_tracker/st_gen_mipmap.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 36782146c57..f52b4e30448 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -27,27 +27,19 @@ #include "main/imports.h" -#include "main/macros.h" #include "main/mipmap.h" #include "main/teximage.h" #include "main/texformat.h" -#include "shader/prog_instruction.h" - #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "util/u_format.h" #include "util/u_gen_mipmap.h" -#include "util/u_math.h" - -#include "cso_cache/cso_cache.h" -#include "cso_cache/cso_context.h" #include "st_debug.h" #include "st_context.h" #include "st_gen_mipmap.h" -#include "st_texture.h" #include "st_cb_texture.h" #include "st_inlines.h" @@ -102,6 +94,9 @@ st_render_mipmap(struct st_context *st, } +/** + * Software fallback for generate mipmap levels. + */ static void fallback_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) @@ -174,7 +169,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, * Compute the expected number of mipmap levels in the texture given * the width/height/depth of the base image and the GL_TEXTURE_BASE_LEVEL/ * GL_TEXTURE_MAX_LEVEL settings. This will tell us how many mipmap - * level should be generated. + * levels should be generated. */ static GLuint compute_num_levels(GLcontext *ctx, @@ -207,6 +202,9 @@ compute_num_levels(GLcontext *ctx, } +/** + * Called via ctx->Driver.GenerateMipmap(). + */ void st_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) -- cgit v1.2.3 From 394ff065f33bdf4f9b5bac11e85d18e3ce4eb42f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 16:04:55 -0600 Subject: st/mesa: minor improvements in fallback_generate_mipmap() --- src/mesa/state_tracker/st_gen_mipmap.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index f52b4e30448..453be425bcb 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -120,6 +120,12 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { const uint srcLevel = dstLevel - 1; + const uint srcWidth = u_minify(pt->width0, srcLevel); + const uint srcHeight = u_minify(pt->height0, srcLevel); + const uint srcDepth = u_minify(pt->depth0, srcLevel); + const uint dstWidth = u_minify(pt->width0, dstLevel); + const uint dstHeight = u_minify(pt->height0, dstLevel); + const uint dstDepth = u_minify(pt->depth0, dstLevel); struct pipe_transfer *srcTrans, *dstTrans; const ubyte *srcData; ubyte *dstData; @@ -128,14 +134,13 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, srcTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face, srcLevel, zslice, PIPE_TRANSFER_READ, 0, 0, - u_minify(pt->width0, srcLevel), - u_minify(pt->height0, srcLevel)); + srcWidth, srcHeight); + dstTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face, dstLevel, zslice, PIPE_TRANSFER_WRITE, 0, 0, - u_minify(pt->width0, dstLevel), - u_minify(pt->height0, dstLevel)); + dstWidth, dstHeight); srcData = (ubyte *) pipe_transfer_map(pipe, srcTrans); dstData = (ubyte *) pipe_transfer_map(pipe, dstTrans); @@ -145,14 +150,10 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, _mesa_generate_mipmap_level(target, datatype, comps, 0 /*border*/, - u_minify(pt->width0, srcLevel), - u_minify(pt->height0, srcLevel), - u_minify(pt->depth0, srcLevel), + srcWidth, srcHeight, srcDepth, srcData, srcStride, /* stride in texels */ - u_minify(pt->width0, dstLevel), - u_minify(pt->height0, dstLevel), - u_minify(pt->depth0, dstLevel), + dstWidth, dstHeight, dstDepth, dstData, dstStride); /* stride in texels */ -- cgit v1.2.3 From b806f2a2397bb0b76f804bb0af4e0eb299b15907 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 18:09:11 -0600 Subject: gallium/util: document that pack/unpack strides are in bytes --- src/gallium/auxiliary/util/u_format.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 5e3dc694be6..605b13bd114 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -192,6 +192,7 @@ struct util_format_description /** * Unpack pixel blocks to R8G8B8A8_UNORM. + * Note: strides are in bytes. * * Only defined for non-depth-stencil formats. */ @@ -202,6 +203,7 @@ struct util_format_description /** * Pack pixel blocks from R8G8B8A8_UNORM. + * Note: strides are in bytes. * * Only defined for non-depth-stencil formats. */ @@ -212,6 +214,7 @@ struct util_format_description /** * Unpack pixel blocks to R32G32B32A32_FLOAT. + * Note: strides are in bytes. * * Only defined for non-depth-stencil formats. */ @@ -222,6 +225,7 @@ struct util_format_description /** * Pack pixel blocks from R32G32B32A32_FLOAT. + * Note: strides are in bytes. * * Only defined for non-depth-stencil formats. */ @@ -242,6 +246,7 @@ struct util_format_description /** * Unpack pixels to Z32_UNORM. + * Note: strides are in bytes. * * Only defined for depth formats. */ @@ -252,6 +257,7 @@ struct util_format_description /** * Pack pixels from Z32_FLOAT. + * Note: strides are in bytes. * * Only defined for depth formats. */ @@ -262,6 +268,7 @@ struct util_format_description /** * Unpack pixels to Z32_FLOAT. + * Note: strides are in bytes. * * Only defined for depth formats. */ @@ -272,6 +279,7 @@ struct util_format_description /** * Pack pixels from Z32_FLOAT. + * Note: strides are in bytes. * * Only defined for depth formats. */ @@ -282,6 +290,7 @@ struct util_format_description /** * Unpack pixels to S8_USCALED. + * Note: strides are in bytes. * * Only defined for stencil formats. */ @@ -292,6 +301,7 @@ struct util_format_description /** * Pack pixels from S8_USCALED. + * Note: strides are in bytes. * * Only defined for stencil formats. */ -- cgit v1.2.3 From 1a4383cd4283fc48f8b70a2692ef5a545b6ab58c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 18:09:43 -0600 Subject: softpipe: compressed formats can't be render targets --- src/gallium/drivers/softpipe/sp_screen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 52ccb32530c..8406aa1ac3e 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -159,7 +159,10 @@ softpipe_is_format_supported( struct pipe_screen *screen, case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: case PIPE_FORMAT_DXT5_RGBA: - return util_format_s3tc_enabled; + if (tex_usage & PIPE_BIND_RENDER_TARGET) + return FALSE; + else + return util_format_s3tc_enabled; case PIPE_FORMAT_Z32_FLOAT: case PIPE_FORMAT_NONE: -- cgit v1.2.3 From 63c9b4f3d2165d4ca5d153a7a20c56c6913283da Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 18:11:22 -0600 Subject: xlib/sw: remove stray semicolon --- src/gallium/winsys/sw/xlib/xlib_sw_winsys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c index 679af611bfc..7df74164d05 100644 --- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c @@ -48,7 +48,7 @@ #include #include -DEBUG_GET_ONCE_BOOL_OPTION(xlib_no_shm, "XLIB_NO_SHM", FALSE); +DEBUG_GET_ONCE_BOOL_OPTION(xlib_no_shm, "XLIB_NO_SHM", FALSE) /** * Display target for Xlib winsys. -- cgit v1.2.3 From 4ff354f281cfe663ef66e26af22e47400c15336f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 18:12:45 -0600 Subject: st/mesa: checkpoint WIP: mipmap generation for compressed textures Something is wrong with the images strides when compressing/decompressing images... --- src/mesa/state_tracker/st_gen_mipmap.c | 112 ++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 453be425bcb..d6b024d8b8c 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -94,6 +94,52 @@ st_render_mipmap(struct st_context *st, } +/** + * Helper function to decompress an image. The result is a 32-bpp RGBA + * image with stride==width. + */ +static void +decompress_image(enum pipe_format format, + const uint8_t *src, uint8_t *dst, + unsigned width, unsigned height) +{ + const struct util_format_description *desc = util_format_description(format); + const uint bw = util_format_get_blockwidth(format); + const uint src_stride = align(width, bw) / util_format_get_blocksize(format); + const uint dst_stride = 4 * width; + + /* + printf("decompress %s %d x %d %d -> %d\n", + util_format_name(format), width, height, src_stride, dst_stride); + */ + + desc->unpack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height); +} + + +/** + * Helper function to compress an image. The source is a 32-bpp RGBA image + * with stride==width. + */ +static void +compress_image(enum pipe_format format, + const uint8_t *src, uint8_t *dst, + unsigned width, unsigned height) +{ + const struct util_format_description *desc = util_format_description(format); + const uint bw = util_format_get_blockwidth(format); + const uint src_stride = 4 * width; + const uint dst_stride = align(width, bw) / util_format_get_blocksize(format); + + /* + printf("compress %s %d x %d %d -> %d\n", + util_format_name(format), width, height, src_stride, dst_stride); + */ + + desc->pack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height); +} + + /** * Software fallback for generate mipmap levels. */ @@ -109,14 +155,25 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, uint dstLevel; GLenum datatype; GLuint comps; + GLboolean compressed; if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); assert(target != GL_TEXTURE_3D); /* not done yet */ - _mesa_format_to_type_and_comps(texObj->Image[face][baseLevel]->TexFormat, - &datatype, &comps); + compressed = + _mesa_is_format_compressed(texObj->Image[face][baseLevel]->TexFormat); + + if (compressed) { + datatype = GL_UNSIGNED_BYTE; + comps = 4; + } + else { + _mesa_format_to_type_and_comps(texObj->Image[face][baseLevel]->TexFormat, + &datatype, &comps); + assert(comps > 0 && "bad texture format in fallback_generate_mipmap()"); + } for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { const uint srcLevel = dstLevel - 1; @@ -148,14 +205,49 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->resource->format); dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->resource->format); - _mesa_generate_mipmap_level(target, datatype, comps, - 0 /*border*/, - srcWidth, srcHeight, srcDepth, - srcData, - srcStride, /* stride in texels */ - dstWidth, dstHeight, dstDepth, - dstData, - dstStride); /* stride in texels */ + if (compressed) { + const enum pipe_format format = pt->format; + const uint bw = util_format_get_blockwidth(format); + const uint bh = util_format_get_blockheight(format); + const uint srcWidth2 = align(srcWidth, bw); + const uint srcHeight2 = align(srcHeight, bh); + const uint dstWidth2 = align(dstWidth, bw); + const uint dstHeight2 = align(dstHeight, bh); + uint8_t *srcTemp, *dstTemp; + + assert(comps == 4); + + srcTemp = malloc(srcWidth2 * srcHeight2 * comps + 000); + dstTemp = malloc(dstWidth2 * dstHeight2 * comps + 000); + + /* decompress the src image: srcData -> srcTemp */ + decompress_image(format, srcData, srcTemp, srcWidth, srcHeight); + + _mesa_generate_mipmap_level(target, datatype, comps, + 0 /*border*/, + srcWidth2, srcHeight2, srcDepth, + srcTemp, + srcWidth2, /* stride in texels */ + dstWidth2, dstHeight2, dstDepth, + dstTemp, + dstWidth2); /* stride in texels */ + + /* compress the new image: dstTemp -> dstData */ + compress_image(format, dstTemp, dstData, dstWidth2, dstHeight2); + + free(srcTemp); + free(dstTemp); + } + else { + _mesa_generate_mipmap_level(target, datatype, comps, + 0 /*border*/, + srcWidth, srcHeight, srcDepth, + srcData, + srcStride, /* stride in texels */ + dstWidth, dstHeight, dstDepth, + dstData, + dstStride); /* stride in texels */ + } pipe_transfer_unmap(pipe, srcTrans); pipe_transfer_unmap(pipe, dstTrans); -- cgit v1.2.3 From c3c920ee2c0ae46e88554c9351f22455f8e8a623 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 23 Apr 2010 22:06:19 -0700 Subject: gallium: In option helpers, move assignment outside of if clause. This silences Coverity assign_where_compare_meant warnings. --- src/gallium/auxiliary/util/u_debug.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index ec3371a9b25..e8ff2773e69 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -309,8 +309,10 @@ debug_get_option_ ## sufix (void) \ { \ static boolean first = TRUE; \ static boolean value; \ - if (first && !(first = FALSE)) \ + if (first) { \ + first = FALSE; \ value = debug_get_bool_option(name, dfault); \ + } \ return value; \ } @@ -320,8 +322,10 @@ debug_get_option_ ## sufix (void) \ { \ static boolean first = TRUE; \ static long value; \ - if (first && !(first = FALSE)) \ + if (first) { \ + first = FALSE; \ value = debug_get_num_option(name, dfault); \ + } \ return value; \ } @@ -331,8 +335,10 @@ debug_get_option_ ## sufix (void) \ { \ static boolean first = TRUE; \ static unsigned long value; \ - if (first && !(first = FALSE)) \ + if (first) { \ + first = FALSE; \ value = debug_get_flags_option(name, flags, dfault); \ + } \ return value; \ } -- cgit v1.2.3 From 3ee4ec99eae51454bd5f3f7a8af51cf65a71908d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 00:02:48 -0700 Subject: llvmpipe: Remove unused variable. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 2c4303a8957..a59b5900292 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -546,7 +546,6 @@ generate_blend(const struct pipe_blend_state *blend, struct lp_build_flow_context *flow; struct lp_build_mask_context mask_ctx; LLVMTypeRef vec_type; - LLVMTypeRef int_vec_type; LLVMValueRef const_ptr; LLVMValueRef con[4]; LLVMValueRef dst[4]; @@ -561,7 +560,6 @@ generate_blend(const struct pipe_blend_state *blend, lp_build_mask_begin(&mask_ctx, flow, type, mask); vec_type = lp_build_vec_type(type); - int_vec_type = lp_build_int_vec_type(type); const_ptr = lp_jit_context_blend_color(builder, context_ptr); const_ptr = LLVMBuildBitCast(builder, const_ptr, -- cgit v1.2.3 From dda8046a6460cbdcfd0ed8a78a443077296a29d2 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 00:19:22 -0700 Subject: gallium/docs: Update Gallium version number to 0.4. --- src/gallium/docs/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/source/conf.py b/src/gallium/docs/source/conf.py index 59c19ed98dd..ccc84405c41 100644 --- a/src/gallium/docs/source/conf.py +++ b/src/gallium/docs/source/conf.py @@ -45,9 +45,9 @@ copyright = u'2009, VMWare, X.org, Nouveau' # built documents. # # The short X.Y version. -version = '0.3' +version = '0.4' # The full version, including alpha/beta/rc tags. -release = '0.3' +release = '0.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- cgit v1.2.3 From e3eed8bf218c04127484e0664c67c100703fa1d8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 01:15:00 -0700 Subject: nouveau: Add to SCons build. --- SConstruct | 2 +- src/gallium/drivers/nouveau/SConscript | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/gallium/drivers/nouveau/SConscript (limited to 'src') diff --git a/SConstruct b/SConstruct index fdcd72b30d1..fdd48556a06 100644 --- a/SConstruct +++ b/SConstruct @@ -50,7 +50,7 @@ common.AddOptions(opts) opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers, ['mesa', 'python', 'xorg'])) opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, - ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe'])) + ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau'])) opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib'])) diff --git a/src/gallium/drivers/nouveau/SConscript b/src/gallium/drivers/nouveau/SConscript new file mode 100644 index 00000000000..fe7af4d2ae8 --- /dev/null +++ b/src/gallium/drivers/nouveau/SConscript @@ -0,0 +1,11 @@ +Import('*') + +env = env.Clone() + +nouveau = env.ConvenienceLibrary( + target = 'nouveau', + source = [ + 'nouveau_screen.c', + ]) + +Export('nouveau') -- cgit v1.2.3 From 81fe19843ac2afdc4fa1e1c87bc979b295af240e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 22 Apr 2010 14:59:29 +1000 Subject: llvmpipe: add initial autoconf support. allows the swrastg_dri.so to be built with llvmpipe, also links llvm to all dri drivers use --enable-gallium-llvm to use it. Signed-off-by: Dave Airlie --- configs/autoconf.in | 12 ++++++++++ configure.ac | 42 +++++++++++++++++++++++++++++++++++ src/gallium/Makefile.template | 2 +- src/gallium/drivers/llvmpipe/Makefile | 5 +++-- src/gallium/targets/Makefile.dri | 15 ++++++++++++- 5 files changed, 72 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/configs/autoconf.in b/configs/autoconf.in index b6cc9b3b73e..3ef385a8a66 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -26,6 +26,10 @@ INTEL_LIBS = @INTEL_LIBS@ INTEL_CFLAGS = @INTEL_CFLAGS@ X11_LIBS = @X11_LIBS@ X11_CFLAGS = @X11_CFLAGS@ +LLVM_CFLAGS = @LLVM_CFLAGS@ +LLVM_LDFLAGS = @LLVM_LDFLAGS@ +LLVM_LIBS = @LLVM_LIBS@ + # Assembler MESA_ASM_SOURCES = @MESA_ASM_SOURCES@ @@ -157,3 +161,11 @@ OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@ EGL_DRI2_CFLAGS = @EGL_DRI2_CFLAGS@ EGL_DRI2_LIBS = @EGL_DRI2_LIBS@ + +MESA_LLVM = @MESA_LLVM@ + +LLVM_VERSION = @LLVM_VERSION@ +ifneq ($(LLVM_VERSION),) + HAVE_LLVM := 0x0$(subst .,0,$(LLVM_VERSION:svn=)) + DEFINES += -DHAVE_LLVM=$(HAVE_LLVM) +endif diff --git a/configure.ac b/configure.ac index 0e777074339..bcf4104515e 100644 --- a/configure.ac +++ b/configure.ac @@ -488,6 +488,7 @@ AC_SUBST([GALLIUM_TARGET_DIRS]) AC_SUBST([GALLIUM_WINSYS_DIRS]) AC_SUBST([GALLIUM_DRIVERS_DIRS]) AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS]) +AC_SUBST([MESA_LLVM]) dnl dnl User supplied program configuration @@ -1181,8 +1182,26 @@ AC_ARG_ENABLE([gallium], [enable_gallium=yes]) if test "x$enable_gallium" = xyes; then SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets" + AC_CHECK_HEADER([udis86.h], [HAS_UDIS86="yes"], + [HAS_UDIS86="no"]) + AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no]) + if test "x$LLVM_CONFIG" != xno; then + LLVM_VERSION=`$LLVM_CONFIG --version` + LLVM_CFLAGS=`$LLVM_CONFIG --cflags` + LLVM_LIBS="`$LLVM_CONFIG --libs jit interpreter nativecodegen bitwriter` -lstdc++" + + if test "x$HAS_UDIS86" != xno; then + LLVM_LIBS="$LLVM_LIBS -ludis86" + fi + LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` + fi fi +AC_SUBST([LLVM_CFLAGS]) +AC_SUBST([LLVM_LIBS]) +AC_SUBST([LLVM_LDFLAGS]) +AC_SUBST([LLVM_VERSION]) + dnl dnl Gallium state trackers configuration dnl @@ -1316,6 +1335,29 @@ AC_ARG_WITH([max-height], [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])] ) +dnl +dnl Gallium LLVM +dnl +AC_ARG_ENABLE([gallium-llvm], + [AS_HELP_STRING([--enable-gallium-llvm], + [build gallium LLVM support @<:@default=disabled@:>@])], + [enable_gallium_llvm="$enableval"], + [enable_gallium_llvm=auto]) +if test "x$enable_gallium_llvm" = xyes; then + if test "x$LLVM_CONFIG" != xno; then + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe" + DEFINES="$DEFINES -DMESA_LLVM -D__STDC_CONSTANT_MACROS" + if test "x$HAS_UDIS86" != xno; then + DEFINES="$DEFINES -DHAVE_UDIS86" + fi + MESA_LLVM=1 + else + MESA_LLVM=0 + fi +else + MESA_LLVM=0 +fi + dnl dnl Gallium helper functions dnl diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index b5a9938c740..1ba0724949a 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -37,7 +37,7 @@ depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURC $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null $(PROGS): % : %.o - $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS) -Wl,--end-group + $(LD) $(LDFLAGS) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS) -Wl,--end-group # Emacs tags tags: diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 4a3fc036c49..7bf5b097628 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -58,8 +58,9 @@ include ../../Makefile.template lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxiliary/util/u_format_pack.py ../../auxiliary/util/u_format.csv python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@ - -LIBS += $(GL_LIB_DEPS) -L../../auxiliary/ -lgallium libllvmpipe.a +LDFLAGS += $(LLVM_LDFLAGS) +LIBS += $(GL_LIB_DEPS) -L../../auxiliary/ -lgallium libllvmpipe.a $(LLVM_LIBS) +LD=g++ $(PROGS): lp_test_main.o libllvmpipe.a diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri index 8efbf4e828c..3cbaf615e2f 100644 --- a/src/gallium/targets/Makefile.dri +++ b/src/gallium/targets/Makefile.dri @@ -1,5 +1,14 @@ # -*-makefile-*- +ifeq ($(MESA_LLVM),1) +DRIVER_DEFINES += -DGALLIUM_LLVMPIPE +PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a +LDFLAGS += $(LLVM_LDFLAGS) +LD = g++ +DRIVER_EXTRAS = $(LLVM_LIBS) +USE_CXX=1 +endif + MESA_MODULES = \ $(TOP)/src/mesa/libmesagallium.a \ $(GALLIUM_AUXILIARIES) @@ -69,7 +78,11 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) + if [ "x${USE_CXX}" == "x" ]; then \ + $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \ + else \ + $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \ + fi @rm -f $@.test mv -f $@.tmp $@ -- cgit v1.2.3 From 35a920e83b2e85f1180d9c0a752ef917f2e08416 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 09:58:41 +0100 Subject: gallivm: LLVMConstBitCast -> LLVMBuildBitCast As the argument in general might not be a constant. --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index d6967633172..5f9d4c62d1c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -1503,7 +1503,7 @@ lp_build_log2_approx(struct lp_build_context *bld, } if(p_exp) { - exp = LLVMConstBitCast(exp, vec_type); + exp = LLVMBuildBitCast(bld->builder, exp, vec_type, ""); *p_exp = exp; } @@ -1575,8 +1575,10 @@ lp_build_float_log2_approx(struct lp_build_context *bld, res = LLVMBuildAdd(bld->builder, logmant, logexp, ""); } - if(p_exp) + if(p_exp) { + exp = LLVMBuildBitCast(bld->builder, exp, float_type, ""); *p_exp = exp; + } if(p_floor_log2) *p_floor_log2 = logexp; -- cgit v1.2.3 From 94b04d3d1ccd1b717dbc9d797341f1170121645a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 10:15:09 +0100 Subject: sw/xlib: Fix bad logic in shm allocation. Fixes fdo 27823. --- src/gallium/winsys/sw/xlib/xlib_sw_winsys.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c index 7df74164d05..56d2df825df 100644 --- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c @@ -124,6 +124,9 @@ static char *alloc_shm(struct xm_displaytarget *buf, unsigned size) { XShmSegmentInfo *const shminfo = & buf->shminfo; + shminfo->shmid = -1; + shminfo->shmaddr = (char *) -1; + shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777); if (shminfo->shmid < 0) { return NULL; @@ -385,12 +388,9 @@ xm_displaytarget_create(struct sw_winsys *winsys, xm_dt->stride = align(util_format_get_stride(format, width), alignment); size = xm_dt->stride * nblocksy; - if (!debug_get_option_xlib_no_shm()) - { + if (!debug_get_option_xlib_no_shm()) { xm_dt->data = alloc_shm(xm_dt, size); - if(!xm_dt->data) { - xm_dt->shminfo.shmid = -1; - xm_dt->shminfo.shmaddr = (char *) -1; + if (xm_dt->data) { xm_dt->shm = TRUE; } } -- cgit v1.2.3 From a523b622036117e8bc1be0a1496d4368562e9702 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 11:23:52 +0100 Subject: st/dri: DRI2 give proper binding to depth buffer --- src/gallium/state_trackers/dri/drm/dri2.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 0d15b5c9b85..5ab7067ae2f 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -120,30 +120,31 @@ static const __DRItexBufferExtension dri2TexBufferExtension = { }; /** - * Get the format of an attachment. + * Get the format and binding of an attachment. */ -static INLINE enum pipe_format +static INLINE void dri2_drawable_get_format(struct dri_drawable *drawable, - enum st_attachment_type statt) + enum st_attachment_type statt, + enum pipe_format *format, + unsigned *bind) { - enum pipe_format format; - switch (statt) { case ST_ATTACHMENT_FRONT_LEFT: case ST_ATTACHMENT_BACK_LEFT: case ST_ATTACHMENT_FRONT_RIGHT: case ST_ATTACHMENT_BACK_RIGHT: - format = drawable->stvis.color_format; + *format = drawable->stvis.color_format; + *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; break; case ST_ATTACHMENT_DEPTH_STENCIL: - format = drawable->stvis.depth_stencil_format; + *format = drawable->stvis.depth_stencil_format; + *bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */ break; default: - format = PIPE_FORMAT_NONE; + *format = PIPE_FORMAT_NONE; + *bind = 0; break; } - - return format; } @@ -174,9 +175,10 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable, for (i = 0; i < *count; i++) { enum pipe_format format; + unsigned bind; int att, bpp; - format = dri2_drawable_get_format(drawable, statts[i]); + dri2_drawable_get_format(drawable, statts[i], &format, &bind); if (format == PIPE_FORMAT_NONE) continue; @@ -263,7 +265,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable, struct pipe_resource templ; struct winsys_handle whandle; boolean have_depth = FALSE; - unsigned i; + unsigned i, bind; if (drawable->old_num == count && drawable->old_w == dri_drawable->w && @@ -275,7 +277,6 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable, pipe_resource_reference(&drawable->textures[i], NULL); memset(&templ, 0, sizeof(templ)); - templ.bind = PIPE_BIND_RENDER_TARGET; templ.target = PIPE_TEXTURE_2D; templ.last_level = 0; templ.width0 = dri_drawable->w; @@ -319,11 +320,12 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable, break; } - format = dri2_drawable_get_format(drawable, statt); + dri2_drawable_get_format(drawable, statt, &format, &bind); if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE) continue; templ.format = format; + templ.bind = bind; whandle.handle = buf->name; whandle.stride = buf->pitch; -- cgit v1.2.3 From 53499c64b212c68527f84f5e672cdfc95935f643 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 10:33:44 +0100 Subject: cso_cache: Ensure irrelevant state of the blend state is zeroed. Otherwise drivers that bake the full blend state in a key end up having uninitialized memory in their key. Courtesy of valgrind. --- src/gallium/auxiliary/cso_cache/cso_context.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 6fd4bd36428..6d0b4207986 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -349,6 +349,7 @@ enum pipe_error cso_set_blend(struct cso_context *ctx, if (!cso) return PIPE_ERROR_OUT_OF_MEMORY; + memset(&cso->state, 0, sizeof cso->state); memcpy(&cso->state, templ, key_size); cso->data = ctx->pipe->create_blend_state(ctx->pipe, &cso->state); cso->delete_state = (cso_state_callback)ctx->pipe->delete_blend_state; -- cgit v1.2.3 From e6c3f594e904256b031092ff4f1a321a005f53de Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 11:34:22 +0100 Subject: svga: Translate recently added vertex formats. --- src/gallium/drivers/svga/svga_state_need_swtnl.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index dfaab53aef4..c8ea7494d85 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -52,14 +52,10 @@ svga_translate_vertex_format(enum pipe_format format) case PIPE_FORMAT_R16G16B16A16_SNORM: return SVGA3D_DECLTYPE_SHORT4N; case PIPE_FORMAT_R16G16_UNORM: return SVGA3D_DECLTYPE_USHORT2N; case PIPE_FORMAT_R16G16B16A16_UNORM: return SVGA3D_DECLTYPE_USHORT4N; - - /* These formats don't exist yet: - * - case PIPE_FORMAT_R10G10B10_USCALED: return SVGA3D_DECLTYPE_UDEC3; - case PIPE_FORMAT_R10G10B10_SNORM: return SVGA3D_DECLTYPE_DEC3N; + case PIPE_FORMAT_R10G10B10X2_USCALED: return SVGA3D_DECLTYPE_UDEC3; + case PIPE_FORMAT_R10G10B10X2_SNORM: return SVGA3D_DECLTYPE_DEC3N; case PIPE_FORMAT_R16G16_FLOAT: return SVGA3D_DECLTYPE_FLOAT16_2; case PIPE_FORMAT_R16G16B16A16_FLOAT: return SVGA3D_DECLTYPE_FLOAT16_4; - */ default: /* There are many formats without hardware support. This case -- cgit v1.2.3 From e94a092437d3c2ebe2a4c514cc1e3fce38c1d7e9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 11:38:41 +0100 Subject: svga: D3DCOLOR actually stands for B8G8R8A8. --- src/gallium/drivers/svga/svga_state_need_swtnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index c8ea7494d85..d34d68f5350 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -43,7 +43,7 @@ svga_translate_vertex_format(enum pipe_format format) case PIPE_FORMAT_R32G32_FLOAT: return SVGA3D_DECLTYPE_FLOAT2; case PIPE_FORMAT_R32G32B32_FLOAT: return SVGA3D_DECLTYPE_FLOAT3; case PIPE_FORMAT_R32G32B32A32_FLOAT: return SVGA3D_DECLTYPE_FLOAT4; - case PIPE_FORMAT_A8R8G8B8_UNORM: return SVGA3D_DECLTYPE_D3DCOLOR; + case PIPE_FORMAT_B8G8R8A8_UNORM: return SVGA3D_DECLTYPE_D3DCOLOR; case PIPE_FORMAT_R8G8B8A8_USCALED: return SVGA3D_DECLTYPE_UBYTE4; case PIPE_FORMAT_R16G16_SSCALED: return SVGA3D_DECLTYPE_SHORT2; case PIPE_FORMAT_R16G16B16A16_SSCALED: return SVGA3D_DECLTYPE_SHORT4; -- cgit v1.2.3 From 30a1c36dc85f0928a9adb69630c418f9aabbdd98 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 12:00:06 +0100 Subject: llvmpipe: Pass flatshade_first to setup. Fixes piglit provoking-vertex. --- src/gallium/drivers/llvmpipe/lp_state_rasterizer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c index 47f65fe72d1..3fba5e4e75d 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c +++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c @@ -71,6 +71,8 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle) llvmpipe->rasterizer->front_winding == PIPE_WINDING_CCW, llvmpipe->rasterizer->scissor, llvmpipe->rasterizer->gl_rasterization_rules); + lp_setup_set_flatshade_first( llvmpipe->setup, + llvmpipe->rasterizer->flatshade_first); } llvmpipe->dirty |= LP_NEW_RASTERIZER; -- cgit v1.2.3 From e7a8cfc8776c70f8c4cc3e158f663f6c630169ed Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 13:19:10 +0100 Subject: gallivm: Centralize the cpu caps detection. --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 10 ++++++++++ src/gallium/drivers/llvmpipe/lp_jit.c | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index de07c222a39..5067d0a164f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -27,6 +27,7 @@ #include "pipe/p_compiler.h" +#include "util/u_cpu_detect.h" #include "util/u_debug.h" #include "lp_bld_init.h" @@ -62,6 +63,15 @@ lp_build_init(void) if (!lp_build_target) lp_build_target = LLVMGetExecutionEngineTargetData(lp_build_engine); + + util_cpu_detect(); + +#if 0 + /* For simulating less capable machines */ + util_cpu_caps.has_sse3 = 0; + util_cpu_caps.has_ssse3 = 0; + util_cpu_caps.has_sse4_1 = 0; +#endif } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 8690941a507..466a2f54fbe 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -171,15 +171,6 @@ lp_jit_screen_cleanup(struct llvmpipe_screen *screen) void lp_jit_screen_init(struct llvmpipe_screen *screen) { - util_cpu_detect(); - -#if 0 - /* For simulating less capable machines */ - util_cpu_caps.has_sse3 = 0; - util_cpu_caps.has_ssse3 = 0; - util_cpu_caps.has_sse4_1 = 0; -#endif - lp_build_init(); screen->module = lp_build_module; -- cgit v1.2.3 From 39be50dcdebe6bcbb48cb6aa8ac151eee811acb1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 13:20:39 +0100 Subject: llvmpipe: Move the determination of the number of threads to the screen. --- src/gallium/drivers/llvmpipe/lp_limits.h | 3 +++ src/gallium/drivers/llvmpipe/lp_rast.c | 18 +++--------------- src/gallium/drivers/llvmpipe/lp_rast.h | 2 +- src/gallium/drivers/llvmpipe/lp_rast_priv.h | 8 +++----- src/gallium/drivers/llvmpipe/lp_screen.c | 21 +++++++++++++++++++-- src/gallium/drivers/llvmpipe/lp_screen.h | 2 ++ src/gallium/drivers/llvmpipe/lp_setup.c | 6 ++++-- src/gallium/drivers/llvmpipe/lp_setup_context.h | 1 + 8 files changed, 36 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h b/src/gallium/drivers/llvmpipe/lp_limits.h index 9ab1b4b36e3..c7c5a1eca87 100644 --- a/src/gallium/drivers/llvmpipe/lp_limits.h +++ b/src/gallium/drivers/llvmpipe/lp_limits.h @@ -58,4 +58,7 @@ #define LP_MAX_WIDTH (1 << (LP_MAX_TEXTURE_LEVELS - 1)) +#define LP_MAX_THREADS 8 + + #endif /* LP_LIMITS_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 0a41b6406bd..c3e186b2a06 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -869,20 +869,6 @@ create_rast_threads(struct lp_rasterizer *rast) { unsigned i; -#ifdef PIPE_OS_WINDOWS - /* Multithreading not supported on windows until conditions and barriers are - * properly implemented. */ - rast->num_threads = 0; -#else -#ifdef PIPE_OS_EMBEDDED - rast->num_threads = 0; -#else - rast->num_threads = util_cpu_caps.nr_cpus; -#endif - rast->num_threads = debug_get_num_option("LP_NUM_THREADS", rast->num_threads); - rast->num_threads = MIN2(rast->num_threads, MAX_THREADS); -#endif - /* NOTE: if num_threads is zero, we won't use any threads */ for (i = 0; i < rast->num_threads; i++) { pipe_semaphore_init(&rast->tasks[i].work_ready, 0); @@ -900,7 +886,7 @@ create_rast_threads(struct lp_rasterizer *rast) * processing them. */ struct lp_rasterizer * -lp_rast_create( void ) +lp_rast_create( unsigned num_threads ) { struct lp_rasterizer *rast; unsigned i; @@ -917,6 +903,8 @@ lp_rast_create( void ) task->thread_index = i; } + rast->num_threads = num_threads; + create_rast_threads(rast); /* for synchronizing rasterization threads */ diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index a0ecb2fc47f..e2f6f926779 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -134,7 +134,7 @@ struct lp_rast_triangle { struct lp_rasterizer * -lp_rast_create( void ); +lp_rast_create( unsigned num_threads ); void lp_rast_destroy( struct lp_rasterizer * ); diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 8bf2b92a6ab..18457ff4ce2 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -35,9 +35,7 @@ #include "lp_scene.h" #include "lp_texture.h" #include "lp_tile_soa.h" - - -#define MAX_THREADS 8 /* XXX probably temporary here */ +#include "lp_limits.h" struct lp_rasterizer; @@ -113,10 +111,10 @@ struct lp_rasterizer struct lp_scene *curr_scene; /** A task object for each rasterization thread */ - struct lp_rasterizer_task tasks[MAX_THREADS]; + struct lp_rasterizer_task tasks[LP_MAX_THREADS]; unsigned num_threads; - pipe_thread threads[MAX_THREADS]; + pipe_thread threads[LP_MAX_THREADS]; /** For synchronizing the rasterization threads */ pipe_barrier barrier; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 7d2cd0c7679..88c0604c541 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -27,6 +27,8 @@ #include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_cpu_detect.h" #include "util/u_format.h" #include "util/u_format_s3tc.h" #include "pipe/p_defines.h" @@ -39,6 +41,7 @@ #include "lp_context.h" #include "lp_debug.h" #include "lp_public.h" +#include "lp_limits.h" #include "state_tracker/sw_winsys.h" @@ -284,12 +287,26 @@ llvmpipe_create_screen(struct sw_winsys *winsys) screen->base.context_create = llvmpipe_create_context; screen->base.flush_frontbuffer = llvmpipe_flush_frontbuffer; - util_format_s3tc_init(); - llvmpipe_init_screen_resource_funcs(&screen->base); llvmpipe_init_screen_fence_funcs(&screen->base); lp_jit_screen_init(screen); +#ifdef PIPE_OS_WINDOWS + /* Multithreading not supported on windows until conditions and barriers are + * properly implemented. */ + screen->num_threads = 0; +#else +#ifdef PIPE_OS_EMBEDDED + screen->num_threads = 0; +#else + screen->num_threads = util_cpu_caps.nr_cpus; +#endif + screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads); + screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS); +#endif + + util_format_s3tc_init(); + return &screen->base; } diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index af25e043cc9..4f394326103 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -58,6 +58,8 @@ struct llvmpipe_screen LLVMTypeRef context_ptr_type; + unsigned num_threads; + /* Increments whenever textures are modified. Contexts can track * this. */ diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 210c7b8a908..0dad4c259ec 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -765,8 +765,9 @@ struct lp_setup_context * lp_setup_create( struct pipe_context *pipe, struct draw_context *draw ) { - unsigned i; + struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen); struct lp_setup_context *setup = CALLOC_STRUCT(lp_setup_context); + unsigned i; if (!setup) return NULL; @@ -779,7 +780,8 @@ lp_setup_create( struct pipe_context *pipe, /* XXX: move this to the screen and share between contexts: */ - setup->rast = lp_rast_create(); + setup->num_threads = screen->num_threads; + setup->rast = lp_rast_create(screen->num_threads); if (!setup->rast) goto fail; diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h index 4594f7597d5..584764ce8ac 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h @@ -80,6 +80,7 @@ struct lp_setup_context * create/install this itself now. */ struct draw_stage *vbuf; + unsigned num_threads; struct lp_rasterizer *rast; struct lp_scene *scenes[MAX_SCENES]; /**< all the scenes */ struct lp_scene *scene; /**< current scene being built */ -- cgit v1.2.3 From bd6e9e33501ad4351029d0eb0efa6b83f9f05445 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 16:13:04 +0100 Subject: llvmpipe: Don't use fences when not using threads. lp_setup_flush has effect immediately. --- src/gallium/drivers/llvmpipe/lp_setup.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 0dad4c259ec..194f628bef5 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -343,20 +343,25 @@ lp_setup_clear( struct lp_setup_context *setup, struct pipe_fence_handle * lp_setup_fence( struct lp_setup_context *setup ) { - struct lp_scene *scene = lp_setup_get_current_scene(setup); - const unsigned rank = lp_scene_get_num_bins( scene ); /* xxx */ - struct lp_fence *fence = lp_fence_create(rank); + if (setup->num_threads == 0) { + return NULL; + } + else { + struct lp_scene *scene = lp_setup_get_current_scene(setup); + const unsigned rank = lp_scene_get_num_bins( scene ); /* xxx */ + struct lp_fence *fence = lp_fence_create(rank); - LP_DBG(DEBUG_SETUP, "%s rank %u\n", __FUNCTION__, rank); + LP_DBG(DEBUG_SETUP, "%s rank %u\n", __FUNCTION__, rank); - set_scene_state( setup, SETUP_ACTIVE ); + set_scene_state( setup, SETUP_ACTIVE ); - /* insert the fence into all command bins */ - lp_scene_bin_everywhere( scene, - lp_rast_fence, - lp_rast_arg_fence(fence) ); + /* insert the fence into all command bins */ + lp_scene_bin_everywhere( scene, + lp_rast_fence, + lp_rast_arg_fence(fence) ); - return (struct pipe_fence_handle *) fence; + return (struct pipe_fence_handle *) fence; + } } -- cgit v1.2.3 From aa7a47dcbdfff3c6858ff3618170ec17ca72d337 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 16:13:18 +0100 Subject: llvmpipe: Initialize dummy variable. --- src/gallium/drivers/llvmpipe/lp_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 194f628bef5..abc659c3691 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -243,7 +243,7 @@ lp_setup_flush( struct lp_setup_context *setup, if (setup->scene) { struct lp_scene *scene = lp_setup_get_current_scene(setup); - union lp_rast_cmd_arg dummy; + union lp_rast_cmd_arg dummy = {0}; if (flags & (PIPE_FLUSH_SWAPBUFFERS | PIPE_FLUSH_FRAME)) { -- cgit v1.2.3 From ee15d5a0c40b252670ec9e261460bad82402443d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 16:13:41 +0100 Subject: util: Fix unsigned <-> ptr conversions. --- src/gallium/auxiliary/util/u_surfaces.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_surfaces.c b/src/gallium/auxiliary/util/u_surfaces.c index 0248120f557..668da8c5c27 100644 --- a/src/gallium/auxiliary/util/u_surfaces.c +++ b/src/gallium/auxiliary/util/u_surfaces.c @@ -9,13 +9,13 @@ static unsigned hash(void *key) { - return (unsigned)key; + return (unsigned)(uintptr_t)key; } static int compare(void *key1, void *key2) { - return (unsigned)key1 - (unsigned)key2; + return (unsigned)(uintptr_t)key1 - (unsigned)(uintptr_t)key2; } struct pipe_surface * @@ -67,7 +67,7 @@ util_surfaces_do_detach(struct util_surfaces *us, struct pipe_surface *ps) struct pipe_resource *pt = ps->texture; if(pt->target == PIPE_TEXTURE_3D || pt->target == PIPE_TEXTURE_CUBE) { /* or 2D array */ - void* key = (void*)(((ps->zslice + ps->face) << 8) | ps->level); + void* key = (void*)(uintptr_t)(((ps->zslice + ps->face) << 8) | ps->level); util_hash_table_remove(us->u.table, key); } else -- cgit v1.2.3 From 1eeae05441f4cf77773efa7079eec1fe4b70c5d9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 16:13:54 +0100 Subject: util: Add missing static keyword. --- src/gallium/auxiliary/util/u_format_s3tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c index abc1951f8f6..66edb597fc8 100644 --- a/src/gallium/auxiliary/util/u_format_s3tc.c +++ b/src/gallium/auxiliary/util/u_format_s3tc.c @@ -300,7 +300,7 @@ util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, util_format_dxt5_rgba_fetch, 16); } -void +static INLINE void util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height, -- cgit v1.2.3 From cca8abe20ec9d1a560cc3fc97545922254d2a574 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 20:31:30 +0100 Subject: mesa: Eliminate multiple va_list usage. va_list is a mutable iterator. When passed to a function it will likely point to somewhere else. This fixes segmentation fault in glean vertProg1 on Ubuntu 9.10. --- src/mesa/shader/program_parse.tab.c | 7 ++++--- src/mesa/shader/program_parse.y | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index e5ef25ec38a..99c4b2baa5f 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -5557,7 +5557,6 @@ make_error_string(const char *fmt, ...) char *str; va_list args; - va_start(args, fmt); /* Call vsnprintf once to determine how large the final string is. Call it * again to do the actual formatting. from the vsnprintf manual page: @@ -5566,15 +5565,17 @@ make_error_string(const char *fmt, ...) * characters printed (not including the trailing '\0' used to end * output to strings). */ + va_start(args, fmt); length = 1 + vsnprintf(NULL, 0, fmt, args); + va_end(args); str = malloc(length); if (str) { + va_start(args, fmt); vsnprintf(str, length, fmt, args); + va_end(args); } - va_end(args); - return str; } diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 299e2477e48..06c2db7a07e 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -2596,7 +2596,6 @@ make_error_string(const char *fmt, ...) char *str; va_list args; - va_start(args, fmt); /* Call vsnprintf once to determine how large the final string is. Call it * again to do the actual formatting. from the vsnprintf manual page: @@ -2605,15 +2604,17 @@ make_error_string(const char *fmt, ...) * characters printed (not including the trailing '\0' used to end * output to strings). */ + va_start(args, fmt); length = 1 + vsnprintf(NULL, 0, fmt, args); + va_end(args); str = malloc(length); if (str) { + va_start(args, fmt); vsnprintf(str, length, fmt, args); + va_end(args); } - va_end(args); - return str; } -- cgit v1.2.3 From e54a86c6770491bb69168f3aef27e4c2dd1827d8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 24 Apr 2010 21:00:45 +0100 Subject: llvmpipe: Implement shader bias. Fixes glean glsl1 test: texture2D(), with bias. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index c9b613e21c8..415346c15fa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -842,6 +842,7 @@ lp_build_minify(struct lp_build_sample_context *bld, * \param s vector of texcoord s values * \param t vector of texcoord t values * \param r vector of texcoord r values + * \param shader_lod_bias vector float with the shader lod bias, * \param width scalar int texture width * \param height scalar int texture height * \param depth scalar int texture depth @@ -851,6 +852,7 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, LLVMValueRef s, LLVMValueRef t, LLVMValueRef r, + LLVMValueRef shader_lod_bias, LLVMValueRef width, LLVMValueRef height, LLVMValueRef depth) @@ -865,8 +867,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, else { const int dims = texture_dims(bld->static_state->target); struct lp_build_context *float_bld = &bld->float_bld; - LLVMValueRef lod_bias = LLVMConstReal(LLVMFloatType(), - bld->static_state->lod_bias); + LLVMValueRef sampler_lod_bias = LLVMConstReal(LLVMFloatType(), + bld->static_state->lod_bias); LLVMValueRef min_lod = LLVMConstReal(LLVMFloatType(), bld->static_state->min_lod); LLVMValueRef max_lod = LLVMConstReal(LLVMFloatType(), @@ -940,8 +942,14 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, /* compute lod = log2(rho) */ lod = lp_build_log2(float_bld, rho); - /* add lod bias */ - lod = LLVMBuildAdd(bld->builder, lod, lod_bias, "LOD bias"); + /* add sampler lod bias */ + lod = LLVMBuildAdd(bld->builder, lod, sampler_lod_bias, "sampler LOD bias"); + + /* add shader lod bias */ + /* XXX for now we take only the first element since our lod is scalar */ + shader_lod_bias = LLVMBuildExtractElement(bld->builder, shader_lod_bias, + LLVMConstInt(LLVMInt32Type(), 0, 0), ""); + lod = LLVMBuildAdd(bld->builder, lod, shader_lod_bias, "shader LOD bias"); /* clamp lod */ lod = lp_build_clamp(float_bld, lod, min_lod, max_lod); @@ -1527,6 +1535,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, LLVMValueRef s, LLVMValueRef t, LLVMValueRef r, + LLVMValueRef lodbias, LLVMValueRef width, LLVMValueRef height, LLVMValueRef depth, @@ -1564,7 +1573,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, /* Need to compute lod either to choose mipmap levels or to * distinguish between minification/magnification with one mipmap level. */ - lod = lp_build_lod_selector(bld, s, t, r, width, height, depth); + lod = lp_build_lod_selector(bld, s, t, r, lodbias, width, height, depth); } /* @@ -2060,7 +2069,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, row_stride_array, data_array, texel); } else { - lp_build_sample_general(&bld, unit, s, t, r, + lp_build_sample_general(&bld, unit, s, t, r, lodbias, width, height, depth, width_vec, height_vec, depth_vec, row_stride_array, img_stride_array, -- cgit v1.2.3 From c7bb271f0d758e9adafd10cbbdaca8c216e10ba8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 14:19:47 -0700 Subject: llvmpipe: Remove unnecessary header. --- src/gallium/drivers/llvmpipe/lp_rast.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index c3e186b2a06..0aae2542a22 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -28,7 +28,6 @@ #include #include "util/u_memory.h" #include "util/u_math.h" -#include "util/u_cpu_detect.h" #include "util/u_surface.h" #include "lp_scene_queue.h" -- cgit v1.2.3 From b147aaea4dfb278f76f210d55c8e20b15b6fba18 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 14:29:08 -0700 Subject: llvmpipe: Remove unused variable. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index a59b5900292..3eb25d41277 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -403,7 +403,6 @@ generate_fs(struct llvmpipe_context *lp, LLVMValueRef step2_ptr) { const struct tgsi_token *tokens = shader->base.tokens; - LLVMTypeRef elem_type; LLVMTypeRef vec_type; LLVMTypeRef int_vec_type; LLVMValueRef consts_ptr; @@ -422,7 +421,6 @@ generate_fs(struct llvmpipe_context *lp, stencil_refs[0] = lp_jit_context_stencil_ref_front_value(builder, context_ptr); stencil_refs[1] = lp_jit_context_stencil_ref_back_value(builder, context_ptr); - elem_type = lp_build_elem_type(type); vec_type = lp_build_vec_type(type); int_vec_type = lp_build_int_vec_type(type); -- cgit v1.2.3 From ac942f5aa2dc3ec43ab879a6065da048ed6cfce3 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 14:38:48 -0700 Subject: nv50: Add to SCons build. --- SConstruct | 2 +- src/gallium/drivers/nv50/SConscript | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/gallium/drivers/nv50/SConscript (limited to 'src') diff --git a/SConstruct b/SConstruct index fdd48556a06..2badd76256c 100644 --- a/SConstruct +++ b/SConstruct @@ -50,7 +50,7 @@ common.AddOptions(opts) opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers, ['mesa', 'python', 'xorg'])) opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, - ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau'])) + ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50'])) opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib'])) diff --git a/src/gallium/drivers/nv50/SConscript b/src/gallium/drivers/nv50/SConscript new file mode 100644 index 00000000000..8625f926221 --- /dev/null +++ b/src/gallium/drivers/nv50/SConscript @@ -0,0 +1,26 @@ +Import('*') + +env = env.Clone() + +nv50 = env.ConvenienceLibrary( + target = 'nv50', + source = [ + 'nv50_buffer.c', + 'nv50_clear.c', + 'nv50_context.c', + 'nv50_draw.c', + 'nv50_miptree.c', + 'nv50_query.c', + 'nv50_program.c', + 'nv50_resource.c', + 'nv50_screen.c', + 'nv50_state.c', + 'nv50_state_validate.c', + 'nv50_surface.c', + 'nv50_tex.c', + 'nv50_transfer.c', + 'nv50_vbo.c', + 'nv50_push.c', + ]) + +Export('nv50') -- cgit v1.2.3 From bd93670bfdc1690ec9846ebe78156f1c3ef357d3 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 16:22:47 -0700 Subject: nvfx: Add to SCons build. --- SConstruct | 2 +- src/gallium/drivers/nvfx/SConscript | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/gallium/drivers/nvfx/SConscript (limited to 'src') diff --git a/SConstruct b/SConstruct index 2badd76256c..de3f6ea5c33 100644 --- a/SConstruct +++ b/SConstruct @@ -50,7 +50,7 @@ common.AddOptions(opts) opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers, ['mesa', 'python', 'xorg'])) opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, - ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50'])) + ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx'])) opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib'])) diff --git a/src/gallium/drivers/nvfx/SConscript b/src/gallium/drivers/nvfx/SConscript new file mode 100644 index 00000000000..fac32dace40 --- /dev/null +++ b/src/gallium/drivers/nvfx/SConscript @@ -0,0 +1,36 @@ +Import('*') + +env = env.Clone() + +nvfx = env.ConvenienceLibrary( + target = 'nvfx', + source = [ + 'nv04_surface_2d.c', + 'nvfx_buffer.c', + 'nvfx_context.c', + 'nvfx_clear.c', + 'nvfx_draw.c', + 'nvfx_fragprog.c', + 'nvfx_fragtex.c', + 'nv30_fragtex.c', + 'nv40_fragtex.c', + 'nvfx_miptree.c', + 'nvfx_query.c', + 'nvfx_resource.c', + 'nvfx_screen.c', + 'nvfx_state.c', + 'nvfx_state_blend.c', + 'nvfx_state_emit.c', + 'nvfx_state_fb.c', + 'nvfx_state_rasterizer.c', + 'nvfx_state_scissor.c', + 'nvfx_state_stipple.c', + 'nvfx_state_viewport.c', + 'nvfx_state_zsa.c', + 'nvfx_surface.c', + 'nvfx_transfer.c', + 'nvfx_vbo.c', + 'nvfx_vertprog.c', + ]) + +Export('nvfx') -- cgit v1.2.3 From 9bc54ca991e15d3a8200f4d64e778bba19338ef5 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 23:14:27 -0700 Subject: dri: Remove unnecessary header. --- src/mesa/drivers/dri/common/dri_util.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 8b3d8c27ce4..11c189a6600 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -31,7 +31,6 @@ #include "dri_util.h" #include "drm_sarea.h" #include "utils.h" -#include "vblank.h" #include "xmlpool.h" PUBLIC const char __dri2ConfigOptions[] = -- cgit v1.2.3 From a1a7738223b754044213b969371823ec52b0a9e2 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 23:31:35 -0700 Subject: gallivm: Remove NULL check of pointer that can't be NULL. info cannot be NULL at the call to debug_printf. emit_instruction dereferences info, so at debug_printf it is either not NULL or the program has already crashed. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index df2e24c2c90..aed1d583cb2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1812,7 +1812,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, const struct tgsi_opcode_info *info = tgsi_get_opcode_info(opcode); if (!emit_instruction( &bld, &parse.FullToken.FullInstruction, info )) _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n", - info ? info->mnemonic : ""); + info->mnemonic); } break; -- cgit v1.2.3 From d69ed3a96eb4ed2630bee28f1937d376eee435e1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 24 Apr 2010 23:41:59 -0700 Subject: radeon: Remove NULL check of bo_legacy->tobj. bo_legacy->tobj cannot be NULL before the call to driUpdateTextureLRU. There is a NULL check earlier in the routine, and if bo_legacy->tobj is NULL, memory is allocated. --- src/mesa/drivers/dri/radeon/radeon_bo_legacy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c index cf12664bacd..78f73bf99ce 100644 --- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c +++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c @@ -618,8 +618,7 @@ static int bo_vram_validate(struct radeon_bo_int *bo, assert(bo_legacy->tobj->base.memBlock); - if (bo_legacy->tobj) - driUpdateTextureLRU(&bo_legacy->tobj->base); + driUpdateTextureLRU(&bo_legacy->tobj->base); if (bo_legacy->dirty || bo_legacy->tobj->base.dirty_images[0]) { if (IS_R600_CLASS(boml->screen)) { -- cgit v1.2.3 From 5d37cebc1b2f41ef68a5f8bb5ad66973ec2c1dd8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 25 Apr 2010 02:04:13 -0700 Subject: gallivm: Rename variable info to opcode_info. Avoid hiding existing variable already named info in outer scope. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index aed1d583cb2..16741e41c8d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1809,10 +1809,10 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, case TGSI_TOKEN_TYPE_INSTRUCTION: { unsigned opcode = parse.FullToken.FullInstruction.Instruction.Opcode; - const struct tgsi_opcode_info *info = tgsi_get_opcode_info(opcode); - if (!emit_instruction( &bld, &parse.FullToken.FullInstruction, info )) + const struct tgsi_opcode_info *opcode_info = tgsi_get_opcode_info(opcode); + if (!emit_instruction( &bld, &parse.FullToken.FullInstruction, opcode_info )) _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n", - info->mnemonic); + opcode_info->mnemonic); } break; -- cgit v1.2.3 From 7b7a9e89274d16c7c6c79bf3a0ee2e7c642aaa02 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 25 Apr 2010 02:18:52 -0700 Subject: st/dri: Add missing header. Add GL/internal/dri_interface.h for __DRI_TEXTURE_FORMAT_RGB. --- src/gallium/state_trackers/dri/drm/dri2.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 5ab7067ae2f..7c84fcfd723 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -41,6 +41,8 @@ #include "dri_st_api.h" #include "dri2.h" +#include "GL/internal/dri_interface.h" + /** * DRI2 flush extension. */ -- cgit v1.2.3 From 7cebd16fbbb68d76b516098f5e6d6a1fc415b8b0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 12:11:36 +0100 Subject: llvmpipe: lp_tex_sample_llvm.c -> lp_tex_sample.c 'llvm' suffix unnecessary now that the C sampling version disappeared. --- src/gallium/drivers/llvmpipe/Makefile | 2 +- src/gallium/drivers/llvmpipe/SConscript | 2 +- src/gallium/drivers/llvmpipe/lp_tex_sample.c | 216 ++++++++++++++++++++++ src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c | 216 ---------------------- 4 files changed, 218 insertions(+), 218 deletions(-) create mode 100644 src/gallium/drivers/llvmpipe/lp_tex_sample.c delete mode 100644 src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 7bf5b097628..4ea367597e1 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -40,7 +40,7 @@ C_SOURCES = \ lp_state_vertex.c \ lp_state_vs.c \ lp_surface.c \ - lp_tex_sample_llvm.c \ + lp_tex_sample.c \ lp_texture.c \ lp_tile_image.c \ lp_tile_soa.c diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index b9e9826e2a3..2911cf2179a 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -60,7 +60,7 @@ llvmpipe = env.ConvenienceLibrary( 'lp_state_vertex.c', 'lp_state_vs.c', 'lp_surface.c', - 'lp_tex_sample_llvm.c', + 'lp_tex_sample.c', 'lp_texture.c', 'lp_tile_image.c', 'lp_tile_soa.c', diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c new file mode 100644 index 00000000000..74b7393e4ec --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -0,0 +1,216 @@ +/************************************************************************** + * + * Copyright 2009 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. + * + **************************************************************************/ + +/** + * Texture sampling code generation + * + * This file is nothing more than ugly glue between three largely independent + * entities: + * - TGSI -> LLVM translation (i.e., lp_build_tgsi_soa) + * - texture sampling code generation (i.e., lp_build_sample_soa) + * - LLVM pipe driver + * + * All interesting code is in the functions mentioned above. There is really + * nothing to see here. + * + * @author Jose Fonseca + */ + +#include "pipe/p_defines.h" +#include "pipe/p_shader_tokens.h" +#include "gallivm/lp_bld_debug.h" +#include "gallivm/lp_bld_type.h" +#include "gallivm/lp_bld_sample.h" +#include "gallivm/lp_bld_tgsi.h" +#include "lp_jit.h" +#include "lp_tex_sample.h" + + +/** + * This provides the bridge between the sampler state store in + * lp_jit_context and lp_jit_texture and the sampler code + * generator. It provides the texture layout information required by + * the texture sampler code generator in terms of the state stored in + * lp_jit_context and lp_jit_texture in runtime. + */ +struct llvmpipe_sampler_dynamic_state +{ + struct lp_sampler_dynamic_state base; + + const struct lp_sampler_static_state *static_state; + + LLVMValueRef context_ptr; +}; + + +/** + * This is the bridge between our sampler and the TGSI translator. + */ +struct lp_llvm_sampler_soa +{ + struct lp_build_sampler_soa base; + + struct llvmpipe_sampler_dynamic_state dynamic_state; +}; + + +/** + * Fetch the specified member of the lp_jit_texture structure. + * \param emit_load if TRUE, emit the LLVM load instruction to actually + * fetch the field's value. Otherwise, just emit the + * GEP code to address the field. + * + * @sa http://llvm.org/docs/GetElementPtr.html + */ +static LLVMValueRef +lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, + LLVMBuilderRef builder, + unsigned unit, + unsigned member_index, + const char *member_name, + boolean emit_load) +{ + struct llvmpipe_sampler_dynamic_state *state = + (struct llvmpipe_sampler_dynamic_state *)base; + LLVMValueRef indices[4]; + LLVMValueRef ptr; + LLVMValueRef res; + + assert(unit < PIPE_MAX_SAMPLERS); + + /* context[0] */ + indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); + /* context[0].textures */ + indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CTX_TEXTURES, 0); + /* context[0].textures[unit] */ + indices[2] = LLVMConstInt(LLVMInt32Type(), unit, 0); + /* context[0].textures[unit].member */ + indices[3] = LLVMConstInt(LLVMInt32Type(), member_index, 0); + + ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); + + if (emit_load) + res = LLVMBuildLoad(builder, ptr, ""); + else + res = ptr; + + lp_build_name(res, "context.texture%u.%s", unit, member_name); + + return res; +} + + +/** + * Helper macro to instantiate the functions that generate the code to + * fetch the members of lp_jit_texture to fulfill the sampler code + * generator requests. + * + * This complexity is the price we have to pay to keep the texture + * sampler code generator a reusable module without dependencies to + * llvmpipe internals. + */ +#define LP_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \ + static LLVMValueRef \ + lp_llvm_texture_##_name( struct lp_sampler_dynamic_state *base, \ + LLVMBuilderRef builder, \ + unsigned unit) \ + { \ + return lp_llvm_texture_member(base, builder, unit, _index, #_name, _emit_load ); \ + } + + +LP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH, TRUE) +LP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT, TRUE) +LP_LLVM_TEXTURE_MEMBER(depth, LP_JIT_TEXTURE_DEPTH, TRUE) +LP_LLVM_TEXTURE_MEMBER(last_level, LP_JIT_TEXTURE_LAST_LEVEL, TRUE) +LP_LLVM_TEXTURE_MEMBER(row_stride, LP_JIT_TEXTURE_ROW_STRIDE, FALSE) +LP_LLVM_TEXTURE_MEMBER(img_stride, LP_JIT_TEXTURE_IMG_STRIDE, FALSE) +LP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA, FALSE) + + +static void +lp_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) +{ + FREE(sampler); +} + + +/** + * Fetch filtered values from texture. + * The 'texel' parameter returns four vectors corresponding to R, G, B, A. + */ +static void +lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, + LLVMBuilderRef builder, + struct lp_type type, + unsigned unit, + unsigned num_coords, + const LLVMValueRef *coords, + LLVMValueRef lodbias, + LLVMValueRef *texel) +{ + struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base; + + assert(unit < PIPE_MAX_SAMPLERS); + + lp_build_sample_soa(builder, + &sampler->dynamic_state.static_state[unit], + &sampler->dynamic_state.base, + type, + unit, + num_coords, + coords, + lodbias, + texel); +} + + +struct lp_build_sampler_soa * +lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state, + LLVMValueRef context_ptr) +{ + struct lp_llvm_sampler_soa *sampler; + + sampler = CALLOC_STRUCT(lp_llvm_sampler_soa); + if(!sampler) + return NULL; + + sampler->base.destroy = lp_llvm_sampler_soa_destroy; + sampler->base.emit_fetch_texel = lp_llvm_sampler_soa_emit_fetch_texel; + sampler->dynamic_state.base.width = lp_llvm_texture_width; + sampler->dynamic_state.base.height = lp_llvm_texture_height; + sampler->dynamic_state.base.depth = lp_llvm_texture_depth; + sampler->dynamic_state.base.last_level = lp_llvm_texture_last_level; + sampler->dynamic_state.base.row_stride = lp_llvm_texture_row_stride; + sampler->dynamic_state.base.img_stride = lp_llvm_texture_img_stride; + sampler->dynamic_state.base.data_ptr = lp_llvm_texture_data_ptr; + sampler->dynamic_state.static_state = static_state; + sampler->dynamic_state.context_ptr = context_ptr; + + return &sampler->base; +} + diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c deleted file mode 100644 index 74b7393e4ec..00000000000 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ /dev/null @@ -1,216 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 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. - * - **************************************************************************/ - -/** - * Texture sampling code generation - * - * This file is nothing more than ugly glue between three largely independent - * entities: - * - TGSI -> LLVM translation (i.e., lp_build_tgsi_soa) - * - texture sampling code generation (i.e., lp_build_sample_soa) - * - LLVM pipe driver - * - * All interesting code is in the functions mentioned above. There is really - * nothing to see here. - * - * @author Jose Fonseca - */ - -#include "pipe/p_defines.h" -#include "pipe/p_shader_tokens.h" -#include "gallivm/lp_bld_debug.h" -#include "gallivm/lp_bld_type.h" -#include "gallivm/lp_bld_sample.h" -#include "gallivm/lp_bld_tgsi.h" -#include "lp_jit.h" -#include "lp_tex_sample.h" - - -/** - * This provides the bridge between the sampler state store in - * lp_jit_context and lp_jit_texture and the sampler code - * generator. It provides the texture layout information required by - * the texture sampler code generator in terms of the state stored in - * lp_jit_context and lp_jit_texture in runtime. - */ -struct llvmpipe_sampler_dynamic_state -{ - struct lp_sampler_dynamic_state base; - - const struct lp_sampler_static_state *static_state; - - LLVMValueRef context_ptr; -}; - - -/** - * This is the bridge between our sampler and the TGSI translator. - */ -struct lp_llvm_sampler_soa -{ - struct lp_build_sampler_soa base; - - struct llvmpipe_sampler_dynamic_state dynamic_state; -}; - - -/** - * Fetch the specified member of the lp_jit_texture structure. - * \param emit_load if TRUE, emit the LLVM load instruction to actually - * fetch the field's value. Otherwise, just emit the - * GEP code to address the field. - * - * @sa http://llvm.org/docs/GetElementPtr.html - */ -static LLVMValueRef -lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, - LLVMBuilderRef builder, - unsigned unit, - unsigned member_index, - const char *member_name, - boolean emit_load) -{ - struct llvmpipe_sampler_dynamic_state *state = - (struct llvmpipe_sampler_dynamic_state *)base; - LLVMValueRef indices[4]; - LLVMValueRef ptr; - LLVMValueRef res; - - assert(unit < PIPE_MAX_SAMPLERS); - - /* context[0] */ - indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); - /* context[0].textures */ - indices[1] = LLVMConstInt(LLVMInt32Type(), LP_JIT_CTX_TEXTURES, 0); - /* context[0].textures[unit] */ - indices[2] = LLVMConstInt(LLVMInt32Type(), unit, 0); - /* context[0].textures[unit].member */ - indices[3] = LLVMConstInt(LLVMInt32Type(), member_index, 0); - - ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); - - if (emit_load) - res = LLVMBuildLoad(builder, ptr, ""); - else - res = ptr; - - lp_build_name(res, "context.texture%u.%s", unit, member_name); - - return res; -} - - -/** - * Helper macro to instantiate the functions that generate the code to - * fetch the members of lp_jit_texture to fulfill the sampler code - * generator requests. - * - * This complexity is the price we have to pay to keep the texture - * sampler code generator a reusable module without dependencies to - * llvmpipe internals. - */ -#define LP_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \ - static LLVMValueRef \ - lp_llvm_texture_##_name( struct lp_sampler_dynamic_state *base, \ - LLVMBuilderRef builder, \ - unsigned unit) \ - { \ - return lp_llvm_texture_member(base, builder, unit, _index, #_name, _emit_load ); \ - } - - -LP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH, TRUE) -LP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT, TRUE) -LP_LLVM_TEXTURE_MEMBER(depth, LP_JIT_TEXTURE_DEPTH, TRUE) -LP_LLVM_TEXTURE_MEMBER(last_level, LP_JIT_TEXTURE_LAST_LEVEL, TRUE) -LP_LLVM_TEXTURE_MEMBER(row_stride, LP_JIT_TEXTURE_ROW_STRIDE, FALSE) -LP_LLVM_TEXTURE_MEMBER(img_stride, LP_JIT_TEXTURE_IMG_STRIDE, FALSE) -LP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA, FALSE) - - -static void -lp_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) -{ - FREE(sampler); -} - - -/** - * Fetch filtered values from texture. - * The 'texel' parameter returns four vectors corresponding to R, G, B, A. - */ -static void -lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, - LLVMBuilderRef builder, - struct lp_type type, - unsigned unit, - unsigned num_coords, - const LLVMValueRef *coords, - LLVMValueRef lodbias, - LLVMValueRef *texel) -{ - struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base; - - assert(unit < PIPE_MAX_SAMPLERS); - - lp_build_sample_soa(builder, - &sampler->dynamic_state.static_state[unit], - &sampler->dynamic_state.base, - type, - unit, - num_coords, - coords, - lodbias, - texel); -} - - -struct lp_build_sampler_soa * -lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state, - LLVMValueRef context_ptr) -{ - struct lp_llvm_sampler_soa *sampler; - - sampler = CALLOC_STRUCT(lp_llvm_sampler_soa); - if(!sampler) - return NULL; - - sampler->base.destroy = lp_llvm_sampler_soa_destroy; - sampler->base.emit_fetch_texel = lp_llvm_sampler_soa_emit_fetch_texel; - sampler->dynamic_state.base.width = lp_llvm_texture_width; - sampler->dynamic_state.base.height = lp_llvm_texture_height; - sampler->dynamic_state.base.depth = lp_llvm_texture_depth; - sampler->dynamic_state.base.last_level = lp_llvm_texture_last_level; - sampler->dynamic_state.base.row_stride = lp_llvm_texture_row_stride; - sampler->dynamic_state.base.img_stride = lp_llvm_texture_img_stride; - sampler->dynamic_state.base.data_ptr = lp_llvm_texture_data_ptr; - sampler->dynamic_state.static_state = static_state; - sampler->dynamic_state.context_ptr = context_ptr; - - return &sampler->base; -} - -- cgit v1.2.3 From 8a70c47c4cf0c792f874e16517f2afd709e160a6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 12:12:54 +0100 Subject: llvmpipe: Remove sp2lp.sh. Irrelevant now that llvmpipe and softpipe grew so far apart. --- src/gallium/drivers/llvmpipe/sp2lp.sh | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100755 src/gallium/drivers/llvmpipe/sp2lp.sh (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/sp2lp.sh b/src/gallium/drivers/llvmpipe/sp2lp.sh deleted file mode 100755 index c45a81ce3cf..00000000000 --- a/src/gallium/drivers/llvmpipe/sp2lp.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# -# Port changes from softpipe to llvmpipe. Invoke as -# -# sp2lp.sh -# -# Note that this will only affect llvmpipe -- you still need to actually -# cherry-pick/merge the softpipe changes themselves if they affect directories -# outside src/gallium/drivers/softpipe - -git format-patch \ - --keep-subject \ - --relative=src/gallium/drivers/softpipe \ - --src-prefix=a/src/gallium/drivers/llvmpipe/ \ - --dst-prefix=b/src/gallium/drivers/llvmpipe/ \ - --stdout "$1^1..$1" \ -| sed \ - -e 's/\/llvmpipe/g' \ - -e 's/\/lp/g' \ - -e 's/\/lpt/g' \ - -e 's/\/lps/g' \ - -e 's/\/lpfs/g' \ - -e 's/\/lptex/g' \ - -e 's/\/llvmpipe_\0/g' \ - -e 's/\/llvmpipe_cached_tex_tile/g' \ - -e 's/_get_cached_tile_tex\>/_get_cached_tex_tile/g' \ - -e 's/\/TEX_TILE_SIZE/g' \ - -e 's/\/tex_tile_address/g' \ - -e 's/\data\.color\>/tile->color/g' \ -| patch -p1 -- cgit v1.2.3 From 7e4ce65d714624d5d2888c59f0d83ffda0662834 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 14:51:33 +0100 Subject: softpipe: More accurate softpipe_is_format_supported(). Unfortunately there are some heavy limitations on supported render target formats due to the way clear values are used internally. --- src/gallium/drivers/softpipe/sp_screen.c | 74 ++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 8406aa1ac3e..11aa0c4583b 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -27,6 +27,7 @@ #include "util/u_memory.h" +#include "util/u_format.h" #include "util/u_format_s3tc.h" #include "pipe/p_defines.h" #include "pipe/p_screen.h" @@ -144,42 +145,77 @@ static boolean softpipe_is_format_supported( struct pipe_screen *screen, enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned bind, unsigned geom_flags ) { struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + const struct util_format_description *format_desc; assert(target == PIPE_TEXTURE_1D || target == PIPE_TEXTURE_2D || target == PIPE_TEXTURE_3D || target == PIPE_TEXTURE_CUBE); - switch(format) { - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: - case PIPE_FORMAT_DXT3_RGBA: - case PIPE_FORMAT_DXT5_RGBA: - if (tex_usage & PIPE_BIND_RENDER_TARGET) + format_desc = util_format_description(format); + if (!format_desc) + return FALSE; + + if (bind & (PIPE_BIND_DISPLAY_TARGET | + PIPE_BIND_SCANOUT | + PIPE_BIND_SHARED)) { + if(!winsys->is_displaytarget_format_supported(winsys, bind, format)) return FALSE; - else - return util_format_s3tc_enabled; + } - case PIPE_FORMAT_Z32_FLOAT: - case PIPE_FORMAT_NONE: - return FALSE; + if (bind & PIPE_BIND_RENDER_TARGET) { + if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) + return FALSE; - default: - break; + /* + * Although possible, it is unnatural to render into compressed or YUV + * surfaces. So disable these here to avoid going into weird paths + * inside the state trackers. + */ + if (format_desc->block.width != 1 || + format_desc->block.height != 1) + return FALSE; + + /* + * TODO: Unfortunately we cannot render into anything more than 32 bits + * because we encode color clear values into a 32bit word. + */ + if (format_desc->block.bits > 32) + return FALSE; } - if(tex_usage & (PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SCANOUT | - PIPE_BIND_SHARED)) { - if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format)) + if (bind & PIPE_BIND_DEPTH_STENCIL) { + if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) return FALSE; + + /* + * TODO: Unfortunately we cannot render into anything more than 32 bits + * because we encode depth and stencil clear values into a 32bit word. + */ + if (format_desc->block.bits > 32) + return FALSE; + + /* + * TODO: eliminate this restriction + */ + if (format == PIPE_FORMAT_Z32_FLOAT) + return FALSE; + } + + /* + * All other operations (sampling, transfer, etc). + */ + + if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { + return util_format_s3tc_enabled; } - /* XXX: this is often a lie. Pull in logic from llvmpipe to fix. + /* + * Everything else should be supported by u_format. */ return TRUE; } -- cgit v1.2.3 From adc7cd6240cb7bc79743871db6ce5b95325b8807 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 14:52:27 +0100 Subject: llvmpipe: Cleanup llvmpipe_is_format_supported(). It should be just cosmetic. --- src/gallium/drivers/llvmpipe/lp_screen.c | 39 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 88c0604c541..00a897c86f8 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -168,7 +168,7 @@ static boolean llvmpipe_is_format_supported( struct pipe_screen *_screen, enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned bind, unsigned geom_flags ) { struct llvmpipe_screen *screen = llvmpipe_screen(_screen); @@ -176,7 +176,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, const struct util_format_description *format_desc; format_desc = util_format_description(format); - if(!format_desc) + if (!format_desc) return FALSE; assert(target == PIPE_TEXTURE_1D || @@ -184,43 +184,42 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, target == PIPE_TEXTURE_3D || target == PIPE_TEXTURE_CUBE); - if(tex_usage & PIPE_BIND_RENDER_TARGET) { - if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) + if (bind & PIPE_BIND_RENDER_TARGET) { + if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) return FALSE; - if(format_desc->block.width != 1 || - format_desc->block.height != 1) + if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) return FALSE; - if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB && - format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB) + if (format_desc->block.width != 1 || + format_desc->block.height != 1) return FALSE; } - if(tex_usage & PIPE_BIND_DISPLAY_TARGET) { - if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format)) + if (bind & PIPE_BIND_DISPLAY_TARGET) { + if(!winsys->is_displaytarget_format_supported(winsys, bind, format)) return FALSE; } - if(tex_usage & PIPE_BIND_DEPTH_STENCIL) { - if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) + if (bind & PIPE_BIND_DEPTH_STENCIL) { + if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) + return FALSE; + + if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) return FALSE; /* FIXME: Temporary restriction. See lp_state_fs.c. */ - if(format_desc->block.bits != 32) + if (format_desc->block.bits != 32) return FALSE; } - switch(format) { - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: - case PIPE_FORMAT_DXT3_RGBA: - case PIPE_FORMAT_DXT5_RGBA: + if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { return util_format_s3tc_enabled; - default: - break; } + /* + * Everything else should be supported by u_format. + */ return TRUE; } -- cgit v1.2.3 From 23df86d851dd6cbce1ddd7a45424c7bf14c04a3e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 14:53:40 +0100 Subject: llvmpipe: Replace tile_read/write with more descriptive swizzle/unswizzle verbs. --- src/gallium/drivers/llvmpipe/lp_rast.c | 6 ++-- src/gallium/drivers/llvmpipe/lp_tile_image.c | 4 +-- src/gallium/drivers/llvmpipe/lp_tile_soa.h | 9 ++++-- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 41 ++++++++++++++++------------ 4 files changed, 36 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 0aae2542a22..400404fc524 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -121,9 +121,11 @@ lp_rast_end( struct lp_rasterizer *rast ) rast->curr_scene = NULL; +#ifdef DEBUG if (0) - debug_printf("Post render scene: tile read: %d tile write: %d\n", - tile_read_count, tile_write_count); + debug_printf("Post render scene: tile unswizzle: %u tile swizzle: %u\n", + lp_tile_unswizzle_count, lp_tile_swizzle_count); +#endif } diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c b/src/gallium/drivers/llvmpipe/lp_tile_image.c index 7a2cc3e6b5e..2b63992dd70 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_image.c +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c @@ -201,7 +201,7 @@ lp_tiled_to_linear(const void *src, void *dst, uint byte_offset = tile_offset * bytes_per_tile; const uint8_t *src_tile = (uint8_t *) src + byte_offset; - lp_tile_write_4ub(format, + lp_tile_unswizzle_4ub(format, src_tile, dst, dst_stride, ii, jj, tile_w, tile_h); @@ -290,7 +290,7 @@ lp_linear_to_tiled(const void *src, void *dst, uint byte_offset = tile_offset * bytes_per_tile; uint8_t *dst_tile = (uint8_t *) dst + byte_offset; - lp_tile_read_4ub(format, + lp_tile_swizzle_4ub(format, dst_tile, src, src_stride, ii, jj, tile_w, tile_h); diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.h b/src/gallium/drivers/llvmpipe/lp_tile_soa.h index 634d8dfb1ce..07f71b8411a 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.h +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.h @@ -51,7 +51,10 @@ tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH]; #define TILE_Y_STRIDE (TILE_VECTOR_HEIGHT * TILE_SIZE * NUM_CHANNELS) //1024 -extern int tile_write_count, tile_read_count; +#ifdef DEBUG +extern unsigned lp_tile_unswizzle_count; +extern unsigned lp_tile_swizzle_count; +#endif /** @@ -73,14 +76,14 @@ tile_pixel_offset(unsigned x, unsigned y, unsigned c) void -lp_tile_read_4ub(enum pipe_format format, +lp_tile_swizzle_4ub(enum pipe_format format, uint8_t *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h); void -lp_tile_write_4ub(enum pipe_format format, +lp_tile_unswizzle_4ub(enum pipe_format format, const uint8_t *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h); diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 4e9cd7e123f..b2f800afd8a 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -75,7 +75,7 @@ def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): src_native_type = native_type(format) print 'static void' - print 'lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type) + print 'lp_tile_%s_swizzle_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type) print '{' print ' unsigned x, y;' print ' const uint8_t *src_row = src + y0*src_stride;' @@ -193,7 +193,7 @@ def pack_rgba(format, src_channel, r, g, b, a): return expr -def emit_unrolled_write_code(format, src_channel): +def emit_unrolled_unswizzle_code(format, src_channel): '''Emit code for writing a block based on unrolled loops. This is considerably faster than the TILE_PIXEL-based code below. ''' @@ -223,7 +223,7 @@ def emit_unrolled_write_code(format, src_channel): print ' }' -def emit_tile_pixel_write_code(format, src_channel): +def emit_tile_pixel_unswizzle_code(format, src_channel): '''Emit code for writing a block based on the TILE_PIXEL macro.''' dst_native_type = native_type(format) @@ -273,7 +273,7 @@ def generate_format_write(format, src_channel, src_native_type, src_suffix): name = format.short_name() print 'static void' - print 'lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type) + print 'lp_tile_%s_unswizzle_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type) print '{' if format.layout == PLAIN \ and format.colorspace == 'rgb' \ @@ -282,14 +282,14 @@ def generate_format_write(format, src_channel, src_native_type, src_suffix): and not format.is_mixed() \ and (format.channels[0].type == UNSIGNED \ or format.channels[1].type == UNSIGNED): - emit_unrolled_write_code(format, src_channel) + emit_unrolled_unswizzle_code(format, src_channel) else: - emit_tile_pixel_write_code(format, src_channel) + emit_tile_pixel_unswizzle_code(format, src_channel) print '}' print -def generate_read(formats, dst_channel, dst_native_type, dst_suffix): +def generate_swizzle(formats, dst_channel, dst_native_type, dst_suffix): '''Generate the dispatch function to read pixels from any format''' for format in formats: @@ -297,15 +297,17 @@ def generate_read(formats, dst_channel, dst_native_type, dst_suffix): generate_format_read(format, dst_channel, dst_native_type, dst_suffix) print 'void' - print 'lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type) + print 'lp_tile_swizzle_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type) print '{' print ' void (*func)(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type - print ' tile_read_count += 1;' + print '#ifdef DEBUG' + print ' lp_tile_swizzle_count += 1;' + print '#endif' print ' switch(format) {' for format in formats: if is_format_supported(format): print ' case %s:' % format.name - print ' func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix) + print ' func = &lp_tile_%s_swizzle_%s;' % (format.short_name(), dst_suffix) print ' break;' print ' default:' print ' debug_printf("%s: unsupported format %s\\n", __FUNCTION__, util_format_name(format));' @@ -316,7 +318,7 @@ def generate_read(formats, dst_channel, dst_native_type, dst_suffix): print -def generate_write(formats, src_channel, src_native_type, src_suffix): +def generate_unswizzle(formats, src_channel, src_native_type, src_suffix): '''Generate the dispatch function to write pixels to any format''' for format in formats: @@ -324,16 +326,18 @@ def generate_write(formats, src_channel, src_native_type, src_suffix): generate_format_write(format, src_channel, src_native_type, src_suffix) print 'void' - print 'lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type) + print 'lp_tile_unswizzle_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type) print '{' print ' void (*func)(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type - print ' tile_write_count += 1;' + print '#ifdef DEBUG' + print ' lp_tile_unswizzle_count += 1;' + print '#endif' print ' switch(format) {' for format in formats: if is_format_supported(format): print ' case %s:' % format.name - print ' func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix) + print ' func = &lp_tile_%s_unswizzle_%s;' % (format.short_name(), src_suffix) print ' break;' print ' default:' print ' debug_printf("%s: unsupported format %s\\n", __FUNCTION__, util_format_name(format));' @@ -360,7 +364,10 @@ def main(): print '#include "util/u_half.h"' print '#include "lp_tile_soa.h"' print - print 'int tile_write_count=0, tile_read_count=0;' + print '#ifdef DEBUG' + print 'unsigned lp_tile_unswizzle_count = 0;' + print 'unsigned lp_tile_swizzle_count = 0;' + print '#endif' print print 'const unsigned char' print 'tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = {' @@ -388,8 +395,8 @@ def main(): native_type = 'uint8_t' suffix = '4ub' - generate_read(formats, channel, native_type, suffix) - generate_write(formats, channel, native_type, suffix) + generate_swizzle(formats, channel, native_type, suffix) + generate_unswizzle(formats, channel, native_type, suffix) if __name__ == '__main__': -- cgit v1.2.3 From 89f244931f444056a1ccf544e608b533fa993fa2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 15:05:41 +0100 Subject: softpipe: Hardcode TILE_CLEAR_OPTIMIZATION to 1. The un-optimized path relies on surface_fill which can only handle formats with depth <= 32, so it is pointless to keep it around. --- src/gallium/drivers/softpipe/sp_clear.c | 10 ---------- src/gallium/drivers/softpipe/sp_tile_cache.c | 9 +-------- src/gallium/drivers/softpipe/sp_tile_cache.h | 2 -- 3 files changed, 1 insertion(+), 20 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index 5f130453c39..ae3f00f3387 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -69,11 +69,6 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, util_pack_color(rgba, ps->format, &uc); sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, uc.ui); - -#if !TILE_CLEAR_OPTIMIZATION - /* non-cached surface */ - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui); -#endif } } @@ -83,11 +78,6 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, cv = util_pack_z_stencil(ps->format, depth, stencil); sp_tile_cache_clear(softpipe->zsbuf_cache, zero, cv); - -#if !TILE_CLEAR_OPTIMIZATION - /* non-cached surface */ - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv); -#endif } softpipe->dirty_render_cache = TRUE; diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index d996c2a3427..4e5a13ba051 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -103,7 +103,7 @@ sp_create_tile_cache( struct pipe_context *pipe ) * However, it breaks clearing in other situations (such as in * progs/tests/drawbuffers, see bug 24402). */ -#if 0 && TILE_CLEAR_OPTIMIZATION +#if 0 /* set flags to indicate all the tiles are cleared */ memset(tc->clear_flags, 255, sizeof(tc->clear_flags)); #endif @@ -344,9 +344,7 @@ sp_flush_tile_cache(struct softpipe_tile_cache *tc) } } -#if TILE_CLEAR_OPTIMIZATION sp_tile_cache_flush_clear(tc); -#endif } #if 0 @@ -448,13 +446,8 @@ sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba, tc->clear_val = clearValue; -#if TILE_CLEAR_OPTIMIZATION /* set flags to indicate all the tiles are cleared */ memset(tc->clear_flags, 255, sizeof(tc->clear_flags)); -#else - /* disable the optimization */ - memset(tc->clear_flags, 0, sizeof(tc->clear_flags)); -#endif for (pos = 0; pos < NUM_ENTRIES; pos++) { struct softpipe_cached_tile *tile = tc->entries + pos; diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h index 753d8c0daac..e03d53eb24e 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tile_cache.h @@ -28,8 +28,6 @@ #ifndef SP_TILE_CACHE_H #define SP_TILE_CACHE_H -#define TILE_CLEAR_OPTIMIZATION 1 - #include "pipe/p_compiler.h" -- cgit v1.2.3 From 5745bcb2dbfcaab53df89125d08689b51b9126ea Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 15:40:06 +0100 Subject: llvmpipe: Fix buffer overflow unswizzling several formats. Array formats without for channels were being advanced as four channels, causing buffer overflows. --- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index b2f800afd8a..5ab63cbac67 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -257,7 +257,7 @@ def emit_tile_pixel_unswizzle_code(format, src_channel): value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) print ' *dst_pixel++ = %s;' % value - else: + elif dst_channel.size: print ' ++dst_pixel;' else: assert False -- cgit v1.2.3 From 7951630d0877fc3c293151ad6476bec7288e63c6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 15:49:03 +0100 Subject: llvmpipe: llvmpipe_flush_texture -> llvmpipe_flush_resource --- src/gallium/drivers/llvmpipe/lp_flush.c | 19 ++++++++----------- src/gallium/drivers/llvmpipe/lp_flush.h | 2 +- src/gallium/drivers/llvmpipe/lp_surface.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_texture.c | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 3627dbd759c..153491378ae 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -97,19 +97,16 @@ llvmpipe_flush( struct pipe_context *pipe, * Flush context if necessary. * * TODO: move this logic to an auxiliary library? - * - * FIXME: We must implement DISCARD/DONTBLOCK/UNSYNCHRONIZED/etc for - * textures to avoid blocking. */ boolean -llvmpipe_flush_texture(struct pipe_context *pipe, - struct pipe_resource *texture, - unsigned face, - unsigned level, - unsigned flush_flags, - boolean read_only, - boolean cpu_access, - boolean do_not_flush) +llvmpipe_flush_resource(struct pipe_context *pipe, + struct pipe_resource *texture, + unsigned face, + unsigned level, + unsigned flush_flags, + boolean read_only, + boolean cpu_access, + boolean do_not_flush) { unsigned referenced; diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h b/src/gallium/drivers/llvmpipe/lp_flush.h index 2375d22b854..e516cee3789 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.h +++ b/src/gallium/drivers/llvmpipe/lp_flush.h @@ -37,7 +37,7 @@ void llvmpipe_flush(struct pipe_context *pipe, unsigned flags, struct pipe_fence_handle **fence); boolean -llvmpipe_flush_texture(struct pipe_context *pipe, +llvmpipe_flush_resource(struct pipe_context *pipe, struct pipe_resource *texture, unsigned face, unsigned level, diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index ca03440d5d6..4934055bc6f 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -59,14 +59,14 @@ lp_surface_copy(struct pipe_context *pipe, struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst->texture); const enum pipe_format format = src_tex->base.format; - llvmpipe_flush_texture(pipe, + llvmpipe_flush_resource(pipe, dst->texture, dst->face, dst->level, 0, /* flush_flags */ FALSE, /* read_only */ FALSE, /* cpu_access */ FALSE); /* do_not_flush */ - llvmpipe_flush_texture(pipe, + llvmpipe_flush_resource(pipe, src->texture, src->face, src->level, 0, /* flush_flags */ TRUE, /* read_only */ diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 0c66f4ad503..e1aed7fdb5b 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -566,7 +566,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe, * Transfers, like other pipe operations, must happen in order, so flush the * context if necessary. */ - llvmpipe_flush_texture(pipe, + llvmpipe_flush_resource(pipe, transfer->resource, transfer->sr.face, transfer->sr.level, -- cgit v1.2.3 From 8352983e2ab9523345f2b2b3db62db19f01fab62 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 25 Apr 2010 13:10:02 -0700 Subject: llvmpipe: Remove unused variable. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 3eb25d41277..9e9d9bcfb52 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -404,7 +404,6 @@ generate_fs(struct llvmpipe_context *lp, { const struct tgsi_token *tokens = shader->base.tokens; LLVMTypeRef vec_type; - LLVMTypeRef int_vec_type; LLVMValueRef consts_ptr; LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS]; LLVMValueRef z = interp->pos[2]; @@ -422,7 +421,6 @@ generate_fs(struct llvmpipe_context *lp, stencil_refs[1] = lp_jit_context_stencil_ref_back_value(builder, context_ptr); vec_type = lp_build_vec_type(type); - int_vec_type = lp_build_int_vec_type(type); consts_ptr = lp_jit_context_constants(builder, context_ptr); -- cgit v1.2.3 From 43b85af56efbe6eb06f4e62d23e9f6f583c5ec2e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 16:59:09 +0100 Subject: llvmpipe: Cleanup/improve llvmpipe_flush_resource usage. Recognize PIPE_TRANSFER_UNSYNCHRONIZED and PIPE_TRANSFER_DONTBLOCK. --- src/gallium/drivers/llvmpipe/lp_flush.c | 11 ++++++---- src/gallium/drivers/llvmpipe/lp_flush.h | 19 +++++++++-------- src/gallium/drivers/llvmpipe/lp_surface.c | 20 +++++++++--------- src/gallium/drivers/llvmpipe/lp_texture.c | 34 +++++++++++++++++++------------ 4 files changed, 48 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 153491378ae..470132d49fa 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -96,6 +96,9 @@ llvmpipe_flush( struct pipe_context *pipe, /** * Flush context if necessary. * + * Returns FALSE if it would have block, but do_not_block was set, TRUE + * otherwise. + * * TODO: move this logic to an auxiliary library? */ boolean @@ -106,7 +109,7 @@ llvmpipe_flush_resource(struct pipe_context *pipe, unsigned flush_flags, boolean read_only, boolean cpu_access, - boolean do_not_flush) + boolean do_not_block) { unsigned referenced; @@ -115,9 +118,6 @@ llvmpipe_flush_resource(struct pipe_context *pipe, if ((referenced & PIPE_REFERENCED_FOR_WRITE) || ((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) { - if (do_not_flush) - return FALSE; - /* * TODO: The semantics of these flush flags are too obtuse. They should * disappear and the pipe driver should just ensure that all visible @@ -136,6 +136,9 @@ llvmpipe_flush_resource(struct pipe_context *pipe, struct pipe_fence_handle *fence = NULL; + if (do_not_block) + return FALSE; + pipe->flush(pipe, flush_flags, &fence); if (fence) { diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h b/src/gallium/drivers/llvmpipe/lp_flush.h index e516cee3789..1b38820b5a4 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.h +++ b/src/gallium/drivers/llvmpipe/lp_flush.h @@ -33,17 +33,18 @@ struct pipe_context; struct pipe_fence_handle; -void llvmpipe_flush(struct pipe_context *pipe, unsigned flags, - struct pipe_fence_handle **fence); +void +llvmpipe_flush(struct pipe_context *pipe, unsigned flags, + struct pipe_fence_handle **fence); boolean llvmpipe_flush_resource(struct pipe_context *pipe, - struct pipe_resource *texture, - unsigned face, - unsigned level, - unsigned flush_flags, - boolean read_only, - boolean cpu_access, - boolean do_not_flush); + struct pipe_resource *texture, + unsigned face, + unsigned level, + unsigned flush_flags, + boolean read_only, + boolean cpu_access, + boolean do_not_block); #endif diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index 4934055bc6f..1432782cefa 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -60,18 +60,18 @@ lp_surface_copy(struct pipe_context *pipe, const enum pipe_format format = src_tex->base.format; llvmpipe_flush_resource(pipe, - dst->texture, dst->face, dst->level, - 0, /* flush_flags */ - FALSE, /* read_only */ - FALSE, /* cpu_access */ - FALSE); /* do_not_flush */ + dst->texture, dst->face, dst->level, + 0, /* flush_flags */ + FALSE, /* read_only */ + FALSE, /* cpu_access */ + FALSE); /* do_not_block */ llvmpipe_flush_resource(pipe, - src->texture, src->face, src->level, - 0, /* flush_flags */ - TRUE, /* read_only */ - FALSE, /* cpu_access */ - FALSE); /* do_not_flush */ + src->texture, src->face, src->level, + 0, /* flush_flags */ + TRUE, /* read_only */ + FALSE, /* cpu_access */ + FALSE); /* do_not_block */ /* printf("surface copy from %u to %u: %u,%u to %u,%u %u x %u\n", diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index e1aed7fdb5b..29bdfe36ae6 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -492,6 +492,27 @@ llvmpipe_get_transfer(struct pipe_context *pipe, assert(resource); assert(sr.level <= resource->last_level); + /* + * Transfers, like other pipe operations, must happen in order, so flush the + * context if necessary. + */ + if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) { + boolean read_only = !(usage & PIPE_TRANSFER_WRITE); + boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK); + if (!llvmpipe_flush_resource(pipe, resource, + sr.face, sr.level, + 0, /* flush_flags */ + read_only, + TRUE, /* cpu_access */ + do_not_block)) { + /* + * It would have blocked, but state tracker requested no to. + */ + assert(do_not_block); + return NULL; + } + } + lpr = CALLOC_STRUCT(llvmpipe_transfer); if (lpr) { struct pipe_transfer *pt = &lpr->base; @@ -562,19 +583,6 @@ llvmpipe_transfer_map( struct pipe_context *pipe, lpr = llvmpipe_resource(transfer->resource); format = lpr->base.format; - /* - * Transfers, like other pipe operations, must happen in order, so flush the - * context if necessary. - */ - llvmpipe_flush_resource(pipe, - transfer->resource, - transfer->sr.face, - transfer->sr.level, - 0, /* flush_flags */ - !(transfer->usage & PIPE_TRANSFER_WRITE), /* read_only */ - TRUE, /* cpu_access */ - FALSE); /* do_not_flush */ - map = llvmpipe_resource_map(transfer->resource, transfer->sr.face, transfer->sr.level, -- cgit v1.2.3 From 53e94bd4adb218c5974c522389c3bcf40f3fa7e8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 17:03:48 +0100 Subject: softpipe: Make softpipe transfers in-order. Transfer, being now a context operation, should happen in order with all other contexts operations. If there is rendering pending on the resource then the driver must flush and potentially wait itself internally. Instead of avoiding using transfers internally (as done in llvmpipe) I've opted to simply pass PIPE_TRANSFER_UNSYNCHRONIZED in all internal transfers, to avoid infinite recursion. --- src/gallium/drivers/softpipe/sp_flush.c | 68 ++++++++++++++++++++++++ src/gallium/drivers/softpipe/sp_flush.h | 17 +++++- src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 3 +- src/gallium/drivers/softpipe/sp_texture.c | 22 ++++++++ src/gallium/drivers/softpipe/sp_tile_cache.c | 3 +- 5 files changed, 109 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index 508fe8f764d..5024fc8a819 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -104,3 +104,71 @@ softpipe_flush( struct pipe_context *pipe, *fence = NULL; } + +/** + * Flush context if necessary. + * + * Returns FALSE if it would have block, but do_not_block was set, TRUE + * otherwise. + * + * TODO: move this logic to an auxiliary library? + */ +boolean +softpipe_flush_resource(struct pipe_context *pipe, + struct pipe_resource *texture, + unsigned face, + unsigned level, + unsigned flush_flags, + boolean read_only, + boolean cpu_access, + boolean do_not_block) +{ + unsigned referenced; + + referenced = pipe->is_resource_referenced(pipe, texture, face, level); + + if ((referenced & PIPE_REFERENCED_FOR_WRITE) || + ((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) { + + /* + * TODO: The semantics of these flush flags are too obtuse. They should + * disappear and the pipe driver should just ensure that all visible + * side-effects happen when they need to happen. + */ + if (referenced & PIPE_REFERENCED_FOR_WRITE) + flush_flags |= PIPE_FLUSH_RENDER_CACHE; + + if (referenced & PIPE_REFERENCED_FOR_READ) + flush_flags |= PIPE_FLUSH_TEXTURE_CACHE; + + if (cpu_access) { + /* + * Flush and wait. + */ + + struct pipe_fence_handle *fence = NULL; + + if (do_not_block) + return FALSE; + + pipe->flush(pipe, flush_flags, &fence); + + if (fence) { + /* + * This is for illustrative purposes only, as softpipe does not + * have fences. + */ + pipe->screen->fence_finish(pipe->screen, fence, 0); + pipe->screen->fence_reference(pipe->screen, &fence, NULL); + } + } else { + /* + * Just flush. + */ + + pipe->flush(pipe, flush_flags, NULL); + } + } + + return TRUE; +} diff --git a/src/gallium/drivers/softpipe/sp_flush.h b/src/gallium/drivers/softpipe/sp_flush.h index 68d9b5fa835..cb97482a71b 100644 --- a/src/gallium/drivers/softpipe/sp_flush.h +++ b/src/gallium/drivers/softpipe/sp_flush.h @@ -28,10 +28,23 @@ #ifndef SP_FLUSH_H #define SP_FLUSH_H +#include "pipe/p_compiler.h" + struct pipe_context; struct pipe_fence_handle; -void softpipe_flush(struct pipe_context *pipe, unsigned flags, - struct pipe_fence_handle **fence); +void +softpipe_flush(struct pipe_context *pipe, unsigned flags, + struct pipe_fence_handle **fence); + +boolean +softpipe_flush_resource(struct pipe_context *pipe, + struct pipe_resource *texture, + unsigned face, + unsigned level, + unsigned flush_flags, + boolean read_only, + boolean cpu_access, + boolean do_not_block); #endif diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index c79f5fb05a1..fbce9e042ba 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -248,7 +248,8 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, addr.bits.face, addr.bits.level, addr.bits.z, - PIPE_TRANSFER_READ, 0, 0, + PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED, + 0, 0, u_minify(tc->texture->width0, addr.bits.level), u_minify(tc->texture->height0, addr.bits.level)); diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 167b6b11617..3533c4fd4f0 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -39,6 +39,7 @@ #include "util/u_transfer.h" #include "sp_context.h" +#include "sp_flush.h" #include "sp_texture.h" #include "sp_screen.h" @@ -301,6 +302,27 @@ softpipe_get_transfer(struct pipe_context *pipe, assert(box->y + box->height <= u_minify(resource->height0, sr.level)); assert(box->z + box->depth <= u_minify(resource->depth0, sr.level)); + /* + * Transfers, like other pipe operations, must happen in order, so flush the + * context if necessary. + */ + if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) { + boolean read_only = !(usage & PIPE_TRANSFER_WRITE); + boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK); + if (!softpipe_flush_resource(pipe, resource, + sr.face, sr.level, + 0, /* flush_flags */ + read_only, + TRUE, /* cpu_access */ + do_not_block)) { + /* + * It would have blocked, but state tracker requested no to. + */ + assert(do_not_block); + return NULL; + } + } + spr = CALLOC_STRUCT(softpipe_transfer); if (spr) { struct pipe_transfer *pt = &spr->base; diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 4e5a13ba051..f4db6f6ef00 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -155,7 +155,8 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, if (ps) { tc->transfer = pipe_get_transfer(pipe, ps->texture, ps->face, ps->level, ps->zslice, - PIPE_TRANSFER_READ_WRITE, + PIPE_TRANSFER_READ_WRITE | + PIPE_TRANSFER_UNSYNCHRONIZED, 0, 0, ps->width, ps->height); tc->depth_stencil = (ps->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || -- cgit v1.2.3 From 2cd128ab443addeb6e013f80d7c3f6639a66b2f1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 17:15:56 +0100 Subject: llvmpipe: No need to flush the caches for buffers. --- src/gallium/drivers/llvmpipe/lp_flush.c | 24 +++++++++++++----------- src/gallium/drivers/llvmpipe/lp_flush.h | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 470132d49fa..644b821957a 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -103,7 +103,7 @@ llvmpipe_flush( struct pipe_context *pipe, */ boolean llvmpipe_flush_resource(struct pipe_context *pipe, - struct pipe_resource *texture, + struct pipe_resource *resource, unsigned face, unsigned level, unsigned flush_flags, @@ -113,21 +113,23 @@ llvmpipe_flush_resource(struct pipe_context *pipe, { unsigned referenced; - referenced = pipe->is_resource_referenced(pipe, texture, face, level); + referenced = pipe->is_resource_referenced(pipe, resource, face, level); if ((referenced & PIPE_REFERENCED_FOR_WRITE) || ((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) { - /* - * TODO: The semantics of these flush flags are too obtuse. They should - * disappear and the pipe driver should just ensure that all visible - * side-effects happen when they need to happen. - */ - if (referenced & PIPE_REFERENCED_FOR_WRITE) - flush_flags |= PIPE_FLUSH_RENDER_CACHE; + if (resource->target != PIPE_BUFFER) { + /* + * TODO: The semantics of these flush flags are too obtuse. They should + * disappear and the pipe driver should just ensure that all visible + * side-effects happen when they need to happen. + */ + if (referenced & PIPE_REFERENCED_FOR_WRITE) + flush_flags |= PIPE_FLUSH_RENDER_CACHE; - if (referenced & PIPE_REFERENCED_FOR_READ) - flush_flags |= PIPE_FLUSH_TEXTURE_CACHE; + if (referenced & PIPE_REFERENCED_FOR_READ) + flush_flags |= PIPE_FLUSH_TEXTURE_CACHE; + } if (cpu_access) { /* diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h b/src/gallium/drivers/llvmpipe/lp_flush.h index 1b38820b5a4..7b605681a93 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.h +++ b/src/gallium/drivers/llvmpipe/lp_flush.h @@ -39,7 +39,7 @@ llvmpipe_flush(struct pipe_context *pipe, unsigned flags, boolean llvmpipe_flush_resource(struct pipe_context *pipe, - struct pipe_resource *texture, + struct pipe_resource *resource, unsigned face, unsigned level, unsigned flush_flags, -- cgit v1.2.3 From 4dd1a568404dcf068cb111db04bb6e904b91d7bd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 25 Apr 2010 21:43:49 +0100 Subject: draw: Respect pipe_vertex_buffer::max_index in llvm generated code. Everybody should respect max_index, specially llvm generated code, which likes to eat vertices 4 at a time, so it may end up chew a bit a bit more than actually exists. --- src/gallium/auxiliary/draw/draw_llvm.c | 12 +++++++++--- src/gallium/auxiliary/draw/draw_llvm.h | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 936753f66b9..703b46b518b 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -286,10 +286,16 @@ generate_fetch(LLVMBuilderRef builder, LLVMValueRef vbuffer_ptr = LLVMBuildGEP(builder, vbuffers_ptr, &indices, 1, ""); LLVMValueRef vb_stride = draw_jit_vbuffer_stride(builder, vbuf); + LLVMValueRef vb_max_index = draw_jit_vbuffer_max_index(builder, vbuf); LLVMValueRef vb_buffer_offset = draw_jit_vbuffer_offset(builder, vbuf); - LLVMValueRef stride = LLVMBuildMul(builder, - vb_stride, - index, ""); + LLVMValueRef cond; + LLVMValueRef stride; + + cond = LLVMBuildICmp(builder, LLVMIntULE, index, vb_max_index, ""); + + index = LLVMBuildSelect(builder, cond, index, vb_max_index, ""); + + stride = LLVMBuildMul(builder, vb_stride, index, ""); vbuffer_ptr = LLVMBuildLoad(builder, vbuffer_ptr, "vbuffer"); diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 28b9044a81e..20f4f3da5f3 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -78,7 +78,10 @@ struct draw_jit_context #define draw_jit_vbuffer_stride(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, 0, "stride") -#define draw_jit_vbuffer_offset(_builder, _ptr) \ +#define draw_jit_vbuffer_max_index(_builder, _ptr) \ + lp_build_struct_get(_builder, _ptr, 1, "max_index") + +#define draw_jit_vbuffer_offset(_builder, _ptr) \ lp_build_struct_get(_builder, _ptr, 2, "buffer_offset") -- cgit v1.2.3 From 81ab19de04e623d24cb65ad1ed3b240bce78235b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 26 Apr 2010 00:32:13 +0100 Subject: llvmpipe: Respect pipe_sampler_view::swizzle_r/g/b/a This allows u_sampler_view_default_dx9_template to do its magic on DX9. --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 5 +++ src/gallium/auxiliary/gallivm/lp_bld_sample.h | 8 +++- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 51 +++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index e1b029a879f..195a4953ab1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -77,6 +77,11 @@ lp_sampler_static_state(struct lp_sampler_static_state *state, */ state->format = view->format; + state->swizzle_r = view->swizzle_r; + state->swizzle_g = view->swizzle_g; + state->swizzle_b = view->swizzle_b; + state->swizzle_a = view->swizzle_a; + state->target = texture->target; state->pot_width = util_is_pot(texture->width0); state->pot_height = util_is_pot(texture->height0); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index e2873763857..8ceb20473d5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -54,8 +54,14 @@ struct lp_build_context; */ struct lp_sampler_static_state { - /* pipe_texture's state */ + /* pipe_sampler_view's state */ enum pipe_format format; + unsigned swizzle_r:3; + unsigned swizzle_g:3; + unsigned swizzle_b:3; + unsigned swizzle_a:3; + + /* pipe_texture's state */ unsigned target:3; unsigned pot_width:1; unsigned pot_height:1; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 415346c15fa..54ef921678d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -185,6 +185,53 @@ texture_dims(enum pipe_texture_target tex) } +static LLVMValueRef +lp_build_swizzle_chan_soa(struct lp_type type, + const LLVMValueRef *unswizzled, + enum util_format_swizzle swizzle) +{ + switch (swizzle) { + case PIPE_SWIZZLE_RED: + case PIPE_SWIZZLE_GREEN: + case PIPE_SWIZZLE_BLUE: + case PIPE_SWIZZLE_ALPHA: + return unswizzled[swizzle]; + case PIPE_SWIZZLE_ZERO: + return lp_build_zero(type); + case PIPE_SWIZZLE_ONE: + return lp_build_one(type); + default: + assert(0); + return lp_build_undef(type); + } +} + + +static void +lp_build_swizzle_soa(struct lp_build_sample_context *bld, + LLVMValueRef *texel) +{ + LLVMValueRef unswizzled[4]; + unsigned char swizzles[4]; + unsigned chan; + + for (chan = 0; chan < 4; ++chan) { + unswizzled[chan] = texel[chan]; + } + + swizzles[0] = bld->static_state->swizzle_r; + swizzles[1] = bld->static_state->swizzle_g; + swizzles[2] = bld->static_state->swizzle_b; + swizzles[3] = bld->static_state->swizzle_a; + + for (chan = 0; chan < 4; ++chan) { + unsigned swizzle = swizzles[chan]; + texel[chan] = lp_build_swizzle_chan_soa(bld->texel_type, + unswizzled, swizzle); + } +} + + /** * Generate code to fetch a texel from a texture at int coords (x, y, z). @@ -285,6 +332,8 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, i, j, texel); + lp_build_swizzle_soa(bld, texel); + /* * Note: if we find an app which frequently samples the texture border * we might want to implement a true conditional here to avoid sampling @@ -1954,6 +2003,8 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, lp_build_format_swizzle_soa(bld->format_desc, bld->texel_type, unswizzled, texel); + + lp_build_swizzle_soa(bld, texel); } -- cgit v1.2.3 From 0c572c6828b6a338b07a6860280b3a314a81662e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 01:05:49 +0100 Subject: st_api: Remove st_module The struct st_module isn't needed as it is the same thing as the st_api struct. That is they both represent the API. Instead just use a single function entry point to the the API. --- src/gallium/include/state_tracker/st_api.h | 35 ++++++++-------------- src/gallium/state_trackers/dri/common/dri_st_api.c | 4 +-- src/gallium/state_trackers/egl/common/egl_g3d_st.c | 29 +++++++++--------- src/gallium/state_trackers/es/st_es1.c | 13 ++++---- src/gallium/state_trackers/es/st_es2.c | 14 ++++----- src/gallium/state_trackers/vega/vg_manager.c | 33 ++++++++------------ src/gallium/targets/libgl-xlib/xlib.c | 16 +++++----- src/mesa/state_tracker/st_gl_api.h | 9 ++++++ src/mesa/state_tracker/st_manager.c | 33 ++++++++++---------- 9 files changed, 86 insertions(+), 100 deletions(-) create mode 100644 src/mesa/state_tracker/st_gl_api.h (limited to 'src') diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 8897ff7c259..002d1c6b840 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -42,14 +42,6 @@ * tracker managers. */ -/** - * The entry points of the state trackers. - */ -#define ST_MODULE_OPENGL_SYMBOL "st_module_OpenGL" -#define ST_MODULE_OPENGL_ES1_SYMBOL "st_module_OpenGL_ES1" -#define ST_MODULE_OPENGL_ES2_SYMBOL "st_module_OpenGL_ES2" -#define ST_MODULE_OPENVG_SYMBOL "st_module_OpenVG" - /** * The supported rendering API of a state tracker. */ @@ -378,17 +370,6 @@ struct st_api struct st_context_iface *(*get_current)(struct st_api *stapi); }; -/** - * Represent a state tracker. - * - * This is the entry point of a state tracker. - */ -struct st_module -{ - enum st_api_type api; - struct st_api *(*create_api)(void); -}; - /** * Return true if the visual has the specified buffers. */ @@ -399,9 +380,17 @@ st_visual_have_buffers(const struct st_visual *visual, unsigned mask) } /* these symbols may need to be dynamically lookup up */ -extern PUBLIC const struct st_module st_module_OpenGL; -extern PUBLIC const struct st_module st_module_OpenGL_ES1; -extern PUBLIC const struct st_module st_module_OpenGL_ES2; -extern PUBLIC const struct st_module st_module_OpenVG; +extern PUBLIC struct st_api * st_api_create_OpenGL(void); +extern PUBLIC struct st_api * st_api_create_OpenGL_ES1(void); +extern PUBLIC struct st_api * st_api_create_OpenGL_ES2(void); +extern PUBLIC struct st_api * st_api_create_OpenVG(void); + +/** + * The entry points of the state trackers. + */ +#define ST_CREATE_OPENGL_SYMBOL "st_api_create_OpenGL" +#define ST_CREATE_OPENGL_ES1_SYMBOL "st_api_create_OpenGL_ES1" +#define ST_CREATE_OPENGL_ES2_SYMBOL "st_api_create_OpenGL_ES2" +#define ST_CREATE_OPENVG_SYMBOL "st_api_create_OpenVG" #endif /* _ST_API_H_ */ diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index 261bae75a28..f9295cb4ca8 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -30,7 +30,7 @@ #include "util/u_inlines.h" #include "util/u_format.h" #include "util/u_debug.h" -#include "state_tracker/st_manager.h" /* for st_manager_create_api */ +#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */ #include "dri_screen.h" #include "dri_context.h" @@ -208,7 +208,7 @@ _dri_get_st_api(void) { p_atomic_inc(&dri_st_api.refcnt); if (p_atomic_read(&dri_st_api.refcnt) == 1) - dri_st_api.stapi = st_manager_create_api(); + dri_st_api.stapi = st_gl_api_create(); } /** diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c index 57a479f6bca..47ecc503eb7 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -49,41 +49,42 @@ egl_g3d_st_manager(struct st_manager *smapi) struct st_api * egl_g3d_create_st_api(enum st_api_type api) { - const char *stmod_name; struct util_dl_library *lib; - const struct st_module *mod; + const char *proc_name; + struct st_api * (*proc)(void) = NULL; switch (api) { case ST_API_OPENGL: - stmod_name = ST_MODULE_OPENGL_SYMBOL; + proc_name = ST_CREATE_OPENGL_SYMBOL; break; case ST_API_OPENGL_ES1: - stmod_name = ST_MODULE_OPENGL_ES1_SYMBOL; + proc_name = ST_CREATE_OPENGL_ES1_SYMBOL; break; case ST_API_OPENGL_ES2: - stmod_name = ST_MODULE_OPENGL_ES2_SYMBOL; + proc_name = ST_CREATE_OPENGL_ES2_SYMBOL; break; case ST_API_OPENVG: - stmod_name = ST_MODULE_OPENVG_SYMBOL; + proc_name = ST_CREATE_OPENVG_SYMBOL; break; default: - stmod_name = NULL; - break; + assert(!"Unknown API Type\n"); + return NULL; } - if (!stmod_name) + + if (!proc_name) return NULL; - mod = NULL; lib = util_dl_open(NULL); if (lib) { - mod = (const struct st_module *) - util_dl_get_proc_address(lib, stmod_name); + proc = util_dl_get_proc_address(lib, proc_name); + debug_printf("%s: %s %p\n", __func__, proc_name, proc); util_dl_close(lib); } - if (!mod || mod->api != api) + + if (!proc) return NULL; - return mod->create_api(); + return proc(); } static boolean diff --git a/src/gallium/state_trackers/es/st_es1.c b/src/gallium/state_trackers/es/st_es1.c index 4e89e06b34c..825fdac2150 100644 --- a/src/gallium/state_trackers/es/st_es1.c +++ b/src/gallium/state_trackers/es/st_es1.c @@ -1,8 +1,7 @@ -#include "state_tracker/st_manager.h" +#include "state_tracker/st_gl_api.h" -PUBLIC const int st_api_OpenGL_ES1 = 1; - -PUBLIC const struct st_module st_module_OpenGL_ES1 = { - .api = ST_API_OPENGL_ES1, - .create_api = st_manager_create_api -}; +PUBLIC struct st_api * +st_api_create_OpenGL_ES1() +{ + return st_gl_api_create(); +} diff --git a/src/gallium/state_trackers/es/st_es2.c b/src/gallium/state_trackers/es/st_es2.c index 82e88b176ac..5c773aaf93b 100644 --- a/src/gallium/state_trackers/es/st_es2.c +++ b/src/gallium/state_trackers/es/st_es2.c @@ -1,8 +1,8 @@ -#include "state_tracker/st_manager.h" +#include "state_tracker/st_gl_api.h" -PUBLIC const int st_api_OpenGL_ES2 = 1; - -PUBLIC const struct st_module st_module_OpenGL_ES2 = { - .api = ST_API_OPENGL_ES2, - .create_api = st_manager_create_api -}; +PUBLIC struct st_api * +st_api_create_OpenGL_ES2() +{ + /* linker magic creates different versions */ + return st_gl_api_create(); +} diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c index e4226754d13..aecac28e7ee 100644 --- a/src/gallium/state_trackers/vega/vg_manager.c +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -546,26 +546,17 @@ vg_api_destroy(struct st_api *stapi) free(stapi); } -static struct st_api * -vg_module_create_api(void) -{ - struct st_api *stapi; - - stapi = CALLOC_STRUCT(st_api); - if (stapi) { - stapi->destroy = vg_api_destroy; - stapi->get_proc_address = vg_api_get_proc_address; - stapi->is_visual_supported = vg_api_is_visual_supported; - - stapi->create_context = vg_api_create_context; - stapi->make_current = vg_api_make_current; - stapi->get_current = vg_api_get_current; - } +struct st_api st_vg_api = { + vg_api_destroy, + vg_api_get_proc_address, + vg_api_is_visual_supported, + vg_api_create_context, + vg_api_make_current, + vg_api_get_current, +}; - return stapi; +struct st_api * +st_api_create_OpenVG(void) +{ + return &st_vg_api; } - -PUBLIC const struct st_module st_module_OpenVG = { - .api = ST_API_OPENVG, - .create_api = vg_module_create_api, -}; diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 48e5bdff429..69b4ddd33f7 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -36,15 +36,15 @@ #include "state_tracker/xlib_sw_winsys.h" #include "xm_public.h" -#include "state_tracker/st_manager.h" +#include "state_tracker/st_gl_api.h" -/* advertise OpenGL support */ -PUBLIC const int st_api_OpenGL = 1; +/* piggy back on this libGL for OpenGL support in EGL */ +struct st_api * +st_api_create_OpenGL() +{ + return st_gl_api_create(); +} -PUBLIC const struct st_module st_module_OpenGL = { - .api = ST_API_OPENGL, - .create_api = st_manager_create_api -}; /* Helper function to choose and instantiate one of the software rasterizers: * cell, llvmpipe, softpipe. @@ -151,7 +151,7 @@ fail: static struct xm_driver xlib_driver = { .create_pipe_screen = swrast_xlib_create_screen, - .create_st_api = st_manager_create_api, + .create_st_api = st_gl_api_create, }; diff --git a/src/mesa/state_tracker/st_gl_api.h b/src/mesa/state_tracker/st_gl_api.h new file mode 100644 index 00000000000..52c3fa0b417 --- /dev/null +++ b/src/mesa/state_tracker/st_gl_api.h @@ -0,0 +1,9 @@ + +#ifndef ST_GL_API_H +#define ST_GL_API_H + +#include "state_tracker/st_api.h" + +struct st_api * st_gl_api_create(void); + +#endif diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 5cf17fe530a..44d59d44763 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -26,7 +26,7 @@ * Chia-I Wu */ -#include "state_tracker/st_api.h" +#include "state_tracker/st_gl_api.h" #include "pipe/p_context.h" #include "pipe/p_screen.h" @@ -692,7 +692,6 @@ st_api_get_proc_address(struct st_api *stapi, const char *procname) static void st_api_destroy(struct st_api *stapi) { - FREE(stapi); } /** @@ -791,24 +790,22 @@ st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb, return TRUE; } +struct st_api st_gl_api = { + st_api_destroy, + st_api_get_proc_address, + st_api_is_visual_supported, + st_api_create_context, + st_api_make_current, + st_api_get_current, +}; + /** - * Create an st_api to manage the state tracker. + * Return the st_api for this state tracker. This might either be GL, GLES1, + * GLES2 that mostly depends on the build and link options. But these + * functions remain the same either way. */ struct st_api * -st_manager_create_api(void) +st_gl_api_create(void) { - struct st_api *stapi; - - stapi = CALLOC_STRUCT(st_api); - if (stapi) { - stapi->destroy = st_api_destroy; - stapi->get_proc_address = st_api_get_proc_address; - stapi->is_visual_supported = st_api_is_visual_supported; - - stapi->create_context = st_api_create_context; - stapi->make_current = st_api_make_current; - stapi->get_current = st_api_get_current; - } - - return stapi; + return &st_gl_api; } -- cgit v1.2.3 From ab12d4f647702f0063c41dd090cef762aa95a0f9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 12:35:56 +0100 Subject: st/dri: Make lookup_egl_image a hook --- src/gallium/state_trackers/dri/common/dri_screen.h | 5 +++++ src/gallium/state_trackers/dri/common/dri_st_api.c | 12 ++++++------ src/gallium/state_trackers/dri/drm/dri2.c | 3 ++- src/gallium/state_trackers/dri/drm/dri2.h | 3 --- 4 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index 8ab7d439191..d84ce1bf48e 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -41,6 +41,8 @@ #include "state_tracker/st_api.h" #include "state_tracker/drm_api.h" +struct dri_context; + struct dri_screen { /* dri */ @@ -55,6 +57,9 @@ struct dri_screen int fd; drmLock *drmLock; + /* hooks filled in by dri1, dri2 & drisw */ + __DRIimage * (*lookup_egl_image)(struct dri_context *ctx, void *handle); + /* gallium */ struct drm_api *api; struct pipe_winsys *pipe_winsys; diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index f9295cb4ca8..cbcb149b0a2 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -229,15 +229,15 @@ static boolean dri_st_manager_get_egl_image(struct st_manager *smapi, struct st_egl_image *stimg) { + struct dri_context *ctx = + (struct dri_context *)stimg->stctxi->st_manager_private; + struct dri_screen *screen = dri_screen(ctx->sPriv); __DRIimage *img = NULL; -#ifndef __NOT_HAVE_DRM_H - if (!__dri1_api_hooks) { - struct dri_context *ctx = (struct dri_context *) - stimg->stctxi->st_manager_private; - img = dri2_lookup_egl_image(ctx, stimg->egl_image); + if (screen->lookup_egl_image) { + img = screen->lookup_egl_image(ctx, stimg->egl_image); } -#endif + if (!img) return FALSE; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 7c84fcfd723..0bf8c83f21f 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -373,7 +373,7 @@ dri2_flush_frontbuffer(struct dri_drawable *drawable, } } -__DRIimage * +static __DRIimage * dri2_lookup_egl_image(struct dri_context *ctx, void *handle) { __DRIimageLookupExtension *loader = ctx->sPriv->dri2.image; @@ -512,6 +512,7 @@ dri2_init_screen(__DRIscreen * sPriv) screen->api = drm_api_create(); screen->sPriv = sPriv; screen->fd = sPriv->fd; + screen->lookup_egl_image = dri2_lookup_egl_image; sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; diff --git a/src/gallium/state_trackers/dri/drm/dri2.h b/src/gallium/state_trackers/dri/drm/dri2.h index 5b28850000b..379963431fb 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.h +++ b/src/gallium/state_trackers/dri/drm/dri2.h @@ -43,7 +43,4 @@ dri2_allocate_textures(struct dri_drawable *drawable, const enum st_attachment_type *statts, unsigned count); -__DRIimage * -dri2_lookup_egl_image(struct dri_context *ctx, void *handle); - #endif /* DRI2_H */ -- cgit v1.2.3 From ea6a52a1f8e7fd72b5506218c31e58088131f1f5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 13:36:09 +0100 Subject: st/dri: Add hooks for framebuffer functions --- .../state_trackers/dri/common/dri_drawable.c | 28 +++++++++++ .../state_trackers/dri/common/dri_drawable.h | 6 +++ src/gallium/state_trackers/dri/common/dri_screen.h | 7 +++ src/gallium/state_trackers/dri/common/dri_st_api.c | 36 +++----------- src/gallium/state_trackers/dri/drm/dri1.c | 49 +++++++------------ src/gallium/state_trackers/dri/drm/dri1.h | 8 --- src/gallium/state_trackers/dri/drm/dri2.c | 6 ++- src/gallium/state_trackers/dri/drm/dri2.h | 9 ---- src/gallium/state_trackers/dri/sw/drisw.c | 57 +++++++++------------- src/gallium/state_trackers/dri/sw/drisw.h | 11 ----- 10 files changed, 94 insertions(+), 123 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c index 88c17e81bfb..6b551ea3f96 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c @@ -90,4 +90,32 @@ dri_destroy_buffer(__DRIdrawable * dPriv) FREE(drawable); } +/** + * Get the format and binding of an attachment. + */ +void +dri_drawable_get_format(struct dri_drawable *drawable, + enum st_attachment_type statt, + enum pipe_format *format, + unsigned *bind) +{ + switch (statt) { + case ST_ATTACHMENT_FRONT_LEFT: + case ST_ATTACHMENT_BACK_LEFT: + case ST_ATTACHMENT_FRONT_RIGHT: + case ST_ATTACHMENT_BACK_RIGHT: + *format = drawable->stvis.color_format; + *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + break; + case ST_ATTACHMENT_DEPTH_STENCIL: + *format = drawable->stvis.depth_stencil_format; + *bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */ + break; + default: + *format = PIPE_FORMAT_NONE; + *bind = 0; + break; + } +} + /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h index 315b7781654..dad218bde29 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.h +++ b/src/gallium/state_trackers/dri/common/dri_drawable.h @@ -84,6 +84,12 @@ dri_create_buffer(__DRIscreen * sPriv, void dri_destroy_buffer(__DRIdrawable * dPriv); +void +dri_drawable_get_format(struct dri_drawable *drawable, + enum st_attachment_type statt, + enum pipe_format *format, + unsigned *bind); + #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index d84ce1bf48e..6e814af615e 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -42,6 +42,7 @@ #include "state_tracker/drm_api.h" struct dri_context; +struct dri_drawable; struct dri_screen { @@ -59,6 +60,12 @@ struct dri_screen /* hooks filled in by dri1, dri2 & drisw */ __DRIimage * (*lookup_egl_image)(struct dri_context *ctx, void *handle); + void (*allocate_textures)(struct dri_drawable *drawable, + const enum st_attachment_type *statts, + unsigned count); + void (*update_drawable_info)(struct dri_drawable *drawable); + void (*flush_frontbuffer)(struct dri_drawable *drawable, + enum st_attachment_type statt); /* gallium */ struct drm_api *api; diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index cbcb149b0a2..9702acea5c8 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -36,12 +36,6 @@ #include "dri_context.h" #include "dri_drawable.h" #include "dri_st_api.h" -#ifndef __NOT_HAVE_DRM_H -#include "dri1.h" -#include "dri2.h" -#else -#include "drisw.h" -#endif static boolean dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, @@ -51,6 +45,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, { struct dri_drawable *drawable = (struct dri_drawable *) stfbi->st_manager_private; + struct dri_screen *screen = dri_screen(drawable->sPriv); unsigned statt_mask, new_mask; boolean new_stamp; int i; @@ -70,20 +65,10 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp); if (new_stamp || new_mask) { + if (new_stamp && screen->update_drawable_info) + screen->update_drawable_info(drawable); -#ifndef __NOT_HAVE_DRM_H - if (__dri1_api_hooks) { - dri1_allocate_textures(drawable, statt_mask); - } - else { - dri2_allocate_textures(drawable, statts, count); - } -#else - if (new_stamp) - drisw_update_drawable_info(drawable); - - drisw_allocate_textures(drawable, statt_mask); -#endif + screen->allocate_textures(drawable, statts, count); /* add existing textures */ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { @@ -112,17 +97,10 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, { struct dri_drawable *drawable = (struct dri_drawable *) stfbi->st_manager_private; + struct dri_screen *screen = dri_screen(drawable->sPriv); -#ifndef __NOT_HAVE_DRM_H - if (__dri1_api_hooks) { - dri1_flush_frontbuffer(drawable, statt); - } - else { - dri2_flush_frontbuffer(drawable, statt); - } -#else - drisw_flush_frontbuffer(drawable, statt); -#endif + /* XXX remove this and just set the correct one on the framebuffer */ + screen->flush_frontbuffer(drawable, statt); return TRUE; } diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index e216e46a87e..0be5fb5d8da 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -253,7 +253,7 @@ dri1_copy_to_front(struct dri_context *ctx, * Backend functions for st_framebuffer interface and swap_buffers. */ -void +static void dri1_flush_frontbuffer(struct dri_drawable *draw, enum st_attachment_type statt) { @@ -342,9 +342,10 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) * as they are requested. Unused attachments are not removed, not until the * framebuffer is resized or destroyed. */ -void +static void dri1_allocate_textures(struct dri_drawable *drawable, - unsigned mask) + const enum st_attachment_type *statts, + unsigned count) { struct dri_screen *screen = dri_screen(drawable->sPriv); struct pipe_resource templ; @@ -371,40 +372,24 @@ dri1_allocate_textures(struct dri_drawable *drawable, templ.depth0 = 1; templ.last_level = 0; - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + for (i = 0; i < count; i++) { enum pipe_format format; - unsigned tex_usage; + unsigned bind; - /* the texture already exists or not requested */ - if (drawable->textures[i] || !(mask & (1 << i))) { + /* the texture already exists */ + if (drawable->textures[statts[i]]) continue; - } - switch (i) { - case ST_ATTACHMENT_FRONT_LEFT: - case ST_ATTACHMENT_BACK_LEFT: - case ST_ATTACHMENT_FRONT_RIGHT: - case ST_ATTACHMENT_BACK_RIGHT: - format = drawable->stvis.color_format; - tex_usage = PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_RENDER_TARGET; - break; - case ST_ATTACHMENT_DEPTH_STENCIL: - format = drawable->stvis.depth_stencil_format; - tex_usage = PIPE_BIND_DEPTH_STENCIL; - break; - default: - format = PIPE_FORMAT_NONE; - break; - } + dri_drawable_get_format(drawable, statts[i], &format, &bind); + + if (format == PIPE_FORMAT_NONE) + continue; - if (format != PIPE_FORMAT_NONE) { - templ.format = format; - templ.bind = tex_usage; + templ.format = format; + templ.bind = bind; - drawable->textures[i] = - screen->pipe_screen->resource_create(screen->pipe_screen, &templ); - } + drawable->textures[statts[i]] = + screen->pipe_screen->resource_create(screen->pipe_screen, &templ); } drawable->old_w = width; @@ -489,6 +474,8 @@ dri1_init_screen(__DRIscreen * sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; screen->drmLock = (drmLock *) & sPriv->pSAREA->lock; + screen->allocate_textures = dri1_allocate_textures; + screen->flush_frontbuffer = dri1_flush_frontbuffer; sPriv->private = (void *)screen; sPriv->extensions = dri1_screen_extensions; diff --git a/src/gallium/state_trackers/dri/drm/dri1.h b/src/gallium/state_trackers/dri/drm/dri1.h index f7441f98abc..a50188b3682 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.h +++ b/src/gallium/state_trackers/dri/drm/dri1.h @@ -43,14 +43,6 @@ extern struct dri1_api *__dri1_api_hooks; const __DRIconfig ** dri1_init_screen(__DRIscreen * sPriv); -void -dri1_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt); - -void -dri1_allocate_textures(struct dri_drawable *drawable, - unsigned mask); - void dri1_swap_buffers(__DRIdrawable * dPriv); void diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 0bf8c83f21f..fa296a874a2 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -346,7 +346,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable, * Backend functions for st_framebuffer interface. */ -void +static void dri2_allocate_textures(struct dri_drawable *drawable, const enum st_attachment_type *statts, unsigned count) @@ -358,7 +358,7 @@ dri2_allocate_textures(struct dri_drawable *drawable, dri2_drawable_process_buffers(drawable, buffers, num_buffers); } -void +static void dri2_flush_frontbuffer(struct dri_drawable *drawable, enum st_attachment_type statt) { @@ -513,6 +513,8 @@ dri2_init_screen(__DRIscreen * sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; screen->lookup_egl_image = dri2_lookup_egl_image; + screen->allocate_textures = dri2_allocate_textures; + screen->flush_frontbuffer = dri2_flush_frontbuffer; sPriv->private = (void *)screen; sPriv->extensions = dri_screen_extensions; diff --git a/src/gallium/state_trackers/dri/drm/dri2.h b/src/gallium/state_trackers/dri/drm/dri2.h index 379963431fb..07adfe4f6c5 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.h +++ b/src/gallium/state_trackers/dri/drm/dri2.h @@ -34,13 +34,4 @@ const __DRIconfig ** dri2_init_screen(__DRIscreen * sPriv); -void -dri2_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt); - -void -dri2_allocate_textures(struct dri_drawable *drawable, - const enum st_attachment_type *statts, - unsigned count); - #endif /* DRI2_H */ diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 9edddf01b57..a7f16dc6929 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -70,7 +70,7 @@ put_image(__DRIdrawable *dPriv, void *data, unsigned width, unsigned height) data, dPriv->loaderPrivate); } -void +static void drisw_update_drawable_info(struct dri_drawable *drawable) { __DRIdrawable *dPriv = drawable->dPriv; @@ -147,7 +147,7 @@ drisw_swap_buffers(__DRIdrawable *dPriv) } } -void +static void drisw_flush_frontbuffer(struct dri_drawable *drawable, enum st_attachment_type statt) { @@ -175,9 +175,10 @@ drisw_flush_frontbuffer(struct dri_drawable *drawable, * seems a better seperation and safer for each DRI version to provide its own * function. */ -void +static void drisw_allocate_textures(struct dri_drawable *drawable, - unsigned mask) + const enum st_attachment_type *statts, + unsigned count) { struct dri_screen *screen = dri_screen(drawable->sPriv); struct pipe_resource templ; @@ -206,38 +207,25 @@ drisw_allocate_textures(struct dri_drawable *drawable, for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { enum pipe_format format; - unsigned tex_usage; + unsigned bind; /* the texture already exists or not requested */ - if (drawable->textures[i] || !(mask & (1 << i))) { + if (drawable->textures[statts[i]]) continue; - } - - switch (i) { - case ST_ATTACHMENT_FRONT_LEFT: - case ST_ATTACHMENT_BACK_LEFT: - case ST_ATTACHMENT_FRONT_RIGHT: - case ST_ATTACHMENT_BACK_RIGHT: - format = drawable->stvis.color_format; - tex_usage = PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_RENDER_TARGET; - break; - case ST_ATTACHMENT_DEPTH_STENCIL: - format = drawable->stvis.depth_stencil_format; - tex_usage = PIPE_BIND_DEPTH_STENCIL; - break; - default: - format = PIPE_FORMAT_NONE; - break; - } - - if (format != PIPE_FORMAT_NONE) { - templ.format = format; - templ.bind = tex_usage; - - drawable->textures[i] = - screen->pipe_screen->resource_create(screen->pipe_screen, &templ); - } + + dri_drawable_get_format(drawable, statts[i], &format, &bind); + + if (statts[i] != ST_ATTACHMENT_DEPTH_STENCIL) + bind |= PIPE_BIND_DISPLAY_TARGET; + + if (format == PIPE_FORMAT_NONE) + continue; + + templ.format = format; + templ.bind = bind; + + drawable->textures[statts[i]] = + screen->pipe_screen->resource_create(screen->pipe_screen, &templ); } drawable->old_w = width; @@ -270,6 +258,9 @@ drisw_init_screen(__DRIscreen * sPriv) screen->api = NULL; /* not needed */ screen->sPriv = sPriv; screen->fd = -1; + screen->allocate_textures = drisw_allocate_textures; + screen->update_drawable_info = drisw_update_drawable_info; + screen->flush_frontbuffer = drisw_flush_frontbuffer; sPriv->private = (void *)screen; sPriv->extensions = drisw_screen_extensions; diff --git a/src/gallium/state_trackers/dri/sw/drisw.h b/src/gallium/state_trackers/dri/sw/drisw.h index c0c874f7326..6c6c891f356 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.h +++ b/src/gallium/state_trackers/dri/sw/drisw.h @@ -38,17 +38,6 @@ const __DRIconfig ** drisw_init_screen(__DRIscreen * sPriv); -void -drisw_update_drawable_info(struct dri_drawable *drawable); - -void -drisw_flush_frontbuffer(struct dri_drawable *drawable, - enum st_attachment_type statt); - -void -drisw_allocate_textures(struct dri_drawable *drawable, - unsigned mask); - void drisw_swap_buffers(__DRIdrawable * dPriv); #endif /* DRISW_H */ -- cgit v1.2.3 From a66b391edf746a5eb0cb4aad1ff2e546df00a11d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 11:08:58 +0100 Subject: st/dri: Make st_manager the base for dri_screen --- .../state_trackers/dri/common/dri_context.c | 15 +++-- .../state_trackers/dri/common/dri_context.h | 2 +- src/gallium/state_trackers/dri/common/dri_screen.c | 6 +- src/gallium/state_trackers/dri/common/dri_screen.h | 6 +- src/gallium/state_trackers/dri/common/dri_st_api.c | 70 ++++------------------ src/gallium/state_trackers/dri/common/dri_st_api.h | 9 +-- src/gallium/state_trackers/dri/drm/dri1.c | 6 +- src/gallium/state_trackers/dri/sw/drisw.c | 6 +- 8 files changed, 35 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c index f14f4130bf4..97e3b0628f1 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.c +++ b/src/gallium/state_trackers/dri/common/dri_context.c @@ -53,9 +53,9 @@ GLboolean dri_create_context(const __GLcontextModes * visual, __DRIcontext * cPriv, void *sharedContextPrivate) { - struct st_api *stapi = dri_get_st_api(); __DRIscreen *sPriv = cPriv->driScreenPriv; struct dri_screen *screen = dri_screen(sPriv); + struct st_api *stapi = screen->st_api; struct dri_context *ctx = NULL; struct st_context_iface *st_share = NULL; struct st_visual stvis; @@ -77,7 +77,7 @@ dri_create_context(const __GLcontextModes * visual, &screen->optionCache, sPriv->myNum, "dri"); dri_fill_st_visual(&stvis, screen, visual); - ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share); + ctx->st = stapi->create_context(stapi, &screen->base, &stvis, st_share); if (ctx->st == NULL) goto fail; ctx->st->st_manager_private = (void *) ctx; @@ -119,7 +119,8 @@ dri_destroy_context(__DRIcontext * cPriv) GLboolean dri_unbind_context(__DRIcontext * cPriv) { - struct st_api *stapi = dri_get_st_api(); + struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); + struct st_api *stapi = screen->st_api; if (cPriv) { struct dri_context *ctx = dri_context(cPriv); @@ -140,7 +141,8 @@ dri_make_current(__DRIcontext * cPriv, __DRIdrawable * driDrawPriv, __DRIdrawable * driReadPriv) { - struct st_api *stapi = dri_get_st_api(); + struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); + struct st_api *stapi = screen->st_api; if (cPriv) { struct dri_context *ctx = dri_context(cPriv); @@ -173,9 +175,10 @@ dri_make_current(__DRIcontext * cPriv, } struct dri_context * -dri_get_current(void) +dri_get_current(__DRIscreen *sPriv) { - struct st_api *stapi = dri_get_st_api(); + struct dri_screen *screen = dri_screen(sPriv); + struct st_api *stapi = screen->st_api; struct st_context_iface *st; st = stapi->get_current(stapi); diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h index 594618874a4..9fe6b581016 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.h +++ b/src/gallium/state_trackers/dri/common/dri_context.h @@ -80,7 +80,7 @@ dri_make_current(__DRIcontext * driContextPriv, __DRIdrawable * driReadPriv); struct dri_context * -dri_get_current(void); +dri_get_current(__DRIscreen * driScreenPriv); boolean dri_create_context(const __GLcontextModes * visual, diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 4bfbc6e80b7..7060107e737 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -304,9 +304,6 @@ dri_destroy_screen_helper(struct dri_screen * screen) { dri1_destroy_pipe_context(screen); - if (screen->smapi) - dri_destroy_st_manager(screen->smapi); - if (screen->pipe_screen) screen->pipe_screen->destroy(screen->pipe_screen); @@ -336,8 +333,7 @@ dri_init_screen_helper(struct dri_screen *screen, return NULL; } - screen->smapi = dri_create_st_manager(screen); - if (!screen->smapi) + if (!dri_init_st_manager(screen)) return NULL; driParseOptionInfo(&screen->optionCache, diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index 6e814af615e..98cb9e75508 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -46,6 +46,10 @@ struct dri_drawable; struct dri_screen { + /* st_api */ + struct st_manager base; + struct st_api *st_api; + /* dri */ __DRIscreen *sPriv; @@ -75,8 +79,6 @@ struct dri_screen boolean sd_depth_bits_last; boolean auto_fake_front; - struct st_manager *smapi; - /* used only by DRI1 */ struct pipe_context *dri1_pipe; }; diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index 9702acea5c8..6c8a7e82abe 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -170,39 +170,6 @@ dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, stfbi->validate(stfbi, statts, count, NULL); } -/** - * Reference counted st_api. - */ -static struct { - int32_t refcnt; - struct st_api *stapi; -} dri_st_api; - -/** - * Add a reference to the st_api of the state tracker. - */ -static void -_dri_get_st_api(void) -{ - p_atomic_inc(&dri_st_api.refcnt); - if (p_atomic_read(&dri_st_api.refcnt) == 1) - dri_st_api.stapi = st_gl_api_create(); -} - -/** - * Remove a reference to the st_api of the state tracker. - */ -static void -_dri_put_st_api(void) -{ - struct st_api *stapi = dri_st_api.stapi; - - if (p_atomic_dec_zero(&dri_st_api.refcnt)) { - stapi->destroy(dri_st_api.stapi); - dri_st_api.stapi = NULL; - } -} - static boolean dri_st_manager_get_egl_image(struct st_manager *smapi, struct st_egl_image *stimg) @@ -231,37 +198,22 @@ dri_st_manager_get_egl_image(struct st_manager *smapi, /** * Create a state tracker manager from the given screen. */ -struct st_manager * -dri_create_st_manager(struct dri_screen *screen) +boolean +dri_init_st_manager(struct dri_screen *screen) { - struct st_manager *smapi; + screen->base.screen = screen->pipe_screen; + screen->base.get_egl_image = dri_st_manager_get_egl_image; + screen->st_api = st_gl_api_create(); - smapi = CALLOC_STRUCT(st_manager); - if (smapi) { - smapi->screen = screen->pipe_screen; - smapi->get_egl_image = dri_st_manager_get_egl_image; - _dri_get_st_api(); - } + if (!screen->st_api) + return FALSE; - return smapi; + return TRUE; } -/** - * Destroy a state tracker manager. - */ void -dri_destroy_st_manager(struct st_manager *smapi) -{ - _dri_put_st_api(); - FREE(smapi); -} - -/** - * Return the st_api of OpenGL state tracker. - */ -struct st_api * -dri_get_st_api(void) +dri_close_st_manager(struct dri_screen *screen) { - assert(dri_st_api.stapi); - return dri_st_api.stapi; + if (screen->st_api && screen->st_api->destroy) + screen->st_api->destroy(screen->st_api); } diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h index 11d86cfbdf7..0a0d43073cb 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.h +++ b/src/gallium/state_trackers/dri/common/dri_st_api.h @@ -43,14 +43,11 @@ struct __DRIimageRec { void *loader_private; }; -struct st_api * -dri_get_st_api(void); - -struct st_manager * -dri_create_st_manager(struct dri_screen *screen); +boolean +dri_init_st_manager(struct dri_screen *screen); void -dri_destroy_st_manager(struct st_manager *smapi); +dri_close_st_manager(struct dri_screen *screen); struct st_framebuffer_iface * dri_create_st_framebuffer(struct dri_drawable *drawable); diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 0be5fb5d8da..3f6f930edef 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -257,7 +257,7 @@ static void dri1_flush_frontbuffer(struct dri_drawable *draw, enum st_attachment_type statt) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(draw->sPriv); struct dri_screen *screen = dri_screen(draw->sPriv); struct pipe_screen *pipe_screen = screen->pipe_screen; struct pipe_fence_handle *dummy_fence; @@ -280,8 +280,8 @@ dri1_flush_frontbuffer(struct dri_drawable *draw, void dri1_swap_buffers(__DRIdrawable * dPriv) { - struct dri_context *ctx = dri_get_current(); struct dri_drawable *draw = dri_drawable(dPriv); + struct dri_context *ctx = dri_get_current(draw->sPriv); struct dri_screen *screen = dri_screen(draw->sPriv); struct pipe_screen *pipe_screen = screen->pipe_screen; struct pipe_fence_handle *fence; @@ -309,7 +309,7 @@ dri1_swap_buffers(__DRIdrawable * dPriv) void dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_screen *screen = dri_screen(dPriv->driScreenPriv); struct pipe_screen *pipe_screen = screen->pipe_screen; struct drm_clip_rect sub_bbox; diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index a7f16dc6929..9bd838e6227 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -105,7 +105,7 @@ drisw_present_texture(__DRIdrawable *dPriv, static INLINE void drisw_invalidate_drawable(__DRIdrawable *dPriv) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_drawable *drawable = dri_drawable(dPriv); drawable->texture_stamp = dPriv->lastStamp - 1; @@ -131,7 +131,7 @@ drisw_copy_to_front(__DRIdrawable * dPriv, void drisw_swap_buffers(__DRIdrawable *dPriv) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_resource *ptex; @@ -151,7 +151,7 @@ static void drisw_flush_frontbuffer(struct dri_drawable *drawable, enum st_attachment_type statt) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(drawable->sPriv); struct pipe_resource *ptex; if (!ctx) -- cgit v1.2.3 From 27779ddad5c61d2fc46367e1556b5e53403c2a97 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 14:05:59 +0100 Subject: st/dri: Make st_framebuffer_iface the base for dri_drawable --- .../state_trackers/dri/common/dri_context.c | 2 +- .../state_trackers/dri/common/dri_drawable.c | 6 ++-- .../state_trackers/dri/common/dri_drawable.h | 7 ++--- src/gallium/state_trackers/dri/common/dri_st_api.c | 34 +++++++--------------- src/gallium/state_trackers/dri/common/dri_st_api.h | 8 ++--- src/gallium/state_trackers/dri/drm/dri1.c | 4 +-- src/gallium/state_trackers/dri/drm/dri2.c | 4 +-- src/gallium/state_trackers/dri/sw/drisw.c | 2 +- 8 files changed, 26 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c index 97e3b0628f1..ba9fe62125d 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.c +++ b/src/gallium/state_trackers/dri/common/dri_context.c @@ -165,7 +165,7 @@ dri_make_current(__DRIcontext * cPriv, read->texture_stamp = driReadPriv->lastStamp - 1; } - stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb); + stapi->make_current(stapi, ctx->st, &draw->base, &read->base); } else { stapi->make_current(stapi, NULL, NULL, NULL); diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c index 6b551ea3f96..a61e7e1b1b4 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c @@ -58,9 +58,7 @@ dri_create_buffer(__DRIscreen * sPriv, goto fail; dri_fill_st_visual(&drawable->stvis, screen, visual); - drawable->stfb = dri_create_st_framebuffer(drawable); - if (drawable->stfb == NULL) - goto fail; + dri_init_st_framebuffer(drawable); drawable->sPriv = sPriv; drawable->dPriv = dPriv; @@ -83,7 +81,7 @@ dri_destroy_buffer(__DRIdrawable * dPriv) dri1_destroy_pipe_surface(drawable); - dri_destroy_st_framebuffer(drawable->stfb); + dri_close_st_framebuffer(drawable); drawable->desired_fences = 0; diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h index dad218bde29..6c54a6953b3 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.h +++ b/src/gallium/state_trackers/dri/common/dri_drawable.h @@ -42,14 +42,13 @@ struct dri_context; struct dri_drawable { + struct st_framebuffer_iface base; + struct st_visual stvis; + /* dri */ __DRIdrawable *dPriv; __DRIscreen *sPriv; - /* gallium */ - struct st_framebuffer_iface *stfb; - struct st_visual stvis; - __DRIbuffer old[8]; unsigned old_num; unsigned old_w; diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c index 6c8a7e82abe..42e0ba020ad 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ b/src/gallium/state_trackers/dri/common/dri_st_api.c @@ -106,38 +106,27 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, } /** - * Create a framebuffer from the given drawable. + * Init a framebuffer from the given drawable. */ -struct st_framebuffer_iface * -dri_create_st_framebuffer(struct dri_drawable *drawable) +void +dri_init_st_framebuffer(struct dri_drawable *drawable) { - struct st_framebuffer_iface *stfbi; - - stfbi = CALLOC_STRUCT(st_framebuffer_iface); - if (stfbi) { - stfbi->visual = &drawable->stvis; - stfbi->flush_front = dri_st_framebuffer_flush_front; - stfbi->validate = dri_st_framebuffer_validate; - stfbi->st_manager_private = (void *) drawable; - } - - return stfbi; + drawable->base.visual = &drawable->stvis; + drawable->base.flush_front = dri_st_framebuffer_flush_front; + drawable->base.validate = dri_st_framebuffer_validate; + drawable->base.st_manager_private = (void *) drawable; } /** * Destroy a framebuffer. */ void -dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) +dri_close_st_framebuffer(struct dri_drawable *drawable) { - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; int i; for (i = 0; i < ST_ATTACHMENT_COUNT; i++) pipe_resource_reference(&drawable->textures[i], NULL); - - FREE(stfbi); } /** @@ -145,11 +134,9 @@ dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi) * exist. */ void -dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, +dri_st_framebuffer_validate_att(struct dri_drawable *drawable, enum st_attachment_type statt) { - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; unsigned i, count = 0; @@ -167,7 +154,8 @@ dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, drawable->texture_stamp = drawable->dPriv->lastStamp - 1; - stfbi->validate(stfbi, statts, count, NULL); + /* this calles into the manager */ + drawable->base.validate(&drawable->base, statts, count, NULL); } static boolean diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h index 0a0d43073cb..8cb9fabd4e4 100644 --- a/src/gallium/state_trackers/dri/common/dri_st_api.h +++ b/src/gallium/state_trackers/dri/common/dri_st_api.h @@ -49,14 +49,14 @@ dri_init_st_manager(struct dri_screen *screen); void dri_close_st_manager(struct dri_screen *screen); -struct st_framebuffer_iface * -dri_create_st_framebuffer(struct dri_drawable *drawable); +void +dri_init_st_framebuffer(struct dri_drawable *drawable); void -dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi); +dri_close_st_framebuffer(struct dri_drawable *drawable); void -dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi, +dri_st_framebuffer_validate_att(struct dri_drawable *drawable, enum st_attachment_type statt); #endif /* _DRI_ST_API_H_ */ diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 3f6f930edef..313195b0967 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -104,13 +104,13 @@ dri1_propagate_drawable_change(struct dri_context *ctx) if (dPriv && draw->texture_stamp != dPriv->lastStamp) { ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); flushed = TRUE; - ctx->st->notify_invalid_framebuffer(ctx->st, draw->stfb); + ctx->st->notify_invalid_framebuffer(ctx->st, &draw->base); } if (rPriv && dPriv != rPriv && read->texture_stamp != rPriv->lastStamp) { if (!flushed) ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - ctx->st->notify_invalid_framebuffer(ctx->st, read->stfb); + ctx->st->notify_invalid_framebuffer(ctx->st, &read->base); } } diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index fa296a874a2..f2d6fc1e5a8 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -61,7 +61,7 @@ dri2_invalidate_drawable(__DRIdrawable *dPriv) drawable->dPriv->lastStamp = *drawable->dPriv->pStamp; if (ctx) - ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb); + ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base); } static const __DRI2flushExtension dri2FlushExtension = { @@ -81,7 +81,7 @@ dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_resource *pt; - dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT); + dri_st_framebuffer_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT); pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 9bd838e6227..c3f88c936ef 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -112,7 +112,7 @@ drisw_invalidate_drawable(__DRIdrawable *dPriv) /* check if swapping currently bound buffer */ if (ctx && ctx->dPriv == dPriv) - ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb); + ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base); } static INLINE void -- cgit v1.2.3 From 1372a8f90dc64350e4ac29dbb8c5feb88bc83cd1 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 24 Apr 2010 14:28:55 +0100 Subject: st/dri: Refactor dri_st_api into other files --- .../state_trackers/dri/common/dri1_helper.c | 10 +- .../state_trackers/dri/common/dri_context.c | 1 - .../state_trackers/dri/common/dri_drawable.c | 111 ++++++++++- .../state_trackers/dri/common/dri_drawable.h | 4 + src/gallium/state_trackers/dri/common/dri_screen.c | 45 ++++- src/gallium/state_trackers/dri/common/dri_screen.h | 11 +- src/gallium/state_trackers/dri/common/dri_st_api.c | 207 --------------------- src/gallium/state_trackers/dri/common/dri_st_api.h | 62 ------ src/gallium/state_trackers/dri/drm/Makefile | 1 - src/gallium/state_trackers/dri/drm/SConscript | 1 - src/gallium/state_trackers/dri/drm/dri1.c | 8 +- src/gallium/state_trackers/dri/drm/dri2.c | 7 +- src/gallium/state_trackers/dri/drm/dri_st_api.c | 1 - src/gallium/state_trackers/dri/sw/Makefile | 1 - src/gallium/state_trackers/dri/sw/SConscript | 1 - src/gallium/state_trackers/dri/sw/dri_st_api.c | 1 - src/gallium/state_trackers/dri/sw/drisw.c | 4 +- 17 files changed, 173 insertions(+), 303 deletions(-) delete mode 100644 src/gallium/state_trackers/dri/common/dri_st_api.c delete mode 100644 src/gallium/state_trackers/dri/common/dri_st_api.h delete mode 120000 src/gallium/state_trackers/dri/drm/dri_st_api.c delete mode 120000 src/gallium/state_trackers/dri/sw/dri_st_api.c (limited to 'src') diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.c b/src/gallium/state_trackers/dri/common/dri1_helper.c index b0dd974a964..f641b41ff8b 100644 --- a/src/gallium/state_trackers/dri/common/dri1_helper.c +++ b/src/gallium/state_trackers/dri/common/dri1_helper.c @@ -42,7 +42,7 @@ struct pipe_fence_handle * dri1_swap_fences_pop_front(struct dri_drawable *draw) { - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_screen *screen = dri_screen(draw->sPriv)->base.screen; struct pipe_fence_handle *fence = NULL; if (draw->cur_fences >= draw->desired_fences) { @@ -58,7 +58,7 @@ void dri1_swap_fences_push_back(struct dri_drawable *draw, struct pipe_fence_handle *fence) { - struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen; + struct pipe_screen *screen = dri_screen(draw->sPriv)->base.screen; if (!fence) return; @@ -74,7 +74,7 @@ dri1_swap_fences_push_back(struct dri_drawable *draw, void dri1_swap_fences_clear(struct dri_drawable *drawable) { - struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_screen *screen = dri_screen(drawable->sPriv)->base.screen; struct pipe_fence_handle *fence; while (drawable->cur_fences) { @@ -86,7 +86,7 @@ dri1_swap_fences_clear(struct dri_drawable *drawable) struct pipe_surface * dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_resource *ptex) { - struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen; + struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->base.screen; struct pipe_surface *psurf = drawable->dri1_surface; if (!psurf || psurf->texture != ptex) { @@ -114,7 +114,7 @@ dri1_get_pipe_context(struct dri_screen *screen) if (!pipe) { screen->dri1_pipe = - screen->pipe_screen->context_create(screen->pipe_screen, NULL); + screen->base.screen->context_create(screen->base.screen, NULL); pipe = screen->dri1_pipe; } diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c index ba9fe62125d..0e5ab5b5198 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.c +++ b/src/gallium/state_trackers/dri/common/dri_context.c @@ -34,7 +34,6 @@ #include "dri_screen.h" #include "dri_drawable.h" #include "dri_context.h" -#include "dri_st_api.h" #include "pipe/p_context.h" #include "state_tracker/st_context.h" diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c index a61e7e1b1b4..25892fc7a76 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c @@ -32,13 +32,82 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" -#include "dri_st_api.h" #include "dri1_helper.h" #include "pipe/p_screen.h" #include "util/u_format.h" #include "util/u_memory.h" +#include "util/u_inlines.h" + +static boolean +dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, + unsigned count, + struct pipe_resource **out) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + struct dri_screen *screen = dri_screen(drawable->sPriv); + unsigned statt_mask, new_mask; + boolean new_stamp; + int i; + + statt_mask = 0x0; + for (i = 0; i < count; i++) + statt_mask |= (1 << statts[i]); + + /* record newly allocated textures */ + new_mask = (statt_mask & ~drawable->texture_mask); + + /* + * dPriv->pStamp is the server stamp. It should be accessed with a lock, at + * least for DRI1. dPriv->lastStamp is the client stamp. It has the value + * of the server stamp when last checked. + */ + new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp); + + if (new_stamp || new_mask) { + if (new_stamp && screen->update_drawable_info) + screen->update_drawable_info(drawable); + + screen->allocate_textures(drawable, statts, count); + + /* add existing textures */ + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + if (drawable->textures[i]) + statt_mask |= (1 << i); + } + + drawable->texture_stamp = drawable->dPriv->lastStamp; + drawable->texture_mask = statt_mask; + } + + if (!out) + return TRUE; + + for (i = 0; i < count; i++) { + out[i] = NULL; + pipe_resource_reference(&out[i], drawable->textures[statts[i]]); + } + + return TRUE; +} + +static boolean +dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, + enum st_attachment_type statt) +{ + struct dri_drawable *drawable = + (struct dri_drawable *) stfbi->st_manager_private; + struct dri_screen *screen = dri_screen(drawable->sPriv); + + /* XXX remove this and just set the correct one on the framebuffer */ + screen->flush_frontbuffer(drawable, statt); + + return TRUE; +} + /** * This is called when we need to set up GL rendering to a new X window. */ @@ -58,7 +127,12 @@ dri_create_buffer(__DRIscreen * sPriv, goto fail; dri_fill_st_visual(&drawable->stvis, screen, visual); - dri_init_st_framebuffer(drawable); + + /* setup the st_framebuffer_iface */ + drawable->base.visual = &drawable->stvis; + drawable->base.flush_front = dri_st_framebuffer_flush_front; + drawable->base.validate = dri_st_framebuffer_validate; + drawable->base.st_manager_private = (void *) drawable; drawable->sPriv = sPriv; drawable->dPriv = dPriv; @@ -76,18 +150,49 @@ void dri_destroy_buffer(__DRIdrawable * dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); + int i; dri1_swap_fences_clear(drawable); dri1_destroy_pipe_surface(drawable); - dri_close_st_framebuffer(drawable); + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) + pipe_resource_reference(&drawable->textures[i], NULL); drawable->desired_fences = 0; FREE(drawable); } +/** + * Validate the texture at an attachment. Allocate the texture if it does not + * exist. + */ +void +dri_drawable_validate_att(struct dri_drawable *drawable, + enum st_attachment_type statt) +{ + enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; + unsigned i, count = 0; + + /* check if buffer already exists */ + if (drawable->texture_mask & (1 << statt)) + return; + + /* make sure DRI2 does not destroy existing buffers */ + for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { + if (drawable->texture_mask & (1 << i)) { + statts[count++] = i; + } + } + statts[count++] = statt; + + drawable->texture_stamp = drawable->dPriv->lastStamp - 1; + + /* this calles into the manager */ + drawable->base.validate(&drawable->base, statts, count, NULL); +} + /** * Get the format and binding of an attachment. */ diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h index 6c54a6953b3..5fd650ac88e 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.h +++ b/src/gallium/state_trackers/dri/common/dri_drawable.h @@ -89,6 +89,10 @@ dri_drawable_get_format(struct dri_drawable *drawable, enum pipe_format *format, unsigned *bind); +void +dri_drawable_validate_att(struct dri_drawable *drawable, + enum st_attachment_type statt); + #endif /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 7060107e737..064c73f54c2 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -38,7 +38,6 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" -#include "dri_st_api.h" #include "dri1_helper.h" #ifndef __NOT_HAVE_DRM_H #include "dri1.h" @@ -50,6 +49,7 @@ #include "util/u_inlines.h" #include "pipe/p_screen.h" #include "pipe/p_format.h" +#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */ #include "util/u_debug.h" @@ -79,7 +79,7 @@ dri_fill_in_modes(struct dri_screen *screen, unsigned depth_buffer_factor; unsigned back_buffer_factor; unsigned msaa_samples_factor; - struct pipe_screen *p_screen = screen->pipe_screen; + struct pipe_screen *p_screen = screen->base.screen; boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8; boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32; @@ -283,6 +283,31 @@ dri_get_swap_info(__DRIdrawable * dPriv, __DRIswapInfo * sInfo) #endif +static boolean +dri_get_egl_image(struct st_manager *smapi, + struct st_egl_image *stimg) +{ + struct dri_context *ctx = + (struct dri_context *)stimg->stctxi->st_manager_private; + struct dri_screen *screen = dri_screen(ctx->sPriv); + __DRIimage *img = NULL; + + if (screen->lookup_egl_image) { + img = screen->lookup_egl_image(ctx, stimg->egl_image); + } + + if (!img) + return FALSE; + + stimg->texture = NULL; + pipe_resource_reference(&stimg->texture, img->texture); + stimg->face = img->face; + stimg->level = img->level; + stimg->zslice = img->zslice; + + return TRUE; +} + static void dri_destroy_option_cache(struct dri_screen * screen) { @@ -304,8 +329,11 @@ dri_destroy_screen_helper(struct dri_screen * screen) { dri1_destroy_pipe_context(screen); - if (screen->pipe_screen) - screen->pipe_screen->destroy(screen->pipe_screen); + if (screen->st_api && screen->st_api->destroy) + screen->st_api->destroy(screen->st_api); + + if (screen->base.screen) + screen->base.screen->destroy(screen->base.screen); dri_destroy_option_cache(screen); } @@ -327,13 +355,16 @@ dri_init_screen_helper(struct dri_screen *screen, struct pipe_screen *pscreen, unsigned pixel_bits) { - screen->pipe_screen = pscreen; - if (!screen->pipe_screen) { + screen->base.screen = pscreen; + if (!screen->base.screen) { debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); return NULL; } - if (!dri_init_st_manager(screen)) + screen->base.get_egl_image = dri_get_egl_image; + screen->st_api = st_gl_api_create(); + + if (!screen->st_api) return NULL; driParseOptionInfo(&screen->optionCache, diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index 98cb9e75508..1740fa8f426 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -73,8 +73,6 @@ struct dri_screen /* gallium */ struct drm_api *api; - struct pipe_winsys *pipe_winsys; - struct pipe_screen *pipe_screen; boolean d_depth_bits_last; boolean sd_depth_bits_last; boolean auto_fake_front; @@ -90,6 +88,15 @@ dri_screen(__DRIscreen * sPriv) return (struct dri_screen *)sPriv->private; } +struct __DRIimageRec { + struct pipe_resource *texture; + unsigned face; + unsigned level; + unsigned zslice; + + void *loader_private; +}; + #ifndef __NOT_HAVE_DRM_H static INLINE boolean diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c deleted file mode 100644 index 42e0ba020ad..00000000000 --- a/src/gallium/state_trackers/dri/common/dri_st_api.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: - * Chia-I Wu - */ - -#include "util/u_memory.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_debug.h" -#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" -#include "dri_st_api.h" - -static boolean -dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, - const enum st_attachment_type *statts, - unsigned count, - struct pipe_resource **out) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; - struct dri_screen *screen = dri_screen(drawable->sPriv); - unsigned statt_mask, new_mask; - boolean new_stamp; - int i; - - statt_mask = 0x0; - for (i = 0; i < count; i++) - statt_mask |= (1 << statts[i]); - - /* record newly allocated textures */ - new_mask = (statt_mask & ~drawable->texture_mask); - - /* - * dPriv->pStamp is the server stamp. It should be accessed with a lock, at - * least for DRI1. dPriv->lastStamp is the client stamp. It has the value - * of the server stamp when last checked. - */ - new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp); - - if (new_stamp || new_mask) { - if (new_stamp && screen->update_drawable_info) - screen->update_drawable_info(drawable); - - screen->allocate_textures(drawable, statts, count); - - /* add existing textures */ - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { - if (drawable->textures[i]) - statt_mask |= (1 << i); - } - - drawable->texture_stamp = drawable->dPriv->lastStamp; - drawable->texture_mask = statt_mask; - } - - if (!out) - return TRUE; - - for (i = 0; i < count; i++) { - out[i] = NULL; - pipe_resource_reference(&out[i], drawable->textures[statts[i]]); - } - - return TRUE; -} - -static boolean -dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, - enum st_attachment_type statt) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi->st_manager_private; - struct dri_screen *screen = dri_screen(drawable->sPriv); - - /* XXX remove this and just set the correct one on the framebuffer */ - screen->flush_frontbuffer(drawable, statt); - - return TRUE; -} - -/** - * Init a framebuffer from the given drawable. - */ -void -dri_init_st_framebuffer(struct dri_drawable *drawable) -{ - drawable->base.visual = &drawable->stvis; - drawable->base.flush_front = dri_st_framebuffer_flush_front; - drawable->base.validate = dri_st_framebuffer_validate; - drawable->base.st_manager_private = (void *) drawable; -} - -/** - * Destroy a framebuffer. - */ -void -dri_close_st_framebuffer(struct dri_drawable *drawable) -{ - int i; - - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) - pipe_resource_reference(&drawable->textures[i], NULL); -} - -/** - * Validate the texture at an attachment. Allocate the texture if it does not - * exist. - */ -void -dri_st_framebuffer_validate_att(struct dri_drawable *drawable, - enum st_attachment_type statt) -{ - enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; - unsigned i, count = 0; - - /* check if buffer already exists */ - if (drawable->texture_mask & (1 << statt)) - return; - - /* make sure DRI2 does not destroy existing buffers */ - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { - if (drawable->texture_mask & (1 << i)) { - statts[count++] = i; - } - } - statts[count++] = statt; - - drawable->texture_stamp = drawable->dPriv->lastStamp - 1; - - /* this calles into the manager */ - drawable->base.validate(&drawable->base, statts, count, NULL); -} - -static boolean -dri_st_manager_get_egl_image(struct st_manager *smapi, - struct st_egl_image *stimg) -{ - struct dri_context *ctx = - (struct dri_context *)stimg->stctxi->st_manager_private; - struct dri_screen *screen = dri_screen(ctx->sPriv); - __DRIimage *img = NULL; - - if (screen->lookup_egl_image) { - img = screen->lookup_egl_image(ctx, stimg->egl_image); - } - - if (!img) - return FALSE; - - stimg->texture = NULL; - pipe_resource_reference(&stimg->texture, img->texture); - stimg->face = img->face; - stimg->level = img->level; - stimg->zslice = img->zslice; - - return TRUE; -} - -/** - * Create a state tracker manager from the given screen. - */ -boolean -dri_init_st_manager(struct dri_screen *screen) -{ - screen->base.screen = screen->pipe_screen; - screen->base.get_egl_image = dri_st_manager_get_egl_image; - screen->st_api = st_gl_api_create(); - - if (!screen->st_api) - return FALSE; - - return TRUE; -} - -void -dri_close_st_manager(struct dri_screen *screen) -{ - if (screen->st_api && screen->st_api->destroy) - screen->st_api->destroy(screen->st_api); -} diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h deleted file mode 100644 index 8cb9fabd4e4..00000000000 --- a/src/gallium/state_trackers/dri/common/dri_st_api.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: - * Chia-I Wu - */ - -#ifndef _DRI_ST_API_H_ -#define _DRI_ST_API_H_ - -#include "state_tracker/st_api.h" - -struct dri_screen; -struct dri_drawable; - -struct __DRIimageRec { - struct pipe_resource *texture; - unsigned face; - unsigned level; - unsigned zslice; - - void *loader_private; -}; - -boolean -dri_init_st_manager(struct dri_screen *screen); - -void -dri_close_st_manager(struct dri_screen *screen); - -void -dri_init_st_framebuffer(struct dri_drawable *drawable); - -void -dri_close_st_framebuffer(struct dri_drawable *drawable); - -void -dri_st_framebuffer_validate_att(struct dri_drawable *drawable, - enum st_attachment_type statt); - -#endif /* _DRI_ST_API_H_ */ diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile index 7a236da0c0f..d9a973e3c3e 100644 --- a/src/gallium/state_trackers/dri/drm/Makefile +++ b/src/gallium/state_trackers/dri/drm/Makefile @@ -16,7 +16,6 @@ C_SOURCES = \ dri_context.c \ dri_screen.c \ dri_drawable.c \ - dri_st_api.c \ dri1_helper.c \ dri1.c \ dri2.c diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript index 1dfaa402f2d..8800b655343 100644 --- a/src/gallium/state_trackers/dri/drm/SConscript +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -20,7 +20,6 @@ if env['dri']: source = [ 'dri_context.c', 'dri_drawable.c', 'dri_screen.c', - 'dri_st_api.c', 'dri1_helper.c', 'dri1.c', 'dri2.c', diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 313195b0967..23c21ed8398 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -259,7 +259,7 @@ dri1_flush_frontbuffer(struct dri_drawable *draw, { struct dri_context *ctx = dri_get_current(draw->sPriv); struct dri_screen *screen = dri_screen(draw->sPriv); - struct pipe_screen *pipe_screen = screen->pipe_screen; + struct pipe_screen *pipe_screen = screen->base.screen; struct pipe_fence_handle *dummy_fence; struct pipe_resource *ptex; @@ -283,7 +283,7 @@ dri1_swap_buffers(__DRIdrawable * dPriv) struct dri_drawable *draw = dri_drawable(dPriv); struct dri_context *ctx = dri_get_current(draw->sPriv); struct dri_screen *screen = dri_screen(draw->sPriv); - struct pipe_screen *pipe_screen = screen->pipe_screen; + struct pipe_screen *pipe_screen = screen->base.screen; struct pipe_fence_handle *fence; struct pipe_resource *ptex; @@ -311,7 +311,7 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) { struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_screen *screen = dri_screen(dPriv->driScreenPriv); - struct pipe_screen *pipe_screen = screen->pipe_screen; + struct pipe_screen *pipe_screen = screen->base.screen; struct drm_clip_rect sub_bbox; struct dri_drawable *draw = dri_drawable(dPriv); struct pipe_fence_handle *dummy_fence; @@ -389,7 +389,7 @@ dri1_allocate_textures(struct dri_drawable *drawable, templ.bind = bind; drawable->textures[statts[i]] = - screen->pipe_screen->resource_create(screen->pipe_screen, &templ); + screen->base.screen->resource_create(screen->base.screen, &templ); } drawable->old_w = width; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index f2d6fc1e5a8..e1216f14c0e 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -38,7 +38,6 @@ #include "dri_screen.h" #include "dri_context.h" #include "dri_drawable.h" -#include "dri_st_api.h" #include "dri2.h" #include "GL/internal/dri_interface.h" @@ -81,7 +80,7 @@ dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_resource *pt; - dri_st_framebuffer_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT); + dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT); pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; @@ -332,7 +331,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable, whandle.stride = buf->pitch; drawable->textures[statt] = - screen->pipe_screen->resource_from_handle(screen->pipe_screen, + screen->base.screen->resource_from_handle(screen->base.screen, &templ, &whandle); } @@ -435,7 +434,7 @@ dri2_create_image_from_name(__DRIcontext *context, whandle.handle = name; whandle.stride = pitch * util_format_get_blocksize(pf); - img->texture = screen->pipe_screen->resource_from_handle(screen->pipe_screen, + img->texture = screen->base.screen->resource_from_handle(screen->base.screen, &templ, &whandle); if (!img->texture) { FREE(img); diff --git a/src/gallium/state_trackers/dri/drm/dri_st_api.c b/src/gallium/state_trackers/dri/drm/dri_st_api.c deleted file mode 120000 index a8f6bd06b09..00000000000 --- a/src/gallium/state_trackers/dri/drm/dri_st_api.c +++ /dev/null @@ -1 +0,0 @@ -../common/dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile index 18d7aabd9f0..c0ae71451b2 100644 --- a/src/gallium/state_trackers/dri/sw/Makefile +++ b/src/gallium/state_trackers/dri/sw/Makefile @@ -19,7 +19,6 @@ C_SOURCES = \ dri_context.c \ dri_screen.c \ dri_drawable.c \ - dri_st_api.c \ dri1_helper.c \ drisw.c diff --git a/src/gallium/state_trackers/dri/sw/SConscript b/src/gallium/state_trackers/dri/sw/SConscript index c97124c8310..6bb282d1a4c 100644 --- a/src/gallium/state_trackers/dri/sw/SConscript +++ b/src/gallium/state_trackers/dri/sw/SConscript @@ -20,7 +20,6 @@ if env['dri']: source = [ 'dri_context.c', 'dri_drawable.c', 'dri_screen.c', - 'dri_st_api.c', 'dri1_helper.c', 'drisw.c', ] diff --git a/src/gallium/state_trackers/dri/sw/dri_st_api.c b/src/gallium/state_trackers/dri/sw/dri_st_api.c deleted file mode 120000 index a8f6bd06b09..00000000000 --- a/src/gallium/state_trackers/dri/sw/dri_st_api.c +++ /dev/null @@ -1 +0,0 @@ -../common/dri_st_api.c \ No newline at end of file diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index c3f88c936ef..dcf645593fb 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -99,7 +99,7 @@ drisw_present_texture(__DRIdrawable *dPriv, if (!psurf) return; - screen->pipe_screen->flush_frontbuffer(screen->pipe_screen, psurf, drawable); + screen->base.screen->flush_frontbuffer(screen->base.screen, psurf, drawable); } static INLINE void @@ -225,7 +225,7 @@ drisw_allocate_textures(struct dri_drawable *drawable, templ.bind = bind; drawable->textures[statts[i]] = - screen->pipe_screen->resource_create(screen->pipe_screen, &templ); + screen->base.screen->resource_create(screen->base.screen, &templ); } drawable->old_w = width; -- cgit v1.2.3 From 78b47c337f584ea940b9a6f1865840b7810289e6 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 25 Apr 2010 21:22:40 -0700 Subject: nvfx: Add missing header. --- src/gallium/drivers/nvfx/nvfx_vbo.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c index 4d7b7f181d8..520bae5aed2 100644 --- a/src/gallium/drivers/nvfx/nvfx_vbo.c +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c @@ -8,6 +8,7 @@ #include "nvfx_resource.h" #include "nouveau/nouveau_channel.h" +#include "nouveau/nouveau_class.h" #include "nouveau/nouveau_pushbuf.h" #include "nouveau/nouveau_util.h" -- cgit v1.2.3 From 210218bb96fce822ad58df6b6fdd41350c6fbdf8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 25 Apr 2010 21:42:19 -0700 Subject: st/wgl: s/st_manager_create_api/st_gl_api_create/ commit 0c572c6828b6a338b07a6860280b3a314a81662e replaced st_manager_create_api with st_gl_api_create. Fixes MSVC build. --- src/gallium/state_trackers/wgl/stw_st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c index f4ea61ed2c6..bcdd82e4f66 100644 --- a/src/gallium/state_trackers/wgl/stw_st.c +++ b/src/gallium/state_trackers/wgl/stw_st.c @@ -27,7 +27,7 @@ #include "util/u_memory.h" #include "util/u_inlines.h" -#include "state_tracker/st_manager.h" /* for st_manager_create_api */ +#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */ #include "stw_st.h" #include "stw_device.h" @@ -308,5 +308,5 @@ stw_st_swap_framebuffer_locked(struct st_framebuffer_iface *stfb) struct st_api * stw_st_create_api(void) { - return st_manager_create_api(); + return st_gl_api_create(); } -- cgit v1.2.3 From d00b2560d590fccdc8d557a91873a1f53ae67f20 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 22 Mar 2010 02:18:51 +0100 Subject: r300g: abort if a vertex buffer offset is not dword-aligned --- src/gallium/drivers/r300/r300_emit.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 19acdaba621..7dc7c1d0efc 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -832,6 +832,15 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) unsigned packet_size = (aos_count * 3 + 1) / 2; CS_LOCALS(r300); + for (i = 0; i < aos_count; i++) { + if ((vbuf[velem[i].vertex_buffer_index].buffer_offset + velem[i].src_offset) % 4 != 0) { + /* XXX We must align the buffer. */ + assert(0); + fprintf(stderr, "r300: Unaligned vertex buffer offsets aren't supported, aborting..\n"); + abort(); + } + } + BEGIN_CS(2 + packet_size + aos_count * 2); OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size); OUT_CS(aos_count); -- cgit v1.2.3 From 824e2afea020fb1afded08141e1b7d1b3ecefd34 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 26 Apr 2010 02:27:03 +0200 Subject: r300g: abort on unsupported vertex formats --- src/gallium/drivers/r300/r300_state_inlines.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 480d0f7c4ae..ca6fc650ed6 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -374,6 +374,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); assert(0); + abort(); } switch (desc->channel[0].type) { @@ -395,6 +396,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); assert(0); + abort(); } break; /* Unsigned ints */ @@ -418,12 +420,14 @@ r300_translate_vertex_data_type(enum pipe_format format) { fprintf(stderr, "r300: desc->channel[0].size == %d\n", desc->channel[0].size); assert(0); + abort(); } break; default: fprintf(stderr, "r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); assert(0); + abort(); } if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) { -- cgit v1.2.3 From 52e591383bdce49cb46a1162aff9632c57e06504 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 26 Apr 2010 01:58:07 +0200 Subject: r300g: allow unaligned vertex formats if the stride is dword-aligned --- src/gallium/drivers/r300/r300_state.c | 38 +++++++++++++++++++++++++-- src/gallium/drivers/r300/r300_state_inlines.h | 12 +++++---- 2 files changed, 43 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 9eb8539a655..e8171e94903 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1271,6 +1271,7 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, { struct r300_vertex_element_state *velems; unsigned i, size; + enum pipe_format *format; assert(count <= PIPE_MAX_ATTRIBS); velems = CALLOC_STRUCT(r300_vertex_element_state); @@ -1281,13 +1282,46 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, if (r300_screen(pipe->screen)->caps.has_tcl) { /* Check if the format is aligned to the size of DWORD. */ for (i = 0; i < count; i++) { - size = util_format_get_blocksize(attribs[i].src_format); + format = &velems->velem[i].src_format; + + /* Replace some formats with their aligned counterparts, + * this is OK because we check for aligned strides too. */ + /* XXX We need X instead of A in the format names. */ + switch (*format) { + case PIPE_FORMAT_R8G8B8_UNORM: + *format = PIPE_FORMAT_R8G8B8X8_UNORM; + continue; + case PIPE_FORMAT_R8G8B8_SNORM: + *format = PIPE_FORMAT_R8G8B8A8_SNORM; + continue; + case PIPE_FORMAT_R8G8B8_USCALED: + *format = PIPE_FORMAT_R8G8B8A8_USCALED; + continue; + case PIPE_FORMAT_R8G8B8_SSCALED: + *format = PIPE_FORMAT_R8G8B8A8_SSCALED; + continue; + case PIPE_FORMAT_R16G16B16_UNORM: + *format = PIPE_FORMAT_R16G16B16A16_UNORM; + continue; + case PIPE_FORMAT_R16G16B16_SNORM: + *format = PIPE_FORMAT_R16G16B16A16_SNORM; + continue; + case PIPE_FORMAT_R16G16B16_USCALED: + *format = PIPE_FORMAT_R16G16B16A16_USCALED; + continue; + case PIPE_FORMAT_R16G16B16_SSCALED: + *format = PIPE_FORMAT_R16G16B16A16_SSCALED; + continue; + default:; + } + + size = util_format_get_blocksize(*format); if (size % 4 != 0) { /* XXX Shouldn't we align the format? */ fprintf(stderr, "r300_create_vertex_elements_state: " "Unaligned format %s:%i isn't supported\n", - util_format_name(attribs[i].src_format), size); + util_format_name(*format), size); assert(0); abort(); } diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index ca6fc650ed6..c2bff67ccb6 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -443,6 +443,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { static INLINE uint16_t r300_translate_vertex_data_swizzle(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); + unsigned i, swizzle = 0; assert(format); @@ -452,11 +453,12 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { return 0; } - return ((desc->swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) | - (desc->swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) | - (desc->swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) | - (desc->swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) | - (0xf << R300_WRITE_ENA_SHIFT)); + for (i = 0; i < 4; i++) { + swizzle |= + MIN2(desc->swizzle[i], R300_SWIZZLE_SELECT_FP_ONE) << (3*i); + } + + return swizzle | (0xf << R300_WRITE_ENA_SHIFT); } #endif /* R300_STATE_INLINES_H */ -- cgit v1.2.3 From 537d117ed57734d034560cc64fe1bed65a6375e3 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 26 Apr 2010 04:52:28 +0200 Subject: r300g: use the dummy FS shader for shaders with zero instructions --- src/gallium/drivers/r300/r300_fs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 4d61f638530..88303f074cd 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -275,6 +275,14 @@ static void r300_translate_fragment_shader( /* Invoke the compiler */ r3xx_compile_fragment_program(&compiler); + /* Shaders with zero instructions are invalid, + * use the dummy shader instead. */ + if (shader->code.code.r500.inst_end == -1) { + rc_destroy(&compiler.Base); + r300_dummy_fragment_shader(r300, shader); + return; + } + if (compiler.Base.Error) { fprintf(stderr, "r300 FP: Compiler Error:\n%sUsing a dummy shader" " instead.\n", compiler.Base.ErrorMsg); -- cgit v1.2.3 From b9e637e8cf1cba99c138f5ca2d79ae5afefb1020 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 26 Apr 2010 05:04:07 +0200 Subject: r300g: force prefetch for non-indexed vertices --- src/gallium/drivers/r300/r300_emit.c | 4 ++-- src/gallium/drivers/r300/r300_emit.h | 2 +- src/gallium/drivers/r300/r300_reg.h | 2 +- src/gallium/drivers/r300/r300_render.c | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 7dc7c1d0efc..ac3b5b09051 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -823,7 +823,7 @@ void r300_emit_textures_state(struct r300_context *r300, END_CS; } -void r300_emit_aos(struct r300_context* r300, unsigned offset) +void r300_emit_aos(struct r300_context* r300, unsigned offset, boolean indexed) { struct pipe_vertex_buffer *vb1, *vb2, *vbuf = r300->vertex_buffer; struct pipe_vertex_element *velem = r300->velems->velem; @@ -843,7 +843,7 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) BEGIN_CS(2 + packet_size + aos_count * 2); OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size); - OUT_CS(aos_count); + OUT_CS(aos_count | (!indexed ? R300_VC_FORCE_PREFETCH : 0)); for (i = 0; i < aos_count - 1; i += 2) { vb1 = &vbuf[velem[i].vertex_buffer_index]; diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 56f7318cdbe..c3eb195d4e7 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -29,7 +29,7 @@ struct rX00_fragment_program_code; struct r300_vertex_program_code; -void r300_emit_aos(struct r300_context* r300, unsigned offset); +void r300_emit_aos(struct r300_context* r300, unsigned offset, boolean indexed); void r300_emit_blend_state(struct r300_context* r300, unsigned size, void* state); diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index 239f91443f2..675a9317f9c 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -3377,7 +3377,7 @@ enum { * the last block is omitted. */ #define R300_PACKET3_3D_LOAD_VBPNTR 0x00002F00 - +# define R300_VC_FORCE_PREFETCH (1 << 5) # define R300_VBPNTR_SIZE0(x) ((x) >> 2) # define R300_VBPNTR_STRIDE0(x) (((x) >> 2) << 8) # define R300_VBPNTR_SIZE1(x) (((x) >> 2) << 16) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 23b61df89cc..8e2acc4ac32 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -574,7 +574,7 @@ void r300_draw_range_elements(struct pipe_context* pipe, r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); r300_emit_buffer_validate(r300, TRUE, indexBuffer); r300_emit_dirty_state(r300); - r300_emit_aos(r300, 0); + r300_emit_aos(r300, 0, TRUE); u_upload_flush(r300->upload_vb); u_upload_flush(r300->upload_ib); @@ -595,7 +595,7 @@ void r300_draw_range_elements(struct pipe_context* pipe, if (count && r300_reserve_cs_space(r300, 16)) { r300_emit_buffer_validate(r300, TRUE, indexBuffer); r300_emit_dirty_state(r300); - r300_emit_aos(r300, 0); + r300_emit_aos(r300, 0, TRUE); } } while (count); } @@ -650,12 +650,12 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, r300_emit_dirty_state(r300); if (alt_num_verts || count <= 65535) { - r300_emit_aos(r300, start); + r300_emit_aos(r300, start, FALSE); r300->emit_draw_arrays(r300, mode, count); } else { do { short_count = MIN2(count, 65535); - r300_emit_aos(r300, start); + r300_emit_aos(r300, start, FALSE); r300->emit_draw_arrays(r300, mode, short_count); start += short_count; -- cgit v1.2.3 From 2579fe4044012a552c8be222ffae76b48de13592 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 26 Apr 2010 06:29:10 +0200 Subject: r300g: emit MSPOS regs --- src/gallium/drivers/r300/r300_state_invariant.c | 14 ++++++++------ src/gallium/drivers/r300/r300_texture.c | 4 ++-- src/gallium/drivers/r300/r300_winsys.h | 2 +- src/gallium/winsys/radeon/drm/radeon_drm.c | 4 ++-- src/gallium/winsys/radeon/drm/radeon_r300.c | 4 ++-- src/gallium/winsys/radeon/drm/radeon_winsys.h | 8 ++++++-- 6 files changed, 21 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 64d1d18b454..cd9443fa260 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -43,15 +43,17 @@ void r300_emit_invariant_state(struct r300_context* r300, { CS_LOCALS(r300); + if (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) { + /* Subpixel multisampling for AA. */ + BEGIN_CS(4); + OUT_CS_REG(R300_GB_MSPOS0, 0x66666666); + OUT_CS_REG(R300_GB_MSPOS1, 0x6666666); + END_CS; + } + BEGIN_CS(12 + (r300->screen->caps.has_tcl ? 2 : 0)); /*** Graphics Backend (GB) ***/ - /* Subpixel multisampling for AA - * These are commented out because glisse's CS checker doesn't like them. - * I presume these will be re-enabled later. - * OUT_CS_REG(R300_GB_MSPOS0, 0x66666666); - * OUT_CS_REG(R300_GB_MSPOS1, 0x6666666); - */ /* Source of fog depth */ OUT_CS_REG(R300_GB_SELECT, R300_GB_FOG_SELECT_1_1_W); diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 8bebeacf860..cfa61b0b3f6 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -762,12 +762,12 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex, static void r300_texture_3d_fix_mipmapping(struct r300_screen *screen, struct r300_texture *tex) { - /* The kernels <= 2.6.34-rc3 compute the size of mipmapped 3D textures + /* The kernels <= 2.6.34-rc4 compute the size of mipmapped 3D textures * incorrectly. This is a workaround to prevent CS from being rejected. */ unsigned i, size; - if (screen->rws->get_value(screen->rws, R300_VID_TEX3D_MIP_BUG) && + if (screen->rws->get_value(screen->rws, R300_VID_DRM_2_3_0) && tex->b.b.target == PIPE_TEXTURE_3D && tex->b.b.last_level > 0) { size = 0; diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 2bd40176d10..fa00a0cba93 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -39,7 +39,7 @@ enum r300_value_id { R300_VID_GB_PIPES, R300_VID_Z_PIPES, R300_VID_SQUARE_TILING_SUPPORT, - R300_VID_TEX3D_MIP_BUG, + R300_VID_DRM_2_3_0, }; enum r300_reference_domain { /* bitfield */ diff --git a/src/gallium/winsys/radeon/drm/radeon_drm.c b/src/gallium/winsys/radeon/drm/radeon_drm.c index 8c22738004e..8d981b22e3d 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm.c @@ -100,8 +100,8 @@ static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys) version->version_minor >= 1; #endif - /* XXX */ - winsys->tex3d_mip_bug = TRUE; + winsys->drm_2_3_0 = version->version_major > 2 || + version->version_minor >= 3; info.request = RADEON_INFO_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c index 2fcf7cf9821..90675ada968 100644 --- a/src/gallium/winsys/radeon/drm/radeon_r300.c +++ b/src/gallium/winsys/radeon/drm/radeon_r300.c @@ -265,8 +265,8 @@ static uint32_t radeon_get_value(struct r300_winsys_screen *rws, return ws->z_pipes; case R300_VID_SQUARE_TILING_SUPPORT: return ws->squaretiling; - case R300_VID_TEX3D_MIP_BUG: - return ws->tex3d_mip_bug; + case R300_VID_DRM_2_3_0: + return ws->drm_2_3_0; } return 0; } diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h index 396f258c312..ca789be8e93 100644 --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h @@ -60,8 +60,12 @@ struct radeon_libdrm_winsys { /* Square tiling support. */ boolean squaretiling; - /* Square tiling support. */ - boolean tex3d_mip_bug; + /* DRM 2.3.0 + * - R500 VAP regs + * - MSPOS regs + * - Fixed texture 3D size calculation + */ + boolean drm_2_3_0; /* DRM FD */ int fd; -- cgit v1.2.3 From 54bcee1e40aae9dee750f901f85fd08706bd9321 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 26 Apr 2010 06:35:21 +0200 Subject: r300g: support rendering more than 65535 vertices in one batch on r500 and disable batch splitting on these chipsets. --- src/gallium/drivers/r300/r300_render.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 8e2acc4ac32..5c3380d9c1b 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -41,9 +41,6 @@ #include "r300_render.h" #include "r300_state_derived.h" -/* XXX The DRM rejects VAP_ALT_NUM_VERTICES.. */ -//#define ENABLE_ALT_NUM_VERTS - static uint32_t r300_translate_primitive(unsigned prim) { switch (prim) { @@ -265,11 +262,7 @@ void r500_emit_draw_arrays(struct r300_context *r300, unsigned mode, unsigned count) { -#if defined(ENABLE_ALT_NUM_VERTS) boolean alt_num_verts = count > 65535; -#else - boolean alt_num_verts = FALSE; -#endif CS_LOCALS(r300); if (alt_num_verts) { @@ -307,11 +300,7 @@ void r500_emit_draw_elements(struct r300_context *r300, { uint32_t count_dwords; uint32_t offset_dwords = indexSize * start / sizeof(uint32_t); -#if defined(ENABLE_ALT_NUM_VERTS) boolean alt_num_verts = count > 65535; -#else - boolean alt_num_verts = FALSE; -#endif CS_LOCALS(r300); if (count >= (1 << 24)) { @@ -541,12 +530,9 @@ void r300_draw_range_elements(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); struct pipe_resource* orgIndexBuffer = indexBuffer; -#if defined(ENABLE_ALT_NUM_VERTS) boolean alt_num_verts = r300->screen->caps.is_r500 && - count > 65536; -#else - boolean alt_num_verts = FALSE; -#endif + count > 65536 && + r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0); unsigned short_count; if (r300->skip_rendering) { @@ -622,12 +608,9 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, unsigned start, unsigned count) { struct r300_context* r300 = r300_context(pipe); -#if defined(ENABLE_ALT_NUM_VERTS) boolean alt_num_verts = r300->screen->caps.is_r500 && - count > 65536; -#else - boolean alt_num_verts = FALSE; -#endif + count > 65536 && + r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0); unsigned short_count; if (r300->skip_rendering) { -- cgit v1.2.3 From 671f1e1229877d459cfd76e2cf5ea89c8d881036 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 26 Apr 2010 07:08:59 +0200 Subject: r300g: support index bias on r500 and DRM 2.3.0 --- src/gallium/drivers/r300/r300_render.c | 53 +++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 5c3380d9c1b..b95a24a5bf0 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -166,6 +166,24 @@ static boolean immd_is_good_idea(struct r300_context *r300, * after resolving fallback issues (e.g. stencil ref two-sided). * ****************************************************************************/ +static boolean r500_emit_index_offset(struct r300_context *r300, int indexBias) +{ + CS_LOCALS(r300); + + if (r300->screen->caps.is_r500 && + r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) { + BEGIN_CS(2); + OUT_CS_REG(R500_VAP_INDEX_OFFSET, + (indexBias & 0xFFFFFF) | (indexBias < 0 ? 1<<24 : 0)); + END_CS; + } else { + if (indexBias) + return FALSE; /* Can't do anything :( */ + } + + return TRUE; +} + void r500_emit_draw_arrays_immediate(struct r300_context *r300, unsigned mode, unsigned start, @@ -221,6 +239,8 @@ void r500_emit_draw_arrays_immediate(struct r300_context *r300, r300_emit_buffer_validate(r300, FALSE, NULL); r300_emit_dirty_state(r300); + r500_emit_index_offset(r300, 0); + BEGIN_CS(dwords); OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); @@ -265,16 +285,17 @@ void r500_emit_draw_arrays(struct r300_context *r300, boolean alt_num_verts = count > 65535; CS_LOCALS(r300); + if (count >= (1 << 24)) { + fprintf(stderr, "r300: Got a huge number of vertices: %i, " + "refusing to render.\n", count); + return; + } + + r500_emit_index_offset(r300, 0); + + BEGIN_CS(7 + (alt_num_verts ? 2 : 0)); if (alt_num_verts) { - if (count >= (1 << 24)) { - fprintf(stderr, "r300: Got a huge number of vertices: %i, " - "refusing to render.\n", count); - return; - } - BEGIN_CS(9); OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count); - } else { - BEGIN_CS(7); } OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); @@ -309,18 +330,20 @@ void r500_emit_draw_elements(struct r300_context *r300, return; } - assert(indexBias == 0); - maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", count, minIndex, maxIndex); + if (!r500_emit_index_offset(r300, indexBias)) { + fprintf(stderr, "r300: Got a non-zero index bias, " + "refusing to render.\n"); + return; + } + + BEGIN_CS(13 + (alt_num_verts ? 2 : 0)); if (alt_num_verts) { - BEGIN_CS(15); OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count); - } else { - BEGIN_CS(13); } OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); @@ -879,6 +902,8 @@ static void r500_render_draw_arrays(struct vbuf_render* render, DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count); + r500_emit_index_offset(r300, 0); + BEGIN_CS(2); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) | @@ -901,6 +926,8 @@ static void r500_render_draw(struct vbuf_render* render, r300_emit_buffer_validate(r300, FALSE, NULL); r300_emit_dirty_state(r300); + r500_emit_index_offset(r300, 0); + BEGIN_CS(dwords); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | -- cgit v1.2.3 From 310ec9a17cbcecfd07be04e286b553ede1e72bd0 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 25 Apr 2010 22:50:23 -0700 Subject: nvfx: Add include path to SCons build. --- src/gallium/drivers/nvfx/SConscript | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/nvfx/SConscript b/src/gallium/drivers/nvfx/SConscript index fac32dace40..7c452acb8b9 100644 --- a/src/gallium/drivers/nvfx/SConscript +++ b/src/gallium/drivers/nvfx/SConscript @@ -2,6 +2,10 @@ Import('*') env = env.Clone() +env.Append(CPPPATH = [ + '#/src/gallium/drivers', +]) + nvfx = env.ConvenienceLibrary( target = 'nvfx', source = [ -- cgit v1.2.3 From 2d1b95477fbf91d90c65f8907dce0556b06db6f0 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 26 Apr 2010 00:19:14 -0700 Subject: et/egl: Remove dead code. proc_name cannot be NULL after the switch statement. proc_name is assigned a value or the function has already returned. --- src/gallium/state_trackers/egl/common/egl_g3d_st.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c index 47ecc503eb7..97445478684 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -71,9 +71,6 @@ egl_g3d_create_st_api(enum st_api_type api) return NULL; } - if (!proc_name) - return NULL; - lib = util_dl_open(NULL); if (lib) { proc = util_dl_get_proc_address(lib, proc_name); -- cgit v1.2.3 From c53142c3f46735f91b2f11308d08fa7e17edbf91 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 26 Apr 2010 00:08:46 -0700 Subject: r300g: Add CS table writing. --- src/gallium/drivers/r300/r300_cs.h | 7 +++++++ src/gallium/drivers/r300/r300_winsys.h | 4 ++++ src/gallium/winsys/radeon/drm/radeon_r300.c | 8 ++++++++ 3 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 456b2ec7b92..96f2825b6d6 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -104,6 +104,13 @@ cs_count--; \ } while (0) +#define OUT_CS_TABLE(values, count) do { \ + if (VERY_VERBOSE_REGISTERS) \ + DBG(cs_context_copy, DBG_CS, "r300: writing table of %d dwords\n", count); \ + cs_winsys->write_cs_table(cs_winsys, values, count); \ + cs_count -= count; \ +} while (0) + #define OUT_CS_BUF_RELOC(bo, offset, rd, wd, flags) do { \ DBG(cs_context_copy, DBG_CS, "r300: writing relocation for buffer %p, offset %d, " \ "domains (%d, %d, %d)\n", \ diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index fa00a0cba93..60c4d18e3a2 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -119,6 +119,10 @@ struct r300_winsys_screen { /* Write a dword to the command buffer. */ void (*write_cs_dword)(struct r300_winsys_screen* winsys, uint32_t dword); + /* Write a table of dwords to the command buffer. */ + void (*write_cs_table)(struct r300_winsys_screen* winsys, + void *dwords, unsigned count); + /* Write a relocated dword to the command buffer. */ void (*write_cs_reloc)(struct r300_winsys_screen *winsys, struct r300_winsys_buffer *buf, diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c index 90675ada968..cab41dba3d5 100644 --- a/src/gallium/winsys/radeon/drm/radeon_r300.c +++ b/src/gallium/winsys/radeon/drm/radeon_r300.c @@ -201,6 +201,13 @@ static void radeon_write_cs_dword(struct r300_winsys_screen *rws, radeon_cs_write_dword(ws->cs, dword); } +static void radeon_write_cs_table(struct r300_winsys_screen *rws, + void *table, unsigned count) +{ + struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws); + radeon_cs_write_table(ws->cs, table, count); +} + static void radeon_write_cs_reloc(struct r300_winsys_screen *rws, struct r300_winsys_buffer *buf, uint32_t rd, @@ -322,6 +329,7 @@ radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws) ws->base.check_cs = radeon_check_cs; ws->base.begin_cs = radeon_begin_cs; ws->base.write_cs_dword = radeon_write_cs_dword; + ws->base.write_cs_table = radeon_write_cs_table; ws->base.write_cs_reloc = radeon_write_cs_reloc; ws->base.end_cs = radeon_end_cs; ws->base.flush_cs = radeon_flush_cs; -- cgit v1.2.3 From 59fcbc0ac5458c14ae2ec783df8736f3e2fe0963 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 26 Apr 2010 00:23:16 -0700 Subject: r300g: Use table CS writing when applicable. I just broke the 2000 fps barrier on glxgears. Yay? --- src/gallium/drivers/r300/r300_emit.c | 48 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index ac3b5b09051..a6716db8dea 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -93,10 +93,7 @@ void r300_emit_clip_state(struct r300_context* r300, R500_PVS_UCP_START : R300_PVS_UCP_START)); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4); for (i = 0; i < 6; i++) { - OUT_CS_32F(clip->ucp[i][0]); - OUT_CS_32F(clip->ucp[i][1]); - OUT_CS_32F(clip->ucp[i][2]); - OUT_CS_32F(clip->ucp[i][3]); + OUT_CS_TABLE(clip->ucp[i], 4); } OUT_CS_REG(R300_VAP_CLIP_CNTL, ((1 << clip->nr) - 1) | R300_PS_UCP_MODE_CLIP_AS_TRIFAN); @@ -244,8 +241,7 @@ void r300_emit_fs(struct r300_context* r300, unsigned size, void *state) OUT_CS_REG(R300_US_CODE_OFFSET, code->code_offset); OUT_CS_REG_SEQ(R300_US_CODE_ADDR_0, 4); - for(i = 0; i < 4; ++i) - OUT_CS(code->code_addr[i]); + OUT_CS_TABLE(code->code_addr, 4); OUT_CS_REG_SEQ(R300_US_ALU_RGB_INST_0, code->alu.length); for (i = 0; i < code->alu.length; i++) @@ -265,8 +261,7 @@ void r300_emit_fs(struct r300_context* r300, unsigned size, void *state) if (code->tex.length) { OUT_CS_REG_SEQ(R300_US_TEX_INST_0, code->tex.length); - for(i = 0; i < code->tex.length; ++i) - OUT_CS(code->tex.inst[i]); + OUT_CS_TABLE(code->tex.inst, code->tex.length); } /* Emit immediates. */ @@ -396,10 +391,7 @@ void r500_emit_fs(struct r300_context* r300, unsigned size, void *state) R500_GA_US_VECTOR_INDEX_TYPE_CONST | (i & R500_GA_US_VECTOR_INDEX_MASK)); OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, 4); - OUT_CS_32F(data[0]); - OUT_CS_32F(data[1]); - OUT_CS_32F(data[2]); - OUT_CS_32F(data[3]); + OUT_CS_TABLE(data, 4); } } } @@ -428,10 +420,7 @@ void r500_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat assert(constants->Constants[i].Type == RC_CONSTANT_EXTERNAL); data = buf->constants[i]; - OUT_CS_32F(data[0]); - OUT_CS_32F(data[1]); - OUT_CS_32F(data[2]); - OUT_CS_32F(data[3]); + OUT_CS_TABLE(data, 4); } END_CS; } @@ -459,10 +448,7 @@ void r500_emit_fs_rc_constant_state(struct r300_context* r300, unsigned size, vo R500_GA_US_VECTOR_INDEX_TYPE_CONST | (i & R500_GA_US_VECTOR_INDEX_MASK)); OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, 4); - OUT_CS_32F(data[0]); - OUT_CS_32F(data[1]); - OUT_CS_32F(data[2]); - OUT_CS_32F(data[3]); + OUT_CS_TABLE(data, 4); } } END_CS; @@ -743,8 +729,8 @@ void r300_emit_rs_block_state(struct r300_context* r300, } else { OUT_CS_REG_SEQ(R300_RS_IP_0, count); } + OUT_CS_TABLE(rs->ip, count); for (i = 0; i < count; i++) { - OUT_CS(rs->ip[i]); DBG(r300, DBG_DRAW, " : ip %d: 0x%08x\n", i, rs->ip[i]); } @@ -757,8 +743,8 @@ void r300_emit_rs_block_state(struct r300_context* r300, } else { OUT_CS_REG_SEQ(R300_RS_INST_0, count); } + OUT_CS_TABLE(rs->inst, count); for (i = 0; i < count; i++) { - OUT_CS(rs->inst[i]); DBG(r300, DBG_DRAW, " : inst %d: 0x%08x\n", i, rs->inst[i]); } @@ -908,14 +894,14 @@ void r300_emit_vertex_stream_state(struct r300_context* r300, BEGIN_CS(size); OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, streams->count); + OUT_CS_TABLE(streams->vap_prog_stream_cntl, streams->count); for (i = 0; i < streams->count; i++) { - OUT_CS(streams->vap_prog_stream_cntl[i]); DBG(r300, DBG_DRAW, " : prog_stream_cntl%d: 0x%08x\n", i, streams->vap_prog_stream_cntl[i]); } OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, streams->count); + OUT_CS_TABLE(streams->vap_prog_stream_cntl_ext, streams->count); for (i = 0; i < streams->count; i++) { - OUT_CS(streams->vap_prog_stream_cntl_ext[i]); DBG(r300, DBG_DRAW, " : prog_stream_cntl_ext%d: 0x%08x\n", i, streams->vap_prog_stream_cntl_ext[i]); } @@ -987,9 +973,7 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, code->length); - for (i = 0; i < code->length; i++) { - OUT_CS(code->body.d[i]); - } + OUT_CS_TABLE(code->body.d, code->length); OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(pvs_num_slots) | R300_PVS_NUM_CNTLRS(pvs_num_controllers) | @@ -1006,10 +990,7 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, imm_count * 4); for (i = imm_first; i < imm_end; i++) { const float *data = vs->code.constants.Constants[i].u.Immediate; - OUT_CS_32F(data[0]); - OUT_CS_32F(data[1]); - OUT_CS_32F(data[2]); - OUT_CS_32F(data[3]); + OUT_CS_TABLE(data, 4); } } END_CS; @@ -1034,10 +1015,7 @@ void r300_emit_vs_constants(struct r300_context* r300, OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, count * 4); for (i = 0; i < count; i++) { const float *data = buf->constants[i]; - OUT_CS_32F(data[0]); - OUT_CS_32F(data[1]); - OUT_CS_32F(data[2]); - OUT_CS_32F(data[3]); + OUT_CS_TABLE(data, 4); } END_CS; } -- cgit v1.2.3 From 31db310be489e1fc83fa3f72366e2e5fdd2a00e7 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 26 Apr 2010 00:25:30 -0700 Subject: os: Check for spurious wakeups in pipe_barrier_wait. The POSIX function pthread_cond_wait can have spurious wakeups when waiting on a condition variable. Add a 64-bit counter that is incremented whenever the barrier becomes full. A woken thread checks the counter. If the counter has not changed then it has been spuriously woken and goes back to sleep. If the counter has changed then it was properly signaled and exits the barrier. Tested on Mac OS X. This patch was based on ideas from Luca Barbieri. --- src/gallium/auxiliary/os/os_thread.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index 07a4268fc0a..c09e8a7a76f 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -302,6 +302,7 @@ static INLINE void pipe_barrier_wait(pipe_barrier *barrier) typedef struct { unsigned count; unsigned waiters; + uint64_t sequence; pipe_mutex mutex; pipe_condvar condvar; } pipe_barrier; @@ -310,6 +311,7 @@ static INLINE void pipe_barrier_init(pipe_barrier *barrier, unsigned count) { barrier->count = count; barrier->waiters = 0; + barrier->sequence = 0; pipe_mutex_init(barrier->mutex); pipe_condvar_init(barrier->condvar); } @@ -329,9 +331,14 @@ static INLINE void pipe_barrier_wait(pipe_barrier *barrier) barrier->waiters++; if (barrier->waiters < barrier->count) { - pipe_condvar_wait(barrier->condvar, barrier->mutex); + uint64_t sequence = barrier->sequence; + + do { + pipe_condvar_wait(barrier->condvar, barrier->mutex); + } while (sequence == barrier->sequence); } else { barrier->waiters = 0; + barrier->sequence++; pipe_condvar_broadcast(barrier->condvar); } -- cgit v1.2.3 From 04a148629f565f556d0b6e7465f8a19921eed7af Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 26 Apr 2010 12:36:39 +0300 Subject: r600: adjust point sprites after 911fa4a4a1 there's no more vp results for point coords so we cannot iterate over vp outputs. Use only Point.CoordReplace[i] --- src/mesa/drivers/dri/r600/r700_fragprog.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.c b/src/mesa/drivers/dri/r600/r700_fragprog.c index 84d51e66069..ee4d2828cff 100644 --- a/src/mesa/drivers/dri/r600/r700_fragprog.c +++ b/src/mesa/drivers/dri/r600/r700_fragprog.c @@ -560,21 +560,22 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx) CLEARbit(r700->SPI_PS_IN_CONTROL_1.u32All, FRONT_FACE_ENA_bit); } - /* see if we need any point_sprite replacements */ - for (i = VERT_RESULT_TEX0; i<= VERT_RESULT_TEX7; i++) + /* see if we need any point_sprite replacements, also increase num_interp + * as there's no vp output for them */ + for (i = FRAG_ATTRIB_TEX0; i<= FRAG_ATTRIB_TEX7; i++) { - if(ctx->Point.CoordReplace[i - VERT_RESULT_TEX0] == GL_TRUE) + if(ctx->Point.CoordReplace[i - FRAG_ATTRIB_TEX0] == GL_TRUE) { + ui++; point_sprite = GL_TRUE; + } } + if( mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC)) + ui++; + if ((mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC)) || point_sprite) { - /* for FRAG_ATTRIB_PNTC we need to increase num_interp */ - if(mesa_fp->Base.InputsRead & (1 << FRAG_ATTRIB_PNTC)) - { - ui++; - SETfield(r700->SPI_PS_IN_CONTROL_0.u32All, ui, NUM_INTERP_shift, NUM_INTERP_mask); - } + SETfield(r700->SPI_PS_IN_CONTROL_0.u32All, ui, NUM_INTERP_shift, NUM_INTERP_mask); SETbit(r700->SPI_INTERP_CONTROL_0.u32All, PNT_SPRITE_ENA_bit); SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_S, PNT_SPRITE_OVRD_X_shift, PNT_SPRITE_OVRD_X_mask); SETfield(r700->SPI_INTERP_CONTROL_0.u32All, SPI_PNT_SPRITE_SEL_T, PNT_SPRITE_OVRD_Y_shift, PNT_SPRITE_OVRD_Y_mask); @@ -669,7 +670,7 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx) for(i=0; i<8; i++) { unBit = 1 << (VERT_RESULT_TEX0 + i); - if(OutputsWritten & unBit) + if((OutputsWritten & unBit) || (ctx->Point.CoordReplace[i] == GL_TRUE)) { ui = pAsm->uiFP_AttributeMap[FRAG_ATTRIB_TEX0 + i]; SETbit(r700->SPI_PS_INPUT_CNTL[ui].u32All, SEL_CENTROID_bit); -- cgit v1.2.3 From 12172071b5f5cb7f475a20ead8a65eb12fa94737 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 26 Apr 2010 13:18:04 +0300 Subject: r600: enable VERT_RESULT_PSIZ - makes point size & attenuation work doc additions: shader export ARRAY_BASE for EXPORT_POS: 60 is position, 61 is misc vec(VS_OUT_MISC_VEC - used here), 62, 63 are clip distance vectors(VS_OUT_CCDIST#) sorry for formating - there seem to be so many different styles in r600 --- src/mesa/drivers/dri/r600/r700_assembler.c | 21 +++++++++++++++++++-- src/mesa/drivers/dri/r600/r700_vertprog.c | 10 ++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 834bcc63e31..0677c54bea1 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -6511,13 +6511,30 @@ GLboolean Process_Vertex_Exports(r700_AssemblerBase *pR700AsmCode, { return GL_FALSE; } + export_starting_index++; + export_count--; + } + unBit = 1 << VERT_RESULT_PSIZ; + if(OutputsWritten & unBit) + { + if( GL_FALSE == Process_Export(pR700AsmCode, + SQ_EXPORT_POS, + export_starting_index, + 1, + pR700AsmCode->ucVP_OutputMap[VERT_RESULT_PSIZ], + GL_FALSE) ) + { + return GL_FALSE; + } export_count--; + } + + pR700AsmCode->cf_last_export_ptr->m_Word1.f.cf_inst = SQ_CF_INST_EXPORT_DONE; - pR700AsmCode->cf_last_export_ptr->m_Word1.f.cf_inst = SQ_CF_INST_EXPORT_DONE; - } pR700AsmCode->number_of_exports = export_count; + export_starting_index = 0; unBit = 1 << VERT_RESULT_COL0; if(OutputsWritten & unBit) diff --git a/src/mesa/drivers/dri/r600/r700_vertprog.c b/src/mesa/drivers/dri/r600/r700_vertprog.c index 05c65164d60..14dd2a5482c 100644 --- a/src/mesa/drivers/dri/r600/r700_vertprog.c +++ b/src/mesa/drivers/dri/r600/r700_vertprog.c @@ -628,6 +628,16 @@ GLboolean r700SetupVertexProgram(GLcontext * ctx) R600_STATECHANGE(context, spi); + if(vp->mesa_program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { + R600_STATECHANGE(context, cl); + SETbit(r700->PA_CL_VS_OUT_CNTL.u32All, USE_VTX_POINT_SIZE_bit); + SETbit(r700->PA_CL_VS_OUT_CNTL.u32All, VS_OUT_MISC_VEC_ENA_bit); + } else if (r700->PA_CL_VS_OUT_CNTL.u32All != 0) { + R600_STATECHANGE(context, cl); + CLEARbit(r700->PA_CL_VS_OUT_CNTL.u32All, USE_VTX_POINT_SIZE_bit); + CLEARbit(r700->PA_CL_VS_OUT_CNTL.u32All, VS_OUT_MISC_VEC_ENA_bit); + } + SETfield(r700->SPI_VS_OUT_CONFIG.u32All, vp->r700Shader.nParamExports ? (vp->r700Shader.nParamExports - 1) : 0, VS_EXPORT_COUNT_shift, VS_EXPORT_COUNT_mask); -- cgit v1.2.3 From bf98d6170851487a94d9c611035cc2f2e807f8b6 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 26 Apr 2010 07:01:27 -0700 Subject: r300g: Add stats debug flag. --- src/gallium/drivers/r300/r300_debug.c | 1 + src/gallium/drivers/r300/r300_screen.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 6e84bf82469..aed0ffeeccb 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -41,6 +41,7 @@ static struct debug_option debug_options[] = { { "anisohq", DBG_ANISOHQ, "High quality anisotropic filtering (for benchmarking)" }, { "notiling", DBG_NO_TILING, "Disable tiling (for benchmarking)" }, { "noimmd", DBG_NO_IMMD, "Disable immediate mode (for benchmarking)" }, + { "stats", DBG_STATS, "Gather statistics (for lulz)" }, { "all", ~0, "Convenience option that enables all debug flags" }, diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 330bd9b36ba..70ea2fe8d92 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -71,6 +71,7 @@ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) { #define DBG_ANISOHQ 0x0000080 #define DBG_NO_TILING 0x0000100 #define DBG_NO_IMMD 0x0000200 +#define DBG_STATS 0x0000400 /*@}*/ static INLINE boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags) -- cgit v1.2.3 From b02f1c86f5bf8b1169776975491c7df929e94e2c Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 26 Apr 2010 07:13:15 -0700 Subject: r300g: Rudimentary stats, printed on exit. Whoo! --- src/gallium/drivers/r300/r300_context.c | 11 +++++++++++ src/gallium/drivers/r300/r300_context.h | 5 +++++ src/gallium/drivers/r300/r300_cs.h | 3 +++ src/gallium/drivers/r300/r300_emit.c | 3 +++ 4 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index deaa03e1f61..43a42490a04 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -41,10 +41,21 @@ static void r300_destroy_context(struct pipe_context* context) { struct r300_context* r300 = r300_context(context); struct r300_query* query, * temp; + struct r300_atom *atom; util_blitter_destroy(r300->blitter); draw_destroy(r300->draw); + /* Print stats, if enabled. */ + if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) { + fprintf(stderr, "r300: Stats for context %p:\n", r300); + fprintf(stderr, " : Flushes: %llu\n", r300->flush_counter); + foreach(atom, &r300->atom_list) { + fprintf(stderr, " : %s: %llu emits\n", + atom->name, atom->counter); + } + } + /* Free the OQ BO. */ context->screen->resource_destroy(context->screen, r300->oqbo); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 1e4fd9e5edd..b6e20591eda 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -45,6 +45,8 @@ struct r300_atom { struct r300_atom *prev, *next; /* Name, for debugging. */ const char* name; + /* Stat counter. */ + uint64_t counter; /* Opaque state. */ void* state; /* Emit the state to the context. */ @@ -435,6 +437,9 @@ struct r300_context { /* upload managers */ struct u_upload_mgr *upload_vb; struct u_upload_mgr *upload_ib; + + /* Stat counter. */ + uint64_t flush_counter; }; /* Convenience cast wrapper. */ diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 96f2825b6d6..996a4f491e7 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -157,6 +157,9 @@ DBG(cs_context_copy, DBG_CS, "r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, \ __FILE__, __LINE__); \ } \ + if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) { \ + r300->flush_counter++; \ + } \ cs_winsys->flush_cs(cs_winsys); \ } while (0) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index a6716db8dea..2816c35fd30 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1187,6 +1187,9 @@ void r300_emit_dirty_state(struct r300_context* r300) foreach(atom, &r300->atom_list) { if (atom->dirty) { atom->emit(r300, atom->size, atom->state); + if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) { + atom->counter++; + } atom->dirty = FALSE; } } -- cgit v1.2.3 From fc431a58dc1446383edc11aec2a0b7de5b363e5e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 26 Apr 2010 14:49:42 +0100 Subject: translate: Take and respect a max_index argument. --- src/gallium/auxiliary/translate/translate.h | 3 ++- src/gallium/auxiliary/translate/translate_generic.c | 19 +++++++++++++------ src/gallium/auxiliary/translate/translate_sse.c | 10 +++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h index 54ed2c1a4be..edd95e07882 100644 --- a/src/gallium/auxiliary/translate/translate.h +++ b/src/gallium/auxiliary/translate/translate.h @@ -76,7 +76,8 @@ struct translate { void (*set_buffer)( struct translate *, unsigned i, const void *ptr, - unsigned stride ); + unsigned stride, + unsigned max_index ); void (PIPE_CDECL *run_elts)( struct translate *, const unsigned *elts, diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index c3ec9ae3f4b..a9272fbb491 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -31,6 +31,7 @@ */ #include "util/u_memory.h" +#include "util/u_math.h" #include "pipe/p_state.h" #include "translate.h" @@ -58,6 +59,7 @@ struct translate_generic { char *input_ptr; unsigned input_stride; + unsigned max_index; } attrib[PIPE_MAX_ATTRIBS]; @@ -588,19 +590,22 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate, for (attr = 0; attr < nr_attrs; attr++) { float data[4]; const char *src; + unsigned index; char *dst = (vert + tg->attrib[attr].output_offset); if (tg->attrib[attr].instance_divisor) { - src = tg->attrib[attr].input_ptr + - tg->attrib[attr].input_stride * - (instance_id / tg->attrib[attr].instance_divisor); + index = instance_id / tg->attrib[attr].instance_divisor; } else { - src = tg->attrib[attr].input_ptr + - tg->attrib[attr].input_stride * elt; + index = elt; } + index = MIN2(index, tg->attrib[attr].max_index); + + src = tg->attrib[attr].input_ptr + + tg->attrib[attr].input_stride * index; + tg->attrib[attr].fetch( src, data ); if (0) debug_printf("vert %d/%d attr %d: %f %f %f %f\n", @@ -670,7 +675,8 @@ static void PIPE_CDECL generic_run( struct translate *translate, static void generic_set_buffer( struct translate *translate, unsigned buf, const void *ptr, - unsigned stride ) + unsigned stride, + unsigned max_index ) { struct translate_generic *tg = translate_generic(translate); unsigned i; @@ -680,6 +686,7 @@ static void generic_set_buffer( struct translate *translate, tg->attrib[i].input_ptr = ((char *)ptr + tg->attrib[i].input_offset); tg->attrib[i].input_stride = stride; + tg->attrib[i].max_index = max_index; } } } diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c index c13e7427387..ef3aa674a34 100644 --- a/src/gallium/auxiliary/translate/translate_sse.c +++ b/src/gallium/auxiliary/translate/translate_sse.c @@ -61,6 +61,7 @@ typedef void (PIPE_CDECL *run_elts_func)( struct translate *translate, struct translate_buffer { const void *base_ptr; unsigned stride; + unsigned max_index; }; struct translate_buffer_varient { @@ -423,6 +424,11 @@ static boolean init_inputs( struct translate_sse *p, } else { x86_mov(p->func, tmp_EAX, elt); } + + /* + * TODO: Respect translate_buffer::max_index. + */ + x86_imul(p->func, tmp_EAX, buf_stride); x86_add(p->func, tmp_EAX, buf_base_ptr); @@ -666,13 +672,15 @@ static boolean build_vertex_emit( struct translate_sse *p, static void translate_sse_set_buffer( struct translate *translate, unsigned buf, const void *ptr, - unsigned stride ) + unsigned stride, + unsigned max_index ) { struct translate_sse *p = (struct translate_sse *)translate; if (buf < p->nr_buffers) { p->buffer[buf].base_ptr = (char *)ptr; p->buffer[buf].stride = stride; + p->buffer[buf].max_index = max_index; } if (0) debug_printf("%s %d/%d: %p %d\n", -- cgit v1.2.3 From 2a30d3d74a0b87f8066659952628ccd072a4e2b0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 26 Apr 2010 14:55:16 +0100 Subject: draw: Pass-through pipe_buffer::max_index to translate. max_index must be observed to prevent crashes due to bad index data. I've been using this patch for some time without regressions. Some places, where we use internal vertex buffer, it is not entirely clear what max_index should be, so passing just ~0 to avoid regressions for now. --- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 4 ++-- src/gallium/auxiliary/draw/draw_pt_emit.c | 10 ++++++---- src/gallium/auxiliary/draw/draw_pt_fetch.c | 9 ++++++--- src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 6 ++++-- src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c | 3 ++- src/gallium/auxiliary/draw/draw_vs.h | 3 ++- src/gallium/auxiliary/draw/draw_vs_varient.c | 18 ++++++++++++------ 7 files changed, 34 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index ee2b8116032..abbf6247ab8 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -137,7 +137,7 @@ emit_vertex( struct vbuf_stage *vbuf, */ /* Note: we really do want data[0] here, not data[pos]: */ - vbuf->translate->set_buffer(vbuf->translate, 0, vertex->data[0], 0); + vbuf->translate->set_buffer(vbuf->translate, 0, vertex->data[0], 0, ~0); vbuf->translate->run(vbuf->translate, 0, 1, 0, vbuf->vertex_ptr); if (0) draw_dump_emitted_vertex(vbuf->vinfo, (uint8_t *)vbuf->vertex_ptr); @@ -271,7 +271,7 @@ vbuf_start_prim( struct vbuf_stage *vbuf, uint prim ) translate_key_sanitize(&hw_key); vbuf->translate = translate_cache_find(vbuf->cache, &hw_key); - vbuf->translate->set_buffer(vbuf->translate, 1, &vbuf->point_size, 0); + vbuf->translate->set_buffer(vbuf->translate, 1, &vbuf->point_size, 0, ~0); } vbuf->point_size = vbuf->stage.draw->rasterizer->point_size; diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c index a7917f54b04..ad48fa39a4f 100644 --- a/src/gallium/auxiliary/draw/draw_pt_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_emit.c @@ -171,12 +171,14 @@ void draw_pt_emit( struct pt_emit *emit, translate->set_buffer(translate, 0, vertex_data, - stride ); + stride, + ~0); translate->set_buffer(translate, 1, &draw->rasterizer->point_size, - 0); + 0, + ~0); translate->run( translate, 0, @@ -232,11 +234,11 @@ void draw_pt_emit_linear(struct pt_emit *emit, goto fail; translate->set_buffer(translate, 0, - vertex_data, stride); + vertex_data, stride, count - 1); translate->set_buffer(translate, 1, &draw->rasterizer->point_size, - 0); + 0, ~0); translate->run(translate, 0, diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 252be5053e4..a1347221b5d 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -149,7 +149,8 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, fetch->translate->set_buffer(fetch->translate, draw->pt.nr_vertex_buffers, &vh, - 0); + 0, + ~0); } } @@ -172,7 +173,8 @@ void draw_pt_fetch_run( struct pt_fetch *fetch, i, ((char *)draw->pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].stride ); + draw->pt.vertex_buffer[i].stride, + draw->pt.vertex_buffer[i].max_index); } translate->run_elts( translate, @@ -198,7 +200,8 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch, i, ((char *)draw->pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].stride ); + draw->pt.vertex_buffer[i].stride, + draw->pt.vertex_buffer[i].max_index); } translate->run( translate, diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index 1994ddf2bcc..d7735bf1ac9 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -168,7 +168,8 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, feme->translate->set_buffer(feme->translate, draw->pt.nr_vertex_buffers, &feme->point_size, - 0); + 0, + ~0); } feme->point_size = draw->rasterizer->point_size; @@ -178,7 +179,8 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, i, ((char *)draw->pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].stride ); + draw->pt.vertex_buffer[i].stride, + draw->pt.vertex_buffer[i].max_index); } *max_vertices = (draw->render->max_vertex_buffer_bytes / diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c index 389e2b105e5..cbb5b6c9605 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c @@ -167,7 +167,8 @@ static void fse_prepare( struct draw_pt_middle_end *middle, i, ((const ubyte *) draw->pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].stride ); + draw->pt.vertex_buffer[i].stride, + draw->pt.vertex_buffer[i].max_index ); } *max_vertices = (draw->render->max_vertex_buffer_bytes / diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h index f49332352b0..efead42335f 100644 --- a/src/gallium/auxiliary/draw/draw_vs.h +++ b/src/gallium/auxiliary/draw/draw_vs.h @@ -80,7 +80,8 @@ struct draw_vs_varient { void (*set_buffer)( struct draw_vs_varient *, unsigned i, const void *ptr, - unsigned stride ); + unsigned stride, + unsigned max_stride ); void (PIPE_CDECL *run_linear)( struct draw_vs_varient *shader, unsigned start, diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c index 5ed706cb4ff..0abd827b615 100644 --- a/src/gallium/auxiliary/draw/draw_vs_varient.c +++ b/src/gallium/auxiliary/draw/draw_vs_varient.c @@ -66,14 +66,16 @@ struct draw_vs_varient_generic { static void vsvg_set_buffer( struct draw_vs_varient *varient, unsigned buffer, const void *ptr, - unsigned stride ) + unsigned stride, + unsigned max_index ) { struct draw_vs_varient_generic *vsvg = (struct draw_vs_varient_generic *)varient; vsvg->fetch->set_buffer(vsvg->fetch, buffer, ptr, - stride); + stride, + max_index ); } @@ -172,12 +174,14 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_varient *varient, vsvg->emit->set_buffer( vsvg->emit, 0, temp_buffer, - temp_vertex_stride ); + temp_vertex_stride, + ~0 ); vsvg->emit->set_buffer( vsvg->emit, 1, &vsvg->draw->rasterizer->point_size, - 0); + 0, + ~0 ); vsvg->emit->run( vsvg->emit, 0, count, @@ -232,12 +236,14 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_varient *varient, vsvg->emit->set_buffer( vsvg->emit, 0, temp_buffer, - temp_vertex_stride ); + temp_vertex_stride, + ~0 ); vsvg->emit->set_buffer( vsvg->emit, 1, &vsvg->draw->rasterizer->point_size, - 0); + 0, + ~0 ); vsvg->emit->run( vsvg->emit, 0, count, -- cgit v1.2.3 From 7fd9e3cfb0c6c639037d17281159270811f5b357 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 26 Apr 2010 14:55:45 +0100 Subject: svga: Pass-through max_index to translate. --- src/gallium/drivers/svga/svga_state_vs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c index a6215c68cbe..5133c70593c 100644 --- a/src/gallium/drivers/svga/svga_state_vs.c +++ b/src/gallium/drivers/svga/svga_state_vs.c @@ -229,7 +229,7 @@ static int update_zero_stride( struct svga_context *svga, translate->set_buffer(translate, vel->vertex_buffer_index, mapped_buffer, - vbuffer->stride); + vbuffer->stride, vbuffer->max_index); translate->run(translate, 0, 1, 0, svga->curr.zero_stride_constants); -- cgit v1.2.3 From 6ecbbc3c056d177174c97ac4d1a57abed3ac3177 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 26 Apr 2010 15:31:37 +0100 Subject: draw: Always use the llvm middle end when available & enabled. --- src/gallium/auxiliary/draw/draw_private.h | 3 ++- src/gallium/auxiliary/draw/draw_pt.c | 37 ++++++++++++++++++------------- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 4bb3282f62c..a2bfb693c09 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -132,6 +132,7 @@ struct draw_context struct draw_pt_middle_end *fetch_emit; struct draw_pt_middle_end *fetch_shade_emit; struct draw_pt_middle_end *general; + struct draw_pt_middle_end *llvm; } middle; struct { @@ -253,8 +254,8 @@ struct draw_context #ifdef HAVE_LLVM LLVMExecutionEngineRef engine; - boolean use_llvm; #endif + void *driver_private; }; diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index c40c25dc3a1..1d9395e06c3 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -97,12 +97,16 @@ draw_pt_arrays(struct draw_context *draw, opt |= PT_SHADE; } - if (opt == 0) - middle = draw->pt.middle.fetch_emit; - else if (opt == PT_SHADE && !draw->pt.no_fse) - middle = draw->pt.middle.fetch_shade_emit; - else - middle = draw->pt.middle.general; + if (draw->pt.middle.llvm) { + middle = draw->pt.middle.llvm; + } else { + if (opt == 0) + middle = draw->pt.middle.fetch_emit; + else if (opt == PT_SHADE && !draw->pt.no_fse) + middle = draw->pt.middle.fetch_shade_emit; + else + middle = draw->pt.middle.general; + } /* Pick the right frontend @@ -148,25 +152,26 @@ boolean draw_pt_init( struct draw_context *draw ) if (!draw->pt.middle.fetch_shade_emit) return FALSE; -#if HAVE_LLVM - draw->use_llvm = debug_get_option_draw_use_llvm(); - if (draw->use_llvm) - draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw ); -#else - draw->pt.middle.general = NULL; -#endif - - if (!draw->pt.middle.general) - draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw ); + draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw ); if (!draw->pt.middle.general) return FALSE; +#if HAVE_LLVM + if (debug_get_option_draw_use_llvm()) + draw->pt.middle.llvm = draw_pt_fetch_pipeline_or_emit_llvm( draw ); +#endif + return TRUE; } void draw_pt_destroy( struct draw_context *draw ) { + if (draw->pt.middle.llvm) { + draw->pt.middle.llvm->destroy( draw->pt.middle.llvm ); + draw->pt.middle.llvm = NULL; + } + if (draw->pt.middle.general) { draw->pt.middle.general->destroy( draw->pt.middle.general ); draw->pt.middle.general = NULL; -- cgit v1.2.3 From 06574e45b418dab1ec106773c92b7d9e5af45c81 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Mon, 26 Apr 2010 17:42:51 +0100 Subject: gallivm: BGNFOR/ENDFOR fallthrough to BGNLOOP/ENDLOOP --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 16741e41c8d..fac90c60064 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1601,11 +1601,7 @@ emit_instruction( break; case TGSI_OPCODE_BGNFOR: - /* deprecated */ - assert(0); - return FALSE; - break; - + /* fall through */ case TGSI_OPCODE_BGNLOOP: lp_exec_bgnloop(&bld->exec_mask); break; @@ -1625,11 +1621,7 @@ emit_instruction( break; case TGSI_OPCODE_ENDFOR: - /* deprecated */ - assert(0); - return FALSE; - break; - + /* fall-through */ case TGSI_OPCODE_ENDLOOP: lp_exec_endloop(&bld->exec_mask); break; -- cgit v1.2.3 From aac2cccccfd701ae8d7ce0813c28c64498d4a076 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 26 Apr 2010 19:50:57 +0200 Subject: gallium: interface changes for multisampling add function to set sample mask, and state for alpha-to-coverage and alpha-to-one. Also make it possible to query for supported sample count with is_msaa_supported(). Use explicit resource_resolve() to resolve a resource. Note that it is illegal to bind a unresolved resource as a sampler view, must be resolved first (as per d3d10 and OGL APIs, binding unresolved resource would mean that special texture fetch functions need to be used which give explicit control over what samples to fetch, which isn't supported yet). Also change surface_fill() and surface_copy() to operate directly on resources. Blits should operate directly on resources, most often state trackers just used get_tex_surface() then did a blit. Note this also means the blit bind flags are gone, if a driver implements this functionality it is expected to handle it for all resources having depth_stencil/render_target/sampler_view bind flags (might even require it for all bind flags?). Might want to introduce quality levels for MSAA later. Might need to revisit this for hw which does instant resolve. --- src/gallium/auxiliary/cso_cache/cso_context.c | 11 ++++++ src/gallium/auxiliary/cso_cache/cso_context.h | 2 ++ src/gallium/docs/source/context.rst | 16 ++++++--- src/gallium/docs/source/screen.rst | 13 +++++-- src/gallium/include/pipe/p_context.h | 51 +++++++++++++++++++-------- src/gallium/include/pipe/p_defines.h | 2 -- src/gallium/include/pipe/p_screen.h | 11 +++++- src/gallium/include/pipe/p_state.h | 2 ++ 8 files changed, 82 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 6d0b4207986..50736f06b32 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -98,6 +98,7 @@ struct cso_context { struct pipe_framebuffer_state fb, fb_saved; struct pipe_viewport_state vp, vp_saved; struct pipe_blend_color blend_color; + unsigned sample_mask sample_mask; struct pipe_stencil_ref stencil_ref, stencil_ref_saved; }; @@ -984,6 +985,16 @@ enum pipe_error cso_set_blend_color(struct cso_context *ctx, return PIPE_OK; } +enum pipe_error cso_set_sample_mask(struct cso_context *ctx, + unsigned sample_mask) +{ + if (ctx->sample_mask != sample_mask) { + ctx->sample_mask = sample_mask; + ctx->pipe->set_sample_mask(ctx->pipe, sample_mask); + } + return PIPE_OK; +} + enum pipe_error cso_set_stencil_ref(struct cso_context *ctx, const struct pipe_stencil_ref *sr) { diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index d6bcb1fe8f7..f0b07f73765 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -159,6 +159,8 @@ void cso_restore_viewport(struct cso_context *cso); enum pipe_error cso_set_blend_color(struct cso_context *cso, const struct pipe_blend_color *bc); +enum pipe_error cso_set_sample_mask(struct cso_context *cso, + unsigned stencil_mask); enum pipe_error cso_set_stencil_ref(struct cso_context *cso, const struct pipe_stencil_ref *sr); diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index c82e681a254..374711b3c5c 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -54,6 +54,7 @@ objects. They all follow simple, one-method binding calls, e.g. * ``set_stencil_ref`` sets the stencil front and back reference values which are used as comparison values in stencil test. * ``set_blend_color`` +* ``set_sample_mask`` * ``set_clip_state`` * ``set_polygon_stipple`` * ``set_scissor_state`` sets the bounds for the scissor test, which culls @@ -255,15 +256,20 @@ Blitting These methods emulate classic blitter controls. They are not guaranteed to be available; if they are set to NULL, then they are not present. -These methods operate directly on ``pipe_surface`` objects, and stand +These methods operate directly on ``pipe_resource`` objects, and stand apart from any 3D state in the context. Blitting functionality may be moved to a separate abstraction at some point in the future. -``surface_fill`` performs a fill operation on a section of a surface. +``resource_fill_region`` performs a fill operation on a section of a resource. -``surface_copy`` blits a region of a surface to a region of another surface, -provided that both surfaces are the same format. The source and destination -may be the same surface, and overlapping blits are permitted. +``resource_copy_region`` blits a region of a subresource of a resource to a +region of another subresource of a resource, provided that both resources have the +same format. The source and destination may be the same resource, and overlapping +blits are permitted. + +``resource_resolve`` resolves a multisampled resource into a non-multisampled +one. Formats and dimensions must match. This function must be present if a driver +supports multisampling. The interfaces to these calls are likely to change to make it easier for a driver to batch multiple blits with the same source and diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index c5815f8939c..2a8f6967ea9 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -128,9 +128,6 @@ resources might be created and handled quite differently. * ``PIPE_BIND_VERTEX_BUFFER``: A vertex buffer. * ``PIPE_BIND_INDEX_BUFFER``: An vertex index/element buffer. * ``PIPE_BIND_CONSTANT_BUFFER``: A buffer of shader constants. -* ``PIPE_BIND_BLIT_SOURCE``: A blit source, as given to surface_copy. -* ``PIPE_BIND_BLIT_DESTINATION``: A blit destination, as given to surface_copy - and surface_fill. * ``PIPE_BIND_TRANSFER_WRITE``: A transfer object which will be written to. * ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from. * ``PIPE_BIND_CUSTOM``: @@ -223,6 +220,16 @@ Determine if a resource in the given format can be used in a specific manner. Returns TRUE if all usages can be satisfied. +is_msaa_supported +^^^^^^^^^^^^^^^^^ + +Determine if a format supports multisampling with a given number of samples. + +**format** the resource format + +**sample_count** the number of samples. Valid query range is 2-32. + +Returns TRUE if sample_count number of samples is supported with this format. .. _resource_create: diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 6f47845f3b8..c38548105ca 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -198,6 +198,9 @@ struct pipe_context { void (*set_stencil_ref)( struct pipe_context *, const struct pipe_stencil_ref * ); + void (*set_sample_mask)( struct pipe_context *, + unsigned sample_mask ); + void (*set_clip_state)( struct pipe_context *, const struct pipe_clip_state * ); @@ -233,32 +236,50 @@ struct pipe_context { /** - * Surface functions + * Resource functions for blit-like functionality * * The pipe driver is allowed to set these functions to NULL, and in that * case, they will not be available. + * If a driver supports multisampling, resource_resolve must be available. */ /*@{*/ /** - * Copy a block of pixels from one surface to another. - * The surfaces must be of the same format. + * Copy a block of pixels from one resource to another. + * The resource must be of the same format. + * Resources with nr_samples > 1 are not allowed. */ - void (*surface_copy)(struct pipe_context *pipe, - struct pipe_surface *dest, - unsigned destx, unsigned desty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, - unsigned width, unsigned height); + void (*resource_copy_region)(struct pipe_context *pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, + unsigned width, unsigned height); /** - * Fill a region of a surface with a constant value. + * Fill a region of a resource with a constant value. + * Resources with nr_samples > 1 are not allowed. */ - void (*surface_fill)(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - unsigned value); + void (*resource_fill_region)(struct pipe_context *pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + struct pipe_box *dstbox, + unsigned srcx, unsigned srcy, unsigned srcz, + unsigned width, unsigned height, + unsigned value); + + /** + * Resolve a multisampled resource into a non-multisampled one. + * Source and destination must have the same size and same format. + */ + void (*resource_resolve)(struct pipe_context *pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + struct pipe_resource *src, + struct pipe_subresource subsrc); + /*@}*/ /** diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 48edfbfcce7..3223e8d844c 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -284,8 +284,6 @@ enum pipe_transfer_usage { #define PIPE_BIND_VERTEX_BUFFER (1 << 3) /* set_vertex_buffers */ #define PIPE_BIND_INDEX_BUFFER (1 << 4) /* draw_elements */ #define PIPE_BIND_CONSTANT_BUFFER (1 << 5) /* set_constant_buffer */ -#define PIPE_BIND_BLIT_SOURCE (1 << 6) /* surface_copy */ -#define PIPE_BIND_BLIT_DESTINATION (1 << 7) /* surface_copy, fill */ #define PIPE_BIND_DISPLAY_TARGET (1 << 8) /* flush_front_buffer */ #define PIPE_BIND_TRANSFER_WRITE (1 << 9) /* get_transfer */ #define PIPE_BIND_TRANSFER_READ (1 << 10) /* get_transfer */ diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index beff1ae8a92..1bad045b162 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -99,9 +99,18 @@ struct pipe_screen { boolean (*is_format_supported)( struct pipe_screen *, enum pipe_format format, enum pipe_texture_target target, - unsigned bindings, + unsigned bindings, unsigned geom_flags ); + /** + * Check if the given pipe_format is supported with a requested + * number of samples for msaa. + * \param sample_count number of samples for multisampling + */ + boolean (*is_msaa_supported)( struct pipe_screen *, + enum pipe_format format, + unsigned sample_count ); + /** * Create a new texture object, using the given template info. */ diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index a504757c472..f9ad07d8f87 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -218,6 +218,8 @@ struct pipe_blend_state unsigned logicop_enable:1; unsigned logicop_func:4; /**< PIPE_LOGICOP_x */ unsigned dither:1; + unsigned alpha_to_coverage:1; + unsigned alpha_to_one:1; struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS]; }; -- cgit v1.2.3 From 9a966b93c03aecac8eb72e6133aa9a2f2c7673f3 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 27 Apr 2010 16:25:50 +0200 Subject: gallium: fix glaring bugs in last commit --- src/gallium/auxiliary/cso_cache/cso_context.c | 2 +- src/gallium/include/pipe/p_context.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 50736f06b32..030683f60f1 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -98,7 +98,7 @@ struct cso_context { struct pipe_framebuffer_state fb, fb_saved; struct pipe_viewport_state vp, vp_saved; struct pipe_blend_color blend_color; - unsigned sample_mask sample_mask; + unsigned sample_mask; struct pipe_stencil_ref stencil_ref, stencil_ref_saved; }; diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index c38548105ca..6ce8ba953a7 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -265,8 +265,7 @@ struct pipe_context { void (*resource_fill_region)(struct pipe_context *pipe, struct pipe_resource *dst, struct pipe_subresource subdst, - struct pipe_box *dstbox, - unsigned srcx, unsigned srcy, unsigned srcz, + unsigned dstx, unsigned dsty, unsigned dstz, unsigned width, unsigned height, unsigned value); -- cgit v1.2.3 From 6272d7632a8d2948e45698d1c75eae8c441c3916 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 20:52:08 +0200 Subject: gallium: another interface change for multisampling due to popular request, use nr_samples parameter in is_format_supported() instead of new is_msaa_supported() query. This makes it easily possible to query if a format with a given sample count is also supported not only as render target, but for sampler views (note that texture sampling from multisampled resources isn't supported yet). It is not quite how dx10 format msaa queries work, but we might need to revisit format queries completely in the future anyway. --- src/gallium/docs/source/screen.rst | 14 +++----------- src/gallium/include/pipe/p_screen.h | 12 ++---------- 2 files changed, 5 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 2a8f6967ea9..5a60ee00a69 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -214,23 +214,15 @@ Determine if a resource in the given format can be used in a specific manner. **target** one of the PIPE_TEXTURE_x flags +**sample_count** the number of samples. 0 and 1 mean no multisampling, +the maximum allowed legal value is 32. + **bindings** is a bitmask of :ref:`PIPE_BIND` flags. **geom_flags** is a bitmask of PIPE_TEXTURE_GEOM_x flags. Returns TRUE if all usages can be satisfied. -is_msaa_supported -^^^^^^^^^^^^^^^^^ - -Determine if a format supports multisampling with a given number of samples. - -**format** the resource format - -**sample_count** the number of samples. Valid query range is 2-32. - -Returns TRUE if sample_count number of samples is supported with this format. - .. _resource_create: resource_create diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 1bad045b162..9cb949a4465 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -89,7 +89,7 @@ struct pipe_screen { struct pipe_context * (*context_create)( struct pipe_screen *, void *priv ); - + /** * Check if the given pipe_format is supported as a texture or * drawing surface. @@ -99,18 +99,10 @@ struct pipe_screen { boolean (*is_format_supported)( struct pipe_screen *, enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned bindings, unsigned geom_flags ); - /** - * Check if the given pipe_format is supported with a requested - * number of samples for msaa. - * \param sample_count number of samples for multisampling - */ - boolean (*is_msaa_supported)( struct pipe_screen *, - enum pipe_format format, - unsigned sample_count ); - /** * Create a new texture object, using the given template info. */ -- cgit v1.2.3 From 379db6a36b32912be8fd8808ceb95ca5cffa7850 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:02:24 +0200 Subject: gallium: clean up resource_copy_region function Previously, surface_copy was said to allow overlapping blits, and it was "optional". However, some state trackers actually assumed it is always present, and quite some code (like in u_blit) assumed overlapping isn't allowed. Hence, resource_copy_region (and in the same spirit, resource_fill_region) is now mandatory, but overlapping blits are no longer allowed. A driver can plug in the cpu fallback util_resource_copy_region if it does not want to provide its own implementation, though this is not optimal. --- src/gallium/docs/source/context.rst | 7 +++---- src/gallium/include/pipe/p_context.h | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 374711b3c5c..ac3c3c7bdbd 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -253,8 +253,7 @@ Resource Busy Queries Blitting ^^^^^^^^ -These methods emulate classic blitter controls. They are not guaranteed to be -available; if they are set to NULL, then they are not present. +These methods emulate classic blitter controls. These methods operate directly on ``pipe_resource`` objects, and stand apart from any 3D state in the context. Blitting functionality may be @@ -264,8 +263,8 @@ moved to a separate abstraction at some point in the future. ``resource_copy_region`` blits a region of a subresource of a resource to a region of another subresource of a resource, provided that both resources have the -same format. The source and destination may be the same resource, and overlapping -blits are permitted. +same format. The source and destination may be the same resource, but overlapping +blits are not permitted. ``resource_resolve`` resolves a multisampled resource into a non-multisampled one. Formats and dimensions must match. This function must be present if a driver diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 6ce8ba953a7..6b729831768 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -238,8 +238,6 @@ struct pipe_context { /** * Resource functions for blit-like functionality * - * The pipe driver is allowed to set these functions to NULL, and in that - * case, they will not be available. * If a driver supports multisampling, resource_resolve must be available. */ /*@{*/ -- cgit v1.2.3 From 815b75705f5e3f0f7db025368da37bb14395de9a Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:15:20 +0200 Subject: gallium/util: adapt util code to interface changes The util blit functions change their interface (apart from some rename) too (in particular util_blit_pixels now also takes a pipe_resource as the src blit argument instead of a surface, as it might just call resource_copy_region). Maybe the blit util code might need a bit more cleanup, it still doesn't feel very clean. In particular it seems that util_blit_pixels_tex should probably disappear, and I think it would be great if the code called by drivers for blitting (u_blitter.c, which isn't really touched by this change) could somehow be merged with the u_blit code. --- src/gallium/auxiliary/util/u_blit.c | 130 +++++++++++++++++------------- src/gallium/auxiliary/util/u_blit.h | 10 ++- src/gallium/auxiliary/util/u_blitter.c | 9 ++- src/gallium/auxiliary/util/u_caps.c | 1 + src/gallium/auxiliary/util/u_clear.h | 23 +++--- src/gallium/auxiliary/util/u_gen_mipmap.c | 2 +- src/gallium/auxiliary/util/u_surface.c | 72 ++++++++--------- src/gallium/auxiliary/util/u_surface.h | 41 +++------- 8 files changed, 145 insertions(+), 143 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index e45310b9bb7..9df5f9a9d26 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -192,7 +192,6 @@ get_next_slot( struct blit_state *ctx ) return ctx->vbuf_slot++ * sizeof ctx->vertices; } - @@ -279,10 +278,11 @@ regions_overlap(int srcX0, int srcY0, */ void util_blit_pixels_writemask(struct blit_state *ctx, - struct pipe_surface *src, - struct pipe_sampler_view *src_sampler_view, + struct pipe_resource *src_tex, + struct pipe_subresource srcsub, int srcX0, int srcY0, int srcX1, int srcY1, + int srcZ0, struct pipe_surface *dst, int dstX0, int dstY0, int dstX1, int dstY1, @@ -292,6 +292,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_sampler_view *sampler_view = NULL; + struct pipe_sampler_view sv_templ; struct pipe_framebuffer_state fb; const int srcW = abs(srcX1 - srcX0); const int srcH = abs(srcY1 - srcY0); @@ -302,13 +303,13 @@ util_blit_pixels_writemask(struct blit_state *ctx, assert(filter == PIPE_TEX_MIPFILTER_NEAREST || filter == PIPE_TEX_MIPFILTER_LINEAR); - assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D, - PIPE_BIND_SAMPLER_VIEW, 0)); - assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, - PIPE_BIND_RENDER_TARGET, 0)); + assert(srcsub.level <= src_tex->last_level); /* do the regions overlap? */ - overlap = util_same_surface(src, dst) && + overlap = src_tex == dst->texture && + dst->face == srcsub.face && + dst->level == srcsub.level && + dst->zslice == srcZ0 && regions_overlap(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1); @@ -317,8 +318,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, * no overlapping. * Filter mode should not matter since there's no stretching. */ - if (pipe->surface_copy && - dst->format == src->format && + if (dst->format == src_tex->format && srcX0 < srcX1 && dstX0 < dstX1 && srcY0 < srcY1 && @@ -326,29 +326,36 @@ util_blit_pixels_writemask(struct blit_state *ctx, (dstX1 - dstX0) == (srcX1 - srcX0) && (dstY1 - dstY0) == (srcY1 - srcY0) && !overlap) { - pipe->surface_copy(pipe, - dst, dstX0, dstY0, /* dest */ - src, srcX0, srcY0, /* src */ - srcW, srcH); /* size */ + struct pipe_subresource subdst; + subdst.face = dst->face; + subdst.level = dst->level; + pipe->resource_copy_region(pipe, + dst->texture, subdst, + dstX0, dstY0, dst->zslice,/* dest */ + src_tex, srcsub, + srcX0, srcY0, srcZ0,/* src */ + srcW, srcH); /* size */ return; } - - assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, - PIPE_BIND_RENDER_TARGET, 0)); + /* Create a temporary texture when src and dest alias or when src - * is anything other than a single-level 2d texture. + * is anything other than a 2d texture. + * XXX should just use appropriate shader to access 1d / 3d slice / cube face, + * much like the u_blitter code does (should be pretty trivial). * * This can still be improved upon. */ - if (util_same_surface(src, dst) || - src->texture->target != PIPE_TEXTURE_2D || - src->texture->last_level != 0) + if ((src_tex == dst->texture && + dst->face == srcsub.face && + dst->level == srcsub.level && + dst->zslice == srcZ0) || + src_tex->target != PIPE_TEXTURE_2D) { struct pipe_resource texTemp; struct pipe_resource *tex; struct pipe_sampler_view sv_templ; - struct pipe_surface *texSurf; + struct pipe_subresource texsub; const int srcLeft = MIN2(srcX0, srcX1); const int srcTop = MIN2(srcY0, srcY1); @@ -369,7 +376,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, /* create temp texture */ memset(&texTemp, 0, sizeof(texTemp)); texTemp.target = PIPE_TEXTURE_2D; - texTemp.format = src->format; + texTemp.format = src_tex->format; texTemp.last_level = 0; texTemp.width0 = srcW; texTemp.height0 = srcH; @@ -380,49 +387,50 @@ util_blit_pixels_writemask(struct blit_state *ctx, if (!tex) return; - u_sampler_view_default_template(&sv_templ, tex, tex->format); - - sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ); - if (!sampler_view) { - pipe_resource_reference(&tex, NULL); - return; - } - - texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, - PIPE_BIND_BLIT_DESTINATION); - + texsub.face = 0; + texsub.level = 0; /* load temp texture */ - if (pipe->surface_copy) { - pipe->surface_copy(pipe, - texSurf, 0, 0, /* dest */ - src, srcLeft, srcTop, /* src */ - srcW, srcH); /* size */ - } else { - util_surface_copy(pipe, FALSE, - texSurf, 0, 0, /* dest */ - src, srcLeft, srcTop, /* src */ - srcW, srcH); /* size */ - } + pipe->resource_copy_region(pipe, + tex, texsub, 0, 0, 0, /* dest */ + src_tex, srcsub, srcLeft, srcTop, srcZ0, /* src */ + srcW, srcH); /* size */ - /* free the surface, update the texture if necessary. - */ - pipe_surface_reference(&texSurf, NULL); s0 = 0.0f; s1 = 1.0f; t0 = 0.0f; t1 = 1.0f; + u_sampler_view_default_template(&sv_templ, tex, tex->format); + sampler_view = pipe->create_sampler_view(pipe, tex, &sv_templ); + + if (!sampler_view) { + pipe_resource_reference(&tex, NULL); + return; + } pipe_resource_reference(&tex, NULL); } else { - pipe_sampler_view_reference(&sampler_view, src_sampler_view); - s0 = srcX0 / (float)src->texture->width0; - s1 = srcX1 / (float)src->texture->width0; - t0 = srcY0 / (float)src->texture->height0; - t1 = srcY1 / (float)src->texture->height0; + u_sampler_view_default_template(&sv_templ, src_tex, src_tex->format); + sv_templ.first_level = sv_templ.last_level = srcsub.level; + sampler_view = pipe->create_sampler_view(pipe, src_tex, &sv_templ); + + if (!sampler_view) { + return; + } + + s0 = srcX0 / (float)(u_minify(sampler_view->texture->width0, srcsub.level)); + s1 = srcX1 / (float)(u_minify(sampler_view->texture->width0, srcsub.level)); + t0 = srcY0 / (float)(u_minify(sampler_view->texture->height0, srcsub.level)); + t1 = srcY1 / (float)(u_minify(sampler_view->texture->height0, srcsub.level)); } - + + assert(screen->is_format_supported(screen, sampler_view->format, PIPE_TEXTURE_2D, + sampler_view->texture->nr_samples, + PIPE_BIND_SAMPLER_VIEW, 0)); + assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, + dst->texture->nr_samples, + PIPE_BIND_RENDER_TARGET, 0)); /* save state (restored below) */ cso_save_blend(ctx->cso); @@ -447,6 +455,9 @@ util_blit_pixels_writemask(struct blit_state *ctx, /* sampler */ ctx->sampler.min_img_filter = filter; ctx->sampler.mag_img_filter = filter; + /* we've limited this already with the sampler view but you never know... */ + ctx->sampler.min_lod = srcsub.level; + ctx->sampler.max_lod = srcsub.level; cso_single_sampler(ctx->cso, 0, &ctx->sampler); cso_single_sampler_done(ctx->cso); @@ -515,18 +526,21 @@ util_blit_pixels_writemask(struct blit_state *ctx, void util_blit_pixels(struct blit_state *ctx, - struct pipe_surface *src, - struct pipe_sampler_view *src_sampler_view, + struct pipe_resource *src_tex, + struct pipe_subresource srcsub, int srcX0, int srcY0, int srcX1, int srcY1, + int srcZ, struct pipe_surface *dst, int dstX0, int dstY0, int dstX1, int dstY1, float z, uint filter ) { - util_blit_pixels_writemask( ctx, src, src_sampler_view, + util_blit_pixels_writemask( ctx, src_tex, + srcsub, srcX0, srcY0, srcX1, srcY1, + srcZ, dst, dstX0, dstY0, dstX1, dstY1, @@ -548,7 +562,6 @@ void util_blit_flush( struct blit_state *ctx ) /** * Copy pixel block from src texture to dst surface. - * Overlapping regions are acceptable. * * XXX Should support selection of level. * XXX need some control over blitting Z and/or stencil. @@ -582,6 +595,7 @@ util_blit_pixels_tex(struct blit_state *ctx, assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format, PIPE_TEXTURE_2D, + dst->texture->nr_samples, PIPE_BIND_RENDER_TARGET, 0)); diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h index 464ff9aaced..ef95134f324 100644 --- a/src/gallium/auxiliary/util/u_blit.h +++ b/src/gallium/auxiliary/util/u_blit.h @@ -52,10 +52,11 @@ util_destroy_blit(struct blit_state *ctx); extern void util_blit_pixels(struct blit_state *ctx, - struct pipe_surface *src, - struct pipe_sampler_view *src_sampler_view, + struct pipe_resource *src_tex, + struct pipe_subresource srcsub, int srcX0, int srcY0, int srcX1, int srcY1, + int srcZ0, struct pipe_surface *dst, int dstX0, int dstY0, int dstX1, int dstY1, @@ -63,10 +64,11 @@ util_blit_pixels(struct blit_state *ctx, void util_blit_pixels_writemask(struct blit_state *ctx, - struct pipe_surface *src, - struct pipe_sampler_view *src_sampler_view, + struct pipe_resource *src_tex, + struct pipe_subresource srcsub, int srcX0, int srcY0, int srcX1, int srcY1, + int srcZ0, struct pipe_surface *dst, int dstX0, int dstY0, int dstX1, int dstY1, diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 1abe31db466..8e0901104a2 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -743,8 +743,8 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter, return; tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION); + PIPE_BIND_SAMPLER_VIEW | + PIPE_BIND_RENDER_TARGET); /* blit from the src to the temp */ util_blitter_do_copy(blitter, tex_surf, 0, 0, @@ -797,9 +797,9 @@ void util_blitter_copy(struct blitter_context *blitter, /* (assuming copying a stencil buffer is not possible) */ if ((!ignore_stencil && is_stencil) || !screen->is_format_supported(screen, dst->format, dst->texture->target, - dst_tex_usage, 0) || + dst->texture->nr_samples, dst_tex_usage, 0) || !screen->is_format_supported(screen, src->format, src->texture->target, - PIPE_BIND_SAMPLER_VIEW, 0)) { + src->texture->nr_samples, PIPE_BIND_SAMPLER_VIEW, 0)) { util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy, width, height); return; @@ -836,6 +836,7 @@ void util_blitter_fill(struct blitter_context *blitter, /* check if we can render to the surface */ if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */ !screen->is_format_supported(screen, dst->format, dst->texture->target, + dst->texture->nr_samples, PIPE_BIND_RENDER_TARGET, 0)) { util_surface_fill(pipe, dst, dstx, dsty, width, height, value); return; diff --git a/src/gallium/auxiliary/util/u_caps.c b/src/gallium/auxiliary/util/u_caps.c index c7c1e830e01..294ee37033d 100644 --- a/src/gallium/auxiliary/util/u_caps.c +++ b/src/gallium/auxiliary/util/u_caps.c @@ -68,6 +68,7 @@ util_check_caps_out(struct pipe_screen *screen, const unsigned *list, int *out) if (!screen->is_format_supported(screen, list[i++], PIPE_TEXTURE_2D, + 0, PIPE_BIND_SAMPLER_VIEW, 0)) { *out = i - 2; diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h index 40da2d75a72..31f7fb2169a 100644 --- a/src/gallium/auxiliary/util/u_clear.h +++ b/src/gallium/auxiliary/util/u_clear.h @@ -47,25 +47,24 @@ util_clear(struct pipe_context *pipe, { if (buffers & PIPE_CLEAR_COLOR) { struct pipe_surface *ps = framebuffer->cbufs[0]; + struct pipe_subresource subdst; union util_color uc; + subdst.face = ps->face; + subdst.level = ps->level; util_pack_color(rgba, ps->format, &uc); - if (pipe->surface_fill) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui); - } else { - util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, uc.ui); - } + pipe->resource_fill_region(pipe, ps->texture, subdst, 0, 0, ps->zslice, + ps->width, ps->height, uc.ui); } if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { struct pipe_surface *ps = framebuffer->zsbuf; + struct pipe_subresource subdst; - if (pipe->surface_fill) { - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, - util_pack_z_stencil(ps->format, depth, stencil)); - } else { - util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, - util_pack_z_stencil(ps->format, depth, stencil)); - } + subdst.face = ps->face; + subdst.level = ps->level; + pipe->resource_fill_region(pipe, ps->texture, subdst, 0, 0, ps->zslice, + ps->width, ps->height, + util_pack_z_stencil(ps->format, depth, stencil)); } } diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index eee6030ddcc..48ee0427261 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1494,7 +1494,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, /* check if we can render in the texture's format */ if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D, - PIPE_BIND_RENDER_TARGET, 0)) { + pt->nr_samples, PIPE_BIND_RENDER_TARGET, 0)) { fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel); return; } diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index b47c92ca28f..029bff44eb1 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -70,7 +70,7 @@ util_create_rgba_surface(struct pipe_screen *screen, /* Choose surface format */ for (i = 0; rgbaFormats[i]; i++) { if (screen->is_format_supported(screen, rgbaFormats[i], - target, bind, 0)) { + target, 0, bind, 0)) { format = rgbaFormats[i]; break; } @@ -122,42 +122,42 @@ util_destroy_rgba_surface(struct pipe_resource *texture, /** * Fallback function for pipe->surface_copy(). * Note: (X,Y)=(0,0) is always the upper-left corner. - * if do_flip, flip the image vertically on its way from src rect to dst rect. */ void -util_surface_copy(struct pipe_context *pipe, - boolean do_flip, - struct pipe_surface *dst, - unsigned dst_x, unsigned dst_y, - struct pipe_surface *src, - unsigned src_x, unsigned src_y, - unsigned w, unsigned h) +util_resource_copy_region(struct pipe_context *pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dst_x, unsigned dst_y, unsigned dst_z, + struct pipe_resource *src, + struct pipe_subresource subsrc, + unsigned src_x, unsigned src_y, unsigned src_z, + unsigned w, unsigned h) { struct pipe_transfer *src_trans, *dst_trans; void *dst_map; const void *src_map; enum pipe_format src_format, dst_format; - assert(src->texture && dst->texture); - if (!src->texture || !dst->texture) + assert(src && dst); + if (!src || !dst) return; - src_format = src->texture->format; - dst_format = dst->texture->format; + src_format = src->format; + dst_format = dst->format; src_trans = pipe_get_transfer(pipe, - src->texture, - src->face, - src->level, - src->zslice, + src, + subsrc.face, + subsrc.level, + src_z, PIPE_TRANSFER_READ, src_x, src_y, w, h); dst_trans = pipe_get_transfer(pipe, - dst->texture, - dst->face, - dst->level, - dst->zslice, + dst, + subdst.face, + subdst.level, + src_z, PIPE_TRANSFER_WRITE, dst_x, dst_y, w, h); @@ -172,16 +172,15 @@ util_surface_copy(struct pipe_context *pipe, assert(dst_map); if (src_map && dst_map) { - /* If do_flip, invert src_y position and pass negative src stride */ util_copy_rect(dst_map, dst_format, dst_trans->stride, 0, 0, w, h, src_map, - do_flip ? -(int) src_trans->stride : src_trans->stride, + src_trans->stride, 0, - do_flip ? h - 1 : 0); + 0); } pipe->transfer_unmap(pipe, src_trans); @@ -200,22 +199,23 @@ util_surface_copy(struct pipe_context *pipe, * Fallback for pipe->surface_fill() function. */ void -util_surface_fill(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, unsigned value) +util_resource_fill_region(struct pipe_context *pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + unsigned width, unsigned height, unsigned value) { struct pipe_transfer *dst_trans; void *dst_map; - assert(dst->texture); - if (!dst->texture) + assert(dst); + if (!dst) return; dst_trans = pipe_get_transfer(pipe, - dst->texture, - dst->face, - dst->level, - dst->zslice, + dst, + subdst.face, + subdst.level, + dstz, PIPE_TRANSFER_WRITE, dstx, dsty, width, height); @@ -226,11 +226,11 @@ util_surface_fill(struct pipe_context *pipe, if (dst_map) { assert(dst_trans->stride > 0); - switch (util_format_get_blocksize(dst->texture->format)) { + switch (util_format_get_blocksize(dst->format)) { case 1: case 2: case 4: - util_fill_rect(dst_map, dst->texture->format, + util_fill_rect(dst_map, dst->format, dst_trans->stride, 0, 0, width, height, value); break; diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h index c43169b5278..ccde738ca40 100644 --- a/src/gallium/auxiliary/util/u_surface.h +++ b/src/gallium/auxiliary/util/u_surface.h @@ -33,23 +33,6 @@ #include "pipe/p_state.h" -/** - * Are s1 and s2 the same surface? - * Surfaces are basically views into textures so check if the two surfaces - * name the same part of the same texture. - */ -static INLINE boolean -util_same_surface(const struct pipe_surface *s1, const struct pipe_surface *s2) -{ - return (s1->texture == s2->texture && - s1->face == s2->face && - s1->level == s2->level && - s1->zslice == s2->zslice); -} - - - - extern boolean util_create_rgba_surface(struct pipe_screen *screen, uint width, uint height, uint bind, @@ -64,19 +47,21 @@ util_destroy_rgba_surface(struct pipe_resource *texture, extern void -util_surface_copy(struct pipe_context *pipe, - boolean do_flip, - struct pipe_surface *dst, - unsigned dst_x, unsigned dst_y, - struct pipe_surface *src, - unsigned src_x, unsigned src_y, - unsigned w, unsigned h); +util_resource_copy_region(struct pipe_context *pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dst_x, unsigned dst_y, unsigned dst_z, + struct pipe_resource *src, + struct pipe_subresource subsrc, + unsigned src_x, unsigned src_y, unsigned src_z, + unsigned w, unsigned h); extern void -util_surface_fill(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, unsigned value); +util_resource_fill_region(struct pipe_context *pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + unsigned width, unsigned height, unsigned value); -- cgit v1.2.3 From 127328bfadaa5f080730fd41f404f1bc74f490d3 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:19:03 +0200 Subject: mesa/st: adapt to interface changes adapt to blit changes, and also handle a bit more msaa state in theory (incomplete, doesn't handle resolves in any way for now). --- src/mesa/SConscript | 1 + src/mesa/sources.mak | 1 + src/mesa/state_tracker/st_atom.c | 1 + src/mesa/state_tracker/st_atom.h | 1 + src/mesa/state_tracker/st_atom_blend.c | 11 +- src/mesa/state_tracker/st_atom_framebuffer.c | 4 +- src/mesa/state_tracker/st_atom_msaa.c | 83 ++++++++++++++ src/mesa/state_tracker/st_atom_pixeltransfer.c | 2 +- src/mesa/state_tracker/st_cb_bitmap.c | 6 +- src/mesa/state_tracker/st_cb_blit.c | 36 +++--- src/mesa/state_tracker/st_cb_bufferobjects.c | 4 +- src/mesa/state_tracker/st_cb_drawpixels.c | 44 ++++---- src/mesa/state_tracker/st_cb_eglimage.c | 4 +- src/mesa/state_tracker/st_cb_fbo.c | 7 +- src/mesa/state_tracker/st_cb_fbo.h | 1 + src/mesa/state_tracker/st_cb_texture.c | 68 ++++++----- src/mesa/state_tracker/st_context.c | 17 --- src/mesa/state_tracker/st_context.h | 1 + src/mesa/state_tracker/st_extensions.c | 20 ++-- src/mesa/state_tracker/st_format.c | 150 +++++++++++++++---------- src/mesa/state_tracker/st_format.h | 5 +- src/mesa/state_tracker/st_gen_mipmap.c | 6 +- src/mesa/state_tracker/st_texture.c | 37 +++--- 23 files changed, 316 insertions(+), 194 deletions(-) create mode 100644 src/mesa/state_tracker/st_atom_msaa.c (limited to 'src') diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 690fa6d1970..a7572af45d4 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -151,6 +151,7 @@ if env['platform'] != 'winddk': 'state_tracker/st_atom_constbuf.c', 'state_tracker/st_atom_depth.c', 'state_tracker/st_atom_framebuffer.c', + 'state_tracker/st_atom_msaa.c', 'state_tracker/st_atom_pixeltransfer.c', 'state_tracker/st_atom_sampler.c', 'state_tracker/st_atom_scissor.c', diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index be859e43256..b69e7eeae51 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -195,6 +195,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_constbuf.c \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_framebuffer.c \ + state_tracker/st_atom_msaa.c \ state_tracker/st_atom_pixeltransfer.c \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index cf391f1f91f..6f293128d3a 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -57,6 +57,7 @@ static const struct st_tracked_state *atoms[] = &st_update_sampler, &st_update_texture, &st_update_framebuffer, + &st_update_msaa, &st_update_vs_constants, &st_update_fs_constants, &st_update_pixel_transfer diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index f34b49203b2..0c25269e0a4 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -54,6 +54,7 @@ extern const struct st_tracked_state st_update_polygon_stipple; extern const struct st_tracked_state st_update_viewport; extern const struct st_tracked_state st_update_scissor; extern const struct st_tracked_state st_update_blend; +extern const struct st_tracked_state st_update_msaa; extern const struct st_tracked_state st_update_sampler; extern const struct st_tracked_state st_update_texture; extern const struct st_tracked_state st_finalize_textures; diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 1511b88dd1f..21403605805 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -257,6 +257,15 @@ update_blend( struct st_context *st ) if (st->ctx->Color.DitherFlag) blend->dither = 1; + if (st->ctx->Multisample.Enabled) { + /* unlike in gallium/d3d10 these operations are only performed + if msaa is enabled */ + if (st->ctx->Multisample.SampleAlphaToCoverage) + blend->alpha_to_coverage = 1; + if (st->ctx->Multisample.SampleAlphaToOne) + blend->alpha_to_one = 1; + } + cso_set_blend(st->cso_context, blend); { @@ -270,7 +279,7 @@ update_blend( struct st_context *st ) const struct st_tracked_state st_update_blend = { "st_update_blend", /* name */ { /* dirty */ - (_NEW_COLOR), /* XXX _NEW_BLEND someday? */ /* mesa */ + (_NEW_COLOR | _NEW_MULTISAMPLE), /* XXX _NEW_BLEND someday? */ /* mesa */ 0, /* st */ }, update_blend, /* update */ diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 52c507da3b3..036bc60049a 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -73,9 +73,7 @@ update_renderbuffer_surface(struct st_context *st, strb->rtt_face, level, strb->rtt_slice, - PIPE_BIND_RENDER_TARGET | - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION ); + PIPE_BIND_RENDER_TARGET); #if 0 printf("-- alloc new surface %d x %d into tex %p\n", strb->surface->width, strb->surface->height, diff --git a/src/mesa/state_tracker/st_atom_msaa.c b/src/mesa/state_tracker/st_atom_msaa.c new file mode 100644 index 00000000000..ea9eb9a6d15 --- /dev/null +++ b/src/mesa/state_tracker/st_atom_msaa.c @@ -0,0 +1,83 @@ +/************************************************************************** + * + * Copyright 2010 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 THE AUTHORS 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. + * + **************************************************************************/ + + +#include "st_context.h" +#include "pipe/p_context.h" +#include "st_atom.h" + +#include "cso_cache/cso_context.h" + + +/* Second state atom for user clip planes: + */ +static void update_sample_mask( struct st_context *st ) +{ + unsigned sample_mask = 0xffffffff; + unsigned sample_count = 1; + struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer; + + /* dependency here on bound surface (or rather, sample count) is worrying */ + if (framebuffer->zsbuf) + sample_count = framebuffer->zsbuf->texture->nr_samples; + else if (framebuffer->cbufs[0]) + sample_count = framebuffer->cbufs[0]->texture->nr_samples; + + if (st->ctx->Multisample.Enabled && sample_count > 1) { + /* unlike in gallium/d3d10 the mask is only active if msaa is enabled */ + if (st->ctx->Multisample.SampleCoverage) { + unsigned nr_bits; + nr_bits = st->ctx->Multisample.SampleCoverageValue * (float)sample_count; + /* there's lot of ways how to do this. We just use first few bits, + since we have no knowledge of sample positions here. When + app-supplied mask though is used too might need to be smarter. + Also, there's a interface restriction here in theory it is + encouraged this mask not be the same at each pixel. */ + sample_mask = (1 << nr_bits) - 1; + if (st->ctx->Multisample.SampleCoverageInvert) + sample_mask = ~sample_mask; + } + /* TODO merge with app-supplied sample mask */ + } + + /* mask off unused bits or don't care? */ + + if (sample_mask != st->state.sample_mask) { + st->state.sample_mask = sample_mask; + cso_set_sample_mask(st->cso_context, sample_mask); + } +} + + +const struct st_tracked_state st_update_msaa = { + "st_update_msaa", /* name */ + { /* dirty */ + (_NEW_MULTISAMPLE | _NEW_BUFFERS), /* mesa */ + ST_NEW_FRAMEBUFFER, /* st */ + }, + update_sample_mask /* update */ +}; diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 29c4d092bf0..323de8a8bd3 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -123,7 +123,7 @@ create_color_map_texture(GLcontext *ctx) /* find an RGBA texture format */ format = st_choose_format(pipe->screen, GL_RGBA, - PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW); /* create texture for color map/table */ pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 797c0ba7f55..1b3787828e1 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -807,15 +807,15 @@ st_init_bitmap(struct st_context *st) st->bitmap.rasterizer.gl_rasterization_rules = 1; /* find a usable texture format */ - if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D, + if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) { st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM; } - else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D, + else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) { st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM; } - else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D, + else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) { st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM; } diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 1c8dc0c07fb..3a34bdfe9a4 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -112,33 +112,23 @@ st_BlitFramebuffer(GLcontext *ctx, &readFB->Attachment[readFB->_ColorReadBufferIndex]; if(srcAtt->Type == GL_TEXTURE) { - struct pipe_screen *screen = pipe->screen; struct st_texture_object *srcObj = st_texture_object(srcAtt->Texture); struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[0]); - struct pipe_surface *srcSurf; + struct pipe_subresource srcSub; struct pipe_surface *dstSurf = dstRb->surface; if (!srcObj->pt) return; - srcSurf = screen->get_tex_surface(screen, - srcObj->pt, - srcAtt->CubeMapFace, - srcAtt->TextureLevel, - srcAtt->Zoffset, - PIPE_BIND_BLIT_SOURCE); - if(!srcSurf) - return; + srcSub.face = srcAtt->CubeMapFace; + srcSub.level = srcAtt->TextureLevel; - util_blit_pixels(st->blit, - srcSurf, st_get_texture_sampler_view(srcObj, pipe), - srcX0, srcY0, srcX1, srcY1, + util_blit_pixels(st->blit, srcObj->pt, srcSub, + srcX0, srcY0, srcX1, srcY1, srcAtt->Zoffset, dstSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); - - pipe_surface_reference(&srcSurf, NULL); } else { struct st_renderbuffer *srcRb = @@ -146,11 +136,15 @@ st_BlitFramebuffer(GLcontext *ctx, struct st_renderbuffer *dstRb = st_renderbuffer(drawFB->_ColorDrawBuffers[0]); struct pipe_surface *srcSurf = srcRb->surface; - struct pipe_sampler_view *srcView = st_get_renderbuffer_sampler_view(srcRb, pipe); struct pipe_surface *dstSurf = dstRb->surface; + struct pipe_subresource srcSub; + + srcSub.face = srcSurf->face; + srcSub.level = srcSurf->level; util_blit_pixels(st->blit, - srcSurf, srcView, srcX0, srcY0, srcX1, srcY1, + srcRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1, + srcSurf->zslice, dstSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } @@ -182,13 +176,17 @@ st_BlitFramebuffer(GLcontext *ctx, if ((mask & depthStencil) == depthStencil && srcDepthSurf == srcStencilSurf && dstDepthSurf == dstStencilSurf) { - struct pipe_sampler_view *srcView = st_get_renderbuffer_sampler_view(srcDepthRb, pipe); + struct pipe_subresource srcSub; + + srcSub.face = srcDepthRb->surface->face; + srcSub.level = srcDepthRb->surface->level; /* Blitting depth and stencil values between combined * depth/stencil buffers. This is the ideal case for such buffers. */ util_blit_pixels(st->blit, - srcDepthSurf, srcView, srcX0, srcY0, srcX1, srcY1, + srcDepthRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1, + srcDepthRb->surface->zslice, dstDepthSurf, dstX0, dstY0, dstX1, dstY1, 0.0, pFilter); } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index f24145844b9..b883c071f7e 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -180,9 +180,7 @@ st_bufferobj_data(GLcontext *ctx, switch(target) { case GL_PIXEL_PACK_BUFFER_ARB: case GL_PIXEL_UNPACK_BUFFER_ARB: - buffer_usage = (PIPE_BIND_RENDER_TARGET | - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION); + buffer_usage = PIPE_BIND_RENDER_TARGET; break; case GL_ARRAY_BUFFER_ARB: buffer_usage = PIPE_BIND_VERTEX_BUFFER; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index e059002f157..ad20004d369 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -968,6 +968,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, enum pipe_format srcFormat, texFormat; GLboolean invertTex = GL_FALSE; GLint readX, readY, readW, readH; + GLuint sample_count; struct gl_pixelstore_attrib pack = ctx->DefaultPacking; pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); @@ -994,9 +995,15 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, driver_vp = make_passthrough_vertex_shader(st, GL_TRUE); } + sample_count = rbRead->texture->nr_samples; + /* I believe this would be legal, presumably would need to do a resolve + for color, and for depth/stencil spec says to just use one of the + depth/stencil samples per pixel? Need some transfer clarifications. */ + assert(sample_count < 2); + srcFormat = rbRead->texture->format; - if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D, + if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D, sample_count, PIPE_BIND_SAMPLER_VIEW, 0)) { texFormat = srcFormat; } @@ -1004,14 +1011,14 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* srcFormat can't be used as a texture format */ if (type == GL_DEPTH) { texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, sample_count, PIPE_BIND_DEPTH_STENCIL); assert(texFormat != PIPE_FORMAT_NONE); } else { /* default color format */ texFormat = st_choose_format(screen, GL_RGBA, PIPE_TEXTURE_2D, - PIPE_BIND_SAMPLER_VIEW); + sample_count, PIPE_BIND_SAMPLER_VIEW); assert(texFormat != PIPE_FORMAT_NONE); } } @@ -1050,27 +1057,20 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* Make temporary texture which is a copy of the src region. */ if (srcFormat == texFormat) { + struct pipe_subresource srcsub, dstsub; + srcsub.face = 0; + srcsub.level = 0; + dstsub.face = 0; + dstsub.level = 0; /* copy source framebuffer surface into mipmap/texture */ - struct pipe_surface *psRead = screen->get_tex_surface(screen, - rbRead->texture, 0, 0, 0, - PIPE_BIND_BLIT_SOURCE); - struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BIND_RENDER_TARGET | - PIPE_BIND_BLIT_DESTINATION); - pipe->surface_copy(pipe, - psTex, /* dest surf */ - pack.SkipPixels, pack.SkipRows, /* dest pos */ - psRead, /* src surf */ - readX, readY, readW, readH); /* src region */ - - if (0) { - /* debug */ - debug_dump_surface(pipe, "copypixsrcsurf", psRead); - debug_dump_surface(pipe, "copypixtemptex", psTex); - } + pipe->resource_copy_region(pipe, + pt, /* dest tex */ + dstsub, + pack.SkipPixels, pack.SkipRows, 0, /* dest pos */ + rbRead->texture, /* src tex */ + srcsub, + readX, readY, 0, readW, readH); /* src region */ - pipe_surface_reference(&psRead, NULL); - pipe_surface_reference(&psTex, NULL); } else { /* CPU-based fallback/conversion */ diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 0fa1848e232..91a42fafd19 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -79,7 +79,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx, struct pipe_surface *ps; unsigned usage; - usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_BLIT_SOURCE | PIPE_BIND_BLIT_DESTINATION; + usage = PIPE_BIND_RENDER_TARGET; ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage); if (ps) { strb->Base.Width = ps->width; @@ -142,7 +142,7 @@ st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target, struct pipe_surface *ps; unsigned usage; - usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_BLIT_SOURCE; + usage = PIPE_BIND_SAMPLER_VIEW; ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage); if (ps) { st_bind_surface(ctx, target, texObj, texImage, ps); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index c02121fbd1a..f67197de94f 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -72,7 +72,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, if (strb->format != PIPE_FORMAT_NONE) format = strb->format; else - format = st_choose_renderbuffer_format(screen, internalFormat); + format = st_choose_renderbuffer_format(screen, internalFormat, rb->NumSamples); /* init renderbuffer fields */ strb->Base.Width = width; @@ -441,8 +441,8 @@ st_validate_attachment(struct pipe_screen *screen, if (!stObj) return GL_FALSE; - return screen->is_format_supported(screen, stObj->pt->format, - PIPE_TEXTURE_2D, bindings, 0); + return screen->is_format_supported(screen, stObj->pt->format, stObj->pt->nr_samples, + PIPE_TEXTURE_2D, bindings, 0); } @@ -545,6 +545,7 @@ void st_init_fbo_functions(struct dd_function_table *functions) functions->ReadBuffer = st_ReadBuffer; } +/* XXX unused ? */ struct pipe_sampler_view * st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb, struct pipe_context *pipe) diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h index beb26ab4da1..43b6c1e75f4 100644 --- a/src/mesa/state_tracker/st_cb_fbo.h +++ b/src/mesa/state_tracker/st_cb_fbo.h @@ -73,6 +73,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw); extern void st_init_fbo_functions(struct dd_function_table *functions); +/* XXX unused ? */ extern struct pipe_sampler_view * st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb, struct pipe_context *pipe); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index ed8eb2929a6..92342167d92 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -221,7 +221,7 @@ default_bindings(struct st_context *st, enum pipe_format format) else bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; - if (screen->is_format_supported(screen, format, target, bindings, geom)) + if (screen->is_format_supported(screen, format, target, 0, bindings, geom)) return bindings; else return PIPE_BIND_SAMPLER_VIEW; @@ -428,7 +428,7 @@ compress_with_blit(GLcontext * ctx, /* get destination surface (in the compressed texture) */ dst_surface = screen->get_tex_surface(screen, stImage->pt, stImage->face, stImage->level, 0, - PIPE_BIND_BLIT_DESTINATION); + 0 /* flags */); if (!dst_surface) { /* can't render into this format (or other problem) */ return GL_FALSE; @@ -652,7 +652,7 @@ st_TexImage(GLcontext * ctx, _mesa_is_format_compressed(texImage->TexFormat) && screen->is_format_supported(screen, stImage->pt->format, - stImage->pt->target, + stImage->pt->target, 0, PIPE_BIND_RENDER_TARGET, 0)) { if (!pixels) goto done; @@ -848,8 +848,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, struct pipe_surface *dst_surface; struct pipe_resource *dst_texture; struct pipe_transfer *tex_xfer; - unsigned bind = (PIPE_BIND_BLIT_DESTINATION | - PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */ + unsigned bind = (PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */ PIPE_BIND_TRANSFER_READ); /* create temp / dest surface */ @@ -1080,7 +1079,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, _mesa_is_format_compressed(texImage->TexFormat) && screen->is_format_supported(screen, stImage->pt->format, - stImage->pt->target, + stImage->pt->target, 0, PIPE_BIND_RENDER_TARGET, 0)) { if (compress_with_blit(ctx, target, level, xoffset, yoffset, zoffset, @@ -1508,7 +1507,7 @@ st_copy_texsubimage(GLcontext *ctx, enum pipe_format dest_format, src_format; GLboolean use_fallback = GL_TRUE; GLboolean matching_base_formats; - GLuint format_writemask; + GLuint format_writemask, sample_count; struct pipe_surface *dest_surface = NULL; GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); @@ -1534,6 +1533,12 @@ st_copy_texsubimage(GLcontext *ctx, return; } + sample_count = strb->surface->texture->nr_samples; + /* I believe this would be legal, presumably would need to do a resolve + for color, and for depth/stencil spec says to just use one of the + depth/stencil samples per pixel? Need some transfer clarifications. */ + assert(sample_count < 2); + if (srcX < 0) { width -= -srcX; destX += -srcX; @@ -1589,42 +1594,45 @@ st_copy_texsubimage(GLcontext *ctx, !do_flip) { /* use surface_copy() / blit */ - - dest_surface = screen->get_tex_surface(screen, stImage->pt, - stImage->face, stImage->level, - destZ, - PIPE_BIND_BLIT_DESTINATION); - - /* for surface_copy(), y=0=top, always */ - pipe->surface_copy(pipe, - /* dest */ - dest_surface, - destX, destY, - /* src */ - strb->surface, - srcX, srcY, - /* size */ - width, height); + struct pipe_subresource subdst, subsrc; + subdst.face = stImage->face; + subdst.level = stImage->level; + subsrc.face = strb->surface->face; + subsrc.level = strb->surface->level; + + /* for resource_copy_region(), y=0=top, always */ + pipe->resource_copy_region(pipe, + /* dest */ + stImage->pt, + subdst, + destX, destY, destZ, + /* src */ + strb->texture, + subsrc, + srcX, srcY, strb->surface->zslice, + /* size */ + width, height); use_fallback = GL_FALSE; } else if (format_writemask && texBaseFormat != GL_DEPTH_COMPONENT && texBaseFormat != GL_DEPTH_STENCIL && screen->is_format_supported(screen, src_format, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, sample_count, PIPE_BIND_SAMPLER_VIEW, 0) && screen->is_format_supported(screen, dest_format, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0)) { /* draw textured quad to do the copy */ GLint srcY0, srcY1; + struct pipe_subresource subsrc; dest_surface = screen->get_tex_surface(screen, stImage->pt, stImage->face, stImage->level, destZ, - PIPE_BIND_BLIT_DESTINATION); + PIPE_BIND_RENDER_TARGET); if (do_flip) { srcY1 = strb->Base.Height - srcY - height; @@ -1634,11 +1642,15 @@ st_copy_texsubimage(GLcontext *ctx, srcY0 = srcY; srcY1 = srcY0 + height; } + subsrc.face = strb->surface->face; + subsrc.level = strb->surface->level; + util_blit_pixels_writemask(st->blit, - strb->surface, - st_get_renderbuffer_sampler_view(strb, pipe), + strb->texture, + subsrc, srcX, srcY0, srcX + width, srcY1, + strb->surface->zslice, dest_surface, destX, destY, destX + width, destY + height, diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index e8a3926e6db..d4ea593e3f7 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -99,19 +99,6 @@ st_get_msaa(void) } -/** Default method for pipe_context::surface_copy() */ -static void -st_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dst_x, unsigned dst_y, - struct pipe_surface *src, - unsigned src_x, unsigned src_y, - unsigned w, unsigned h) -{ - util_surface_copy(pipe, FALSE, dst, dst_x, dst_y, src, src_x, src_y, w, h); -} - - static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { @@ -181,10 +168,6 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st_init_limits(st); st_init_extensions(st); - /* plug in helper driver functions if needed */ - if (!pipe->surface_copy) - pipe->surface_copy = st_surface_copy; - return st; } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 3637f6e75f0..987516f2482 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -94,6 +94,7 @@ struct st_context struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_scissor_state scissor; struct pipe_viewport_state viewport; + unsigned sample_mask; GLuint num_samplers; GLuint num_textures; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index b2045cf3fcb..9ada38aa483 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -287,39 +287,39 @@ void st_init_extensions(struct st_context *st) * a depth/stencil buffer and texture from depth/stencil source. */ if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0) && screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0) && screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } /* sRGB support */ if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0) || screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.EXT_texture_sRGB = GL_TRUE; } /* s3tc support */ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0) && (ctx->Mesa_DXTn || screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0))) { ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; ctx->Extensions.S3_s3tc = GL_TRUE; @@ -327,10 +327,10 @@ void st_init_extensions(struct st_context *st) /* ycbcr support */ if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0) || screen->is_format_supported(screen, PIPE_FORMAT_YUYV, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; } diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index d7d2be6d454..f7b10ea243a 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -311,13 +311,14 @@ find_supported_format(struct pipe_screen *screen, const enum pipe_format formats[], uint num_formats, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags) { uint i; for (i = 0; i < num_formats; i++) { if (screen->is_format_supported(screen, formats[i], target, - tex_usage, geom_flags)) { + sample_count, tex_usage, geom_flags)) { return formats[i]; } } @@ -331,7 +332,8 @@ find_supported_format(struct pipe_screen *screen, static enum pipe_format default_rgba_format(struct pipe_screen *screen, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { @@ -341,7 +343,7 @@ default_rgba_format(struct pipe_screen *screen, PIPE_FORMAT_B5G6R5_UNORM }; return find_supported_format(screen, colorFormats, Elements(colorFormats), - target, tex_usage, geom_flags); + target, sample_count, tex_usage, geom_flags); } @@ -351,7 +353,8 @@ default_rgba_format(struct pipe_screen *screen, static enum pipe_format default_rgb_format(struct pipe_screen *screen, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { @@ -364,7 +367,7 @@ default_rgb_format(struct pipe_screen *screen, PIPE_FORMAT_B5G6R5_UNORM }; return find_supported_format(screen, colorFormats, Elements(colorFormats), - target, tex_usage, geom_flags); + target, sample_count, tex_usage, geom_flags); } /** @@ -373,7 +376,8 @@ default_rgb_format(struct pipe_screen *screen, static enum pipe_format default_srgba_format(struct pipe_screen *screen, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { @@ -382,7 +386,7 @@ default_srgba_format(struct pipe_screen *screen, PIPE_FORMAT_A8B8G8R8_SRGB, }; return find_supported_format(screen, colorFormats, Elements(colorFormats), - target, tex_usage, geom_flags); + target, sample_count, tex_usage, geom_flags); } @@ -401,7 +405,8 @@ default_srgba_format(struct pipe_screen *screen, */ enum pipe_format st_choose_format(struct pipe_screen *screen, GLenum internalFormat, - enum pipe_texture_target target, unsigned bindings) + enum pipe_texture_target target, unsigned sample_count, + unsigned bindings) { unsigned geom_flags = 0; /* we don't care about POT vs. NPOT here, yet */ @@ -411,42 +416,53 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_RGBA8: case GL_RGB10_A2: case GL_RGBA12: - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case 3: case GL_RGB: - return default_rgb_format( screen, target, bindings, geom_flags ); + return default_rgb_format( screen, target, sample_count, bindings, + geom_flags ); case GL_RGBA16: - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_RGBA4: case GL_RGBA2: if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, - target, bindings, geom_flags )) + target, sample_count, bindings, + geom_flags )) return PIPE_FORMAT_B4G4R4A4_UNORM; - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_RGB5_A1: if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, - target, bindings, geom_flags )) + target, sample_count, bindings, + geom_flags )) return PIPE_FORMAT_B5G5R5A1_UNORM; - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_RGB8: case GL_RGB10: case GL_RGB12: case GL_RGB16: - return default_rgb_format( screen, target, bindings, geom_flags ); + return default_rgb_format( screen, target, sample_count, bindings, + geom_flags ); case GL_RGB5: case GL_RGB4: case GL_R3_G3_B2: if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, - target, bindings, geom_flags )) + target, sample_count, bindings, + geom_flags )) return PIPE_FORMAT_B5G6R5_UNORM; if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, - target, bindings, geom_flags )) + target, sample_count, bindings, + geom_flags )) return PIPE_FORMAT_B5G5R5A1_UNORM; - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_ALPHA: case GL_ALPHA4: @@ -455,9 +471,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_ALPHA16: case GL_COMPRESSED_ALPHA: if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, - bindings, geom_flags )) + sample_count, bindings, geom_flags )) return PIPE_FORMAT_A8_UNORM; - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case 1: case GL_LUMINANCE: @@ -467,9 +484,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE16: case GL_COMPRESSED_LUMINANCE: if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, - bindings, geom_flags )) + sample_count, bindings, geom_flags )) return PIPE_FORMAT_L8_UNORM; - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case 2: case GL_LUMINANCE_ALPHA: @@ -481,9 +499,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, - bindings, geom_flags )) + sample_count, bindings, geom_flags )) return PIPE_FORMAT_L8A8_UNORM; - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_INTENSITY: case GL_INTENSITY4: @@ -492,17 +511,18 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_INTENSITY16: case GL_COMPRESSED_INTENSITY: if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, - bindings, geom_flags )) + sample_count, bindings, geom_flags )) return PIPE_FORMAT_I8_UNORM; - return default_rgba_format( screen, target, bindings, geom_flags ); + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_YCBCR_MESA: - if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, - target, bindings, geom_flags)) { + if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, target, + sample_count, bindings, geom_flags)) { return PIPE_FORMAT_UYVY; } - if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, - target, bindings, geom_flags)) { + if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, target, + sample_count, bindings, geom_flags)) { return PIPE_FORMAT_YUYV; } return PIPE_FORMAT_NONE; @@ -512,33 +532,39 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, if (bindings & ~PIPE_BIND_SAMPLER_VIEW) return PIPE_FORMAT_NONE; else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, - target, bindings, geom_flags)) + target, sample_count, bindings, + geom_flags)) return PIPE_FORMAT_DXT1_RGB; else - return default_rgb_format(screen, target, bindings, geom_flags); + return default_rgb_format(screen, target, sample_count, bindings, + geom_flags); case GL_COMPRESSED_RGBA: /* can only sample from compressed formats */ if (bindings & ~PIPE_BIND_SAMPLER_VIEW) return PIPE_FORMAT_NONE; else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, - target, bindings, geom_flags)) + target, sample_count, bindings, + geom_flags)) return PIPE_FORMAT_DXT3_RGBA; else - return default_rgba_format(screen, target, bindings, geom_flags); + return default_rgba_format(screen, target, sample_count, bindings, + geom_flags); case GL_RGB_S3TC: case GL_RGB4_S3TC: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, - target, bindings, geom_flags)) + target, sample_count, bindings, + geom_flags)) return PIPE_FORMAT_DXT1_RGB; else return PIPE_FORMAT_NONE; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA, - target, bindings, geom_flags)) + target, sample_count, bindings, + geom_flags)) return PIPE_FORMAT_DXT1_RGBA; else return PIPE_FORMAT_NONE; @@ -547,14 +573,16 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_RGBA4_S3TC: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, - target, bindings, geom_flags)) + target, sample_count, bindings, + geom_flags)) return PIPE_FORMAT_DXT3_RGBA; else return PIPE_FORMAT_NONE; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, - target, bindings, geom_flags)) + target, sample_count, bindings, + geom_flags)) return PIPE_FORMAT_DXT5_RGBA; else return PIPE_FORMAT_NONE; @@ -568,20 +596,20 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_DEPTH_COMPONENT16: if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target, - bindings, geom_flags)) + sample_count, bindings, geom_flags)) return PIPE_FORMAT_Z16_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT24: if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, - target, bindings, geom_flags)) + target, sample_count, bindings, geom_flags)) return PIPE_FORMAT_Z24_UNORM_S8_USCALED; if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, - target, bindings, geom_flags)) + target, sample_count, bindings, geom_flags)) return PIPE_FORMAT_S8_USCALED_Z24_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT32: - if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, - target, bindings, geom_flags)) + if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, target, + sample_count, bindings, geom_flags)) return PIPE_FORMAT_Z32_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT: @@ -593,7 +621,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, PIPE_FORMAT_S8_USCALED_Z24_UNORM }; return find_supported_format(screen, formats, Elements(formats), - target, bindings, geom_flags); + target, sample_count, bindings, geom_flags); } case GL_STENCIL_INDEX: @@ -608,7 +636,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, PIPE_FORMAT_S8_USCALED_Z24_UNORM }; return find_supported_format(screen, formats, Elements(formats), - target, bindings, geom_flags); + target, sample_count, bindings, geom_flags); } case GL_DEPTH_STENCIL_EXT: @@ -619,7 +647,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, PIPE_FORMAT_S8_USCALED_Z24_UNORM }; return find_supported_format(screen, formats, Elements(formats), - target, bindings, geom_flags); + target, sample_count, bindings, geom_flags); } case GL_SRGB_EXT: @@ -628,7 +656,8 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_COMPRESSED_SRGB_ALPHA_EXT: case GL_SRGB_ALPHA_EXT: case GL_SRGB8_ALPHA8_EXT: - return default_srgba_format( screen, target, bindings, geom_flags ); + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: return PIPE_FORMAT_DXT1_SRGB; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: @@ -642,17 +671,19 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_SLUMINANCE8_ALPHA8_EXT: case GL_COMPRESSED_SLUMINANCE_EXT: case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, - target, bindings, geom_flags)) + if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, target, + sample_count, bindings, geom_flags)) return PIPE_FORMAT_L8A8_SRGB; - return default_srgba_format( screen, target, bindings, geom_flags ); + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); case GL_SLUMINANCE_EXT: case GL_SLUMINANCE8_EXT: - if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, - target, bindings, geom_flags)) + if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, target, + sample_count, bindings, geom_flags)) return PIPE_FORMAT_L8_SRGB; - return default_srgba_format( screen, target, bindings, geom_flags ); + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); default: return PIPE_FORMAT_NONE; @@ -665,14 +696,15 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, */ enum pipe_format st_choose_renderbuffer_format(struct pipe_screen *screen, - GLenum internalFormat) + GLenum internalFormat, unsigned sample_count) { uint usage; if (_mesa_is_depth_or_stencil_format(internalFormat)) usage = PIPE_BIND_DEPTH_STENCIL; else usage = PIPE_BIND_RENDER_TARGET; - return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, usage); + return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, + sample_count, usage); } @@ -700,12 +732,12 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; pFormat = st_choose_format(screen, internalFormat, - PIPE_TEXTURE_2D, bindings); + PIPE_TEXTURE_2D, 0, bindings); if (pFormat == PIPE_FORMAT_NONE) { /* try choosing format again, this time without render target bindings */ pFormat = st_choose_format(screen, internalFormat, - PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW); } if (pFormat == PIPE_FORMAT_NONE) { diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h index a6cf7025a92..3288225d5d4 100644 --- a/src/mesa/state_tracker/st_format.h +++ b/src/mesa/state_tracker/st_format.h @@ -46,11 +46,12 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat); extern enum pipe_format st_choose_format(struct pipe_screen *screen, GLenum internalFormat, - enum pipe_texture_target target, unsigned tex_usage); + enum pipe_texture_target target, unsigned sample_count, + unsigned tex_usage); extern enum pipe_format st_choose_renderbuffer_format(struct pipe_screen *screen, - GLenum internalFormat); + GLenum internalFormat, unsigned sample_count); extern gl_format diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 6b1d51b3f44..5cf8b4a881b 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -82,7 +82,7 @@ st_render_mipmap(struct st_context *st, assert(target != GL_TEXTURE_3D); /* not done yet */ /* check if we can render in the texture's format */ - if (!screen->is_format_supported(screen, psv->format, psv->texture->target, + if (!screen->is_format_supported(screen, psv->format, psv->texture->target, 0, PIPE_BIND_RENDER_TARGET, 0)) { return FALSE; } @@ -300,6 +300,10 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, if (!pt) return; + /* not sure if this ultimately actually should work, + but we're not supporting multisampled textures yet. */ + assert(pt->nr_samples < 2); + /* find expected last mipmap level */ lastLevel = compute_num_levels(ctx, texObj, target) - 1; diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 6a42789b824..d0d1c5c3156 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -72,7 +72,7 @@ st_texture_create(struct st_context *st, _mesa_lookup_enum_by_nr(format), last_level); assert(format); - assert(screen->is_format_supported(screen, format, target, + assert(screen->is_format_supported(screen, format, target, 0, PIPE_BIND_SAMPLER_VIEW, 0)); memset(&pt, 0, sizeof(pt)); @@ -245,17 +245,19 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *src, GLuint face) { - struct pipe_screen *screen = pipe->screen; GLuint width = u_minify(dst->width0, dstLevel); GLuint height = u_minify(dst->height0, dstLevel); GLuint depth = u_minify(dst->depth0, dstLevel); - struct pipe_surface *src_surface; - struct pipe_surface *dst_surface; + struct pipe_subresource dstsub, srcsub; GLuint i; assert(src->width0 == dst->width0); assert(src->height0 == dst->height0); + dstsub.face = face; + dstsub.level = dstLevel; + srcsub.face = face; + for (i = 0; i < depth; i++) { GLuint srcLevel; @@ -271,6 +273,7 @@ st_texture_image_copy(struct pipe_context *pipe, #if 0 { + struct pipe_screen *screen = pipe->screen; src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, PIPE_BUFFER_USAGE_CPU_READ); ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ); @@ -284,22 +287,16 @@ st_texture_image_copy(struct pipe_context *pipe, pipe_surface_reference(&src_surface, NULL); } #endif - - dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i, - PIPE_BIND_BLIT_DESTINATION); - - src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, - PIPE_BIND_BLIT_SOURCE); - - pipe->surface_copy(pipe, - dst_surface, - 0, 0, /* destX, Y */ - src_surface, - 0, 0, /* srcX, Y */ - width, height); - - pipe_surface_reference(&src_surface, NULL); - pipe_surface_reference(&dst_surface, NULL); + srcsub.level = srcLevel; + + pipe->resource_copy_region(pipe, + dst, + dstsub, + 0, 0, i,/* destX, Y, Z */ + src, + srcsub, + 0, 0, i,/* srcX, Y, Z */ + width, height); } } -- cgit v1.2.3 From 57a01712258c9d6063ef36bc359cffba3e7f9be1 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:22:23 +0200 Subject: cell: adapt to interface changes not even compile tested but fairly trivial --- src/gallium/drivers/cell/ppu/cell_screen.c | 8 ++++++-- src/gallium/drivers/cell/ppu/cell_surface.c | 16 ++-------------- 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index b4fd8d7235c..9bb3abfc9dd 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -132,13 +132,17 @@ cell_get_paramf(struct pipe_screen *screen, int param) static boolean cell_is_format_supported( struct pipe_screen *screen, - enum pipe_format format, + enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags ) { struct sw_winsys *winsys = cell_screen(screen)->winsys; + if (sample_count > 1) + return FALSE; + if (tex_usage & (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) { diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c index 6696a4591c1..8000eee88a3 100644 --- a/src/gallium/drivers/cell/ppu/cell_surface.c +++ b/src/gallium/drivers/cell/ppu/cell_surface.c @@ -30,21 +30,9 @@ #include "cell_surface.h" -static void -cell_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, unsigned destx, unsigned desty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) -{ - util_surface_copy(pipe, FALSE, - dest, destx, desty, - src, srcx, srcy, - width, height); -} - void cell_init_surface_functions(struct cell_context *cell) { - cell->pipe.surface_copy = cell_surface_copy; - cell->pipe.surface_fill = util_surface_fill; + cell->pipe.resource_copy_region = util_resource_copy_region; + cell->pipe.resource_fill_region = util_resource_fill_region; } -- cgit v1.2.3 From e121a73d629856240a9676a4f0dff832d95c90c3 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:23:31 +0200 Subject: llvmpipe: adapt to interface changes --- src/gallium/drivers/llvmpipe/lp_screen.c | 6 ++++- src/gallium/drivers/llvmpipe/lp_surface.c | 41 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 111eedc4f23..5f50446f846 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -168,8 +168,9 @@ llvmpipe_get_paramf(struct pipe_screen *screen, int param) */ static boolean llvmpipe_is_format_supported( struct pipe_screen *_screen, - enum pipe_format format, + enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned bind, unsigned geom_flags ) { @@ -186,6 +187,9 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, target == PIPE_TEXTURE_3D || target == PIPE_TEXTURE_CUBE); + if (sample_count > 1) + return FALSE; + if (bind & PIPE_BIND_RENDER_TARGET) { if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) return FALSE; diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index 245171120dd..85687ada1c4 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -51,24 +51,27 @@ adjust_to_tile_bounds(unsigned x, unsigned y, unsigned width, unsigned height, static void -lp_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dst, unsigned dstx, unsigned dsty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) +lp_resource_copy(struct pipe_context *pipe, + struct pipe_resource *dst, struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, + unsigned width, unsigned height) { - struct llvmpipe_resource *src_tex = llvmpipe_resource(src->texture); - struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst->texture); + /* XXX what about the dstz/srcz parameters - zslice wasn't used... */ + struct llvmpipe_resource *src_tex = llvmpipe_resource(src); + struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst); const enum pipe_format format = src_tex->base.format; llvmpipe_flush_resource(pipe, - dst->texture, dst->face, dst->level, + dst, subdst.face, subdst.level, 0, /* flush_flags */ FALSE, /* read_only */ FALSE, /* cpu_access */ FALSE); /* do_not_block */ llvmpipe_flush_resource(pipe, - src->texture, src->face, src->level, + src, subsrc.face, subsrc.level, 0, /* flush_flags */ TRUE, /* read_only */ FALSE, /* cpu_access */ @@ -90,8 +93,8 @@ lp_surface_copy(struct pipe_context *pipe, for (y = 0; y < th; y += TILE_SIZE) { for (x = 0; x < tw; x += TILE_SIZE) { (void) llvmpipe_get_texture_tile_linear(src_tex, - src->face, src->level, - LP_TEX_USAGE_READ, + subsrc.face, subsrc.level, + LP_TEX_USAGE_READ, tx + x, ty + y); } } @@ -117,7 +120,7 @@ lp_surface_copy(struct pipe_context *pipe, for (y = 0; y < th; y += TILE_SIZE) { for (x = 0; x < tw; x += TILE_SIZE) { (void) llvmpipe_get_texture_tile_linear(dst_tex, - dst->face, dst->level, + subdst.face, subdst.level, usage, tx + x, ty + y); } @@ -127,20 +130,20 @@ lp_surface_copy(struct pipe_context *pipe, /* copy */ { const ubyte *src_linear_ptr - = llvmpipe_get_texture_image_address(src_tex, src->face, - src->level, + = llvmpipe_get_texture_image_address(src_tex, subsrc.face, + subsrc.level, LP_TEX_LAYOUT_LINEAR); ubyte *dst_linear_ptr - = llvmpipe_get_texture_image_address(dst_tex, dst->face, - dst->level, + = llvmpipe_get_texture_image_address(dst_tex, subdst.face, + subdst.level, LP_TEX_LAYOUT_LINEAR); util_copy_rect(dst_linear_ptr, format, - llvmpipe_resource_stride(&dst_tex->base, dst->level), + llvmpipe_resource_stride(&dst_tex->base, subdst.level), dstx, dsty, width, height, src_linear_ptr, - llvmpipe_resource_stride(&src_tex->base, src->level), + llvmpipe_resource_stride(&src_tex->base, subsrc.level), srcx, srcy); } } @@ -149,6 +152,6 @@ lp_surface_copy(struct pipe_context *pipe, void llvmpipe_init_surface_functions(struct llvmpipe_context *lp) { - lp->pipe.surface_copy = lp_surface_copy; - lp->pipe.surface_fill = util_surface_fill; + lp->pipe.resource_copy_region = lp_resource_copy; + lp->pipe.resource_fill_region = util_resource_fill_region; } -- cgit v1.2.3 From 6c32670706e8ed3855ff2187f0eadee43b5b8742 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:23:46 +0200 Subject: softpipe: adapt to interface changes --- src/gallium/drivers/softpipe/sp_screen.c | 6 +++++- src/gallium/drivers/softpipe/sp_surface.c | 17 ++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 8bb0294238a..ad59ee90936 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -145,8 +145,9 @@ softpipe_get_paramf(struct pipe_screen *screen, int param) */ static boolean softpipe_is_format_supported( struct pipe_screen *screen, - enum pipe_format format, + enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned bind, unsigned geom_flags ) { @@ -162,6 +163,9 @@ softpipe_is_format_supported( struct pipe_screen *screen, if (!format_desc) return FALSE; + if (sample_count > 1) + return FALSE; + if (bind & (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) { diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c index 32cab06004f..0296c26ad26 100644 --- a/src/gallium/drivers/softpipe/sp_surface.c +++ b/src/gallium/drivers/softpipe/sp_surface.c @@ -29,22 +29,9 @@ #include "sp_context.h" #include "sp_surface.h" - -static void -sp_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, unsigned destx, unsigned desty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, - unsigned width, unsigned height) -{ - util_surface_copy(pipe, FALSE, - dest, destx, desty, - src, srcx, srcy, - width, height); -} - void sp_init_surface_functions(struct softpipe_context *sp) { - sp->pipe.surface_copy = sp_surface_copy; - sp->pipe.surface_fill = util_surface_fill; + sp->pipe.resource_copy_region = util_resource_copy_region; + sp->pipe.resource_fill_region = util_resource_fill_region; } -- cgit v1.2.3 From bccf31bf5f2d6c9516a4c073d735b5056ff1d608 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:24:04 +0200 Subject: i915g: adapt to interface changes --- src/gallium/drivers/i915/i915_screen.c | 19 ++++++--- src/gallium/drivers/i915/i915_surface.c | 69 +++++++++++++++++++++++++-------- 2 files changed, 67 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 9086f9fc3b1..c10ba25d2d5 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -159,9 +159,10 @@ i915_get_paramf(struct pipe_screen *screen, int param) static boolean i915_is_format_supported(struct pipe_screen *screen, - enum pipe_format format, + enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags) { static const enum pipe_format tex_supported[] = { @@ -181,17 +182,25 @@ i915_is_format_supported(struct pipe_screen *screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_NONE /* list terminator */ }; - static const enum pipe_format surface_supported[] = { + static const enum pipe_format render_supported[] = { PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_NONE /* list terminator */ + }; + static const enum pipe_format depth_supported[] = { PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_NONE /* list terminator */ }; const enum pipe_format *list; uint i; - if(tex_usage & PIPE_BIND_RENDER_TARGET) - list = surface_supported; + if (sample_count > 1) + return FALSE; + + if(tex_usage & PIPE_BIND_DEPTH_STENCIL) + list = depth_supported; + else if (tex_usage & PIPE_BIND_RENDER_TARGET) + list = render_supported; else list = tex_supported; diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 453437b8090..0deee24754f 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -41,15 +41,41 @@ */ static void i915_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, unsigned width, unsigned height) + struct pipe_resource *dst, struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, + unsigned width, unsigned height) { - struct i915_texture *dst_tex = i915_texture(dst->texture); - struct i915_texture *src_tex = i915_texture(src->texture); + struct i915_texture *dst_tex = i915_texture(dst); + struct i915_texture *src_tex = i915_texture(src); struct pipe_resource *dpt = &dst_tex->b.b; struct pipe_resource *spt = &src_tex->b.b; + unsigned dst_offset, src_offset; /* in bytes */ + + if (dst->target == PIPE_TEXTURE_CUBE) { + dst_offset = dst_tex->image_offset[subdst.level][subdst.face]; + } + else if (dst->target == PIPE_TEXTURE_3D) { + dst_offset = dst_tex->image_offset[subdst.level][dstz]; + } + else { + dst_offset = dst_tex->image_offset[subdst.level][0]; + assert(subdst.face == 0); + assert(dstz == 0); + } + if (src->target == PIPE_TEXTURE_CUBE) { + src_offset = src_tex->image_offset[subsrc.level][subsrc.face]; + } + else if (src->target == PIPE_TEXTURE_3D) { + src_offset = src_tex->image_offset[subsrc.level][srcz]; + } + else { + src_offset = src_tex->image_offset[subsrc.level][0]; + assert(subsrc.face == 0); + assert(srcz == 0); + } + assert( dst != src ); assert( util_format_get_blocksize(dpt->format) == util_format_get_blocksize(spt->format) ); @@ -61,20 +87,33 @@ i915_surface_copy(struct pipe_context *pipe, i915_copy_blit( i915_context(pipe), FALSE, util_format_get_blocksize(dpt->format), - (unsigned short) src_tex->stride, src_tex->buffer, src->offset, - (unsigned short) dst_tex->stride, dst_tex->buffer, dst->offset, + (unsigned short) src_tex->stride, src_tex->buffer, src_offset, + (unsigned short) dst_tex->stride, dst_tex->buffer, dst_offset, (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height ); } static void i915_surface_fill(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, + struct pipe_resource *dst, struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, unsigned width, unsigned height, unsigned value) { - struct i915_texture *tex = i915_texture(dst->texture); + struct i915_texture *tex = i915_texture(dst); struct pipe_resource *pt = &tex->b.b; + unsigned dst_offset; /* in bytes */ + + if (dst->target == PIPE_TEXTURE_CUBE) { + dst_offset = tex->image_offset[subdst.level][subdst.face]; + } + else if (dst->target == PIPE_TEXTURE_3D) { + dst_offset = tex->image_offset[subdst.level][dstz]; + } + else { + dst_offset = tex->image_offset[subdst.level][0]; + assert(subdst.face == 0); + assert(dstz == 0); + } assert(util_format_get_blockwidth(pt->format) == 1); assert(util_format_get_blockheight(pt->format) == 1); @@ -82,7 +121,7 @@ i915_surface_fill(struct pipe_context *pipe, i915_fill_blit( i915_context(pipe), util_format_get_blocksize(pt->format), (unsigned short) tex->stride, - tex->buffer, dst->offset, + tex->buffer, dst_offset, (short) dstx, (short) dsty, (short) width, (short) height, value ); @@ -137,13 +176,11 @@ i915_tex_surface_destroy(struct pipe_surface *surf) } -/* Probably going to make blits work on textures rather than surfaces. - */ void i915_init_surface_functions(struct i915_context *i915) { - i915->base.surface_copy = i915_surface_copy; - i915->base.surface_fill = i915_surface_fill; + i915->base.resource_copy_region = i915_surface_copy; + i915->base.resource_fill_region = i915_surface_fill; } /* No good reason for these to be in the screen. -- cgit v1.2.3 From a02ddd48c5f7350366115ac07c15113402a79ee2 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:24:50 +0200 Subject: i965g: adapt to interface changes --- src/gallium/drivers/i965/brw_resource.c | 3 +++ src/gallium/drivers/i965/brw_resource.h | 3 ++- src/gallium/drivers/i965/brw_resource_texture.c | 3 ++- src/gallium/drivers/i965/brw_screen.c | 8 ++++++-- 4 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/i965/brw_resource.c b/src/gallium/drivers/i965/brw_resource.c index d601f42dd16..3b9854be588 100644 --- a/src/gallium/drivers/i965/brw_resource.c +++ b/src/gallium/drivers/i965/brw_resource.c @@ -1,4 +1,5 @@ #include "util/u_debug.h" +#include "util/u_surface.h" #include "brw_resource.h" #include "brw_context.h" @@ -37,6 +38,8 @@ brw_init_resource_functions(struct brw_context *brw ) brw->base.transfer_unmap = u_transfer_unmap_vtbl; brw->base.transfer_destroy = u_transfer_destroy_vtbl; brw->base.transfer_inline_write = u_transfer_inline_write_vtbl; + brw->base.resource_copy_region = util_resource_copy_region; + brw->base.resource_fill_region = util_resource_fill_region; } void diff --git a/src/gallium/drivers/i965/brw_resource.h b/src/gallium/drivers/i965/brw_resource.h index 3390c270d42..78defb37b2a 100644 --- a/src/gallium/drivers/i965/brw_resource.h +++ b/src/gallium/drivers/i965/brw_resource.h @@ -124,7 +124,8 @@ boolean brw_is_format_supported( struct pipe_screen *screen, enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags ); */ diff --git a/src/gallium/drivers/i965/brw_resource_texture.c b/src/gallium/drivers/i965/brw_resource_texture.c index 07537fe44ef..4fbb0c2484d 100644 --- a/src/gallium/drivers/i965/brw_resource_texture.c +++ b/src/gallium/drivers/i965/brw_resource_texture.c @@ -594,7 +594,8 @@ fail: boolean brw_is_format_supported( struct pipe_screen *screen, enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags ) { return translate_tex_format(format) != BRW_SURFACEFORMAT_INVALID; diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index 0a7151bde44..172e222c057 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -218,9 +218,10 @@ brw_get_paramf(struct pipe_screen *screen, int param) static boolean brw_is_format_supported(struct pipe_screen *screen, - enum pipe_format format, + enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags) { static const enum pipe_format tex_supported[] = { @@ -276,6 +277,9 @@ brw_is_format_supported(struct pipe_screen *screen, const enum pipe_format *list; uint i; + if (sample_count > 1) + return FALSE; + if (tex_usage & PIPE_BIND_DEPTH_STENCIL) list = depth_supported; else if (tex_usage & PIPE_BIND_RENDER_TARGET) -- cgit v1.2.3 From bd771cda8e11a5f9a8bc5b8eab9ef4293df316e0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:25:07 +0200 Subject: trace: adapt to interface changes --- src/gallium/drivers/trace/tr_context.c | 63 +++++++++++++++++++--------------- src/gallium/drivers/trace/tr_screen.c | 5 ++- 2 files changed, 40 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 3d1fb96b91e..0edb685ac7b 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1157,61 +1157,72 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, static INLINE void -trace_context_surface_copy(struct pipe_context *_pipe, - struct pipe_surface *dest, - unsigned destx, unsigned desty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, - unsigned width, unsigned height) +trace_context_resource_copy_region(struct pipe_context *_pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource *src, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, + unsigned width, unsigned height) { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - dest = trace_surface_unwrap(tr_ctx, dest); - src = trace_surface_unwrap(tr_ctx, src); + dst = trace_resource_unwrap(tr_ctx, dst); + src = trace_resource_unwrap(tr_ctx, src); - trace_dump_call_begin("pipe_context", "surface_copy"); + trace_dump_call_begin("pipe_context", "resource_copy_region"); trace_dump_arg(ptr, pipe); - trace_dump_arg(ptr, dest); - trace_dump_arg(uint, destx); - trace_dump_arg(uint, desty); + trace_dump_arg(ptr, dst); + trace_dump_arg_struct(subresource, subdst); + trace_dump_arg(uint, dstx); + trace_dump_arg(uint, dsty); + trace_dump_arg(uint, dstz); trace_dump_arg(ptr, src); + trace_dump_arg_struct(subresource, subsrc); trace_dump_arg(uint, srcx); trace_dump_arg(uint, srcy); + trace_dump_arg(uint, srcz); trace_dump_arg(uint, width); trace_dump_arg(uint, height); - pipe->surface_copy(pipe, - dest, destx, desty, - src, srcx, srcy, width, height); + pipe->resource_copy_region(pipe, + dst, subdst, dstx, dsty, dstz, + src, subsrc, srcx, srcy, srcz, width, height); trace_dump_call_end(); } static INLINE void -trace_context_surface_fill(struct pipe_context *_pipe, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height, - unsigned value) +trace_context_resource_fill_region(struct pipe_context *_pipe, + struct pipe_resource *dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + unsigned width, unsigned height, + unsigned value) { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - dst = trace_surface_unwrap(tr_ctx, dst); + dst = trace_resource_unwrap(tr_ctx, dst); - trace_dump_call_begin("pipe_context", "surface_fill"); + trace_dump_call_begin("pipe_context", "resource_fill_region"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, dst); + trace_dump_arg_struct(subresource, subdst); trace_dump_arg(uint, dstx); trace_dump_arg(uint, dsty); + trace_dump_arg(uint, dstz); trace_dump_arg(uint, width); trace_dump_arg(uint, height); + trace_dump_arg(uint, value); - pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value); + pipe->resource_fill_region(pipe, dst, subdst, dstx, dsty, dstz, + width, height, value); trace_dump_call_end(); } @@ -1560,10 +1571,8 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.create_sampler_view = trace_create_sampler_view; tr_ctx->base.sampler_view_destroy = trace_sampler_view_destroy; tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers; - if (pipe->surface_copy) - tr_ctx->base.surface_copy = trace_context_surface_copy; - if (pipe->surface_fill) - tr_ctx->base.surface_fill = trace_context_surface_fill; + tr_ctx->base.resource_copy_region = trace_context_resource_copy_region; + tr_ctx->base.resource_fill_region = trace_context_resource_fill_region; tr_ctx->base.clear = trace_context_clear; tr_ctx->base.flush = trace_context_flush; tr_ctx->base.is_resource_referenced = trace_is_resource_referenced; diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 63a45d7e512..ffae6e94d11 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -134,6 +134,7 @@ static boolean trace_screen_is_format_supported(struct pipe_screen *_screen, enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned tex_usage, unsigned geom_flags) { @@ -146,10 +147,12 @@ trace_screen_is_format_supported(struct pipe_screen *_screen, trace_dump_arg(ptr, screen); trace_dump_arg(format, format); trace_dump_arg(int, target); + trace_dump_arg(uint, sample_count); trace_dump_arg(uint, tex_usage); trace_dump_arg(uint, geom_flags); - result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags); + result = screen->is_format_supported(screen, format, target, sample_count, + tex_usage, geom_flags); trace_dump_ret(bool, result); -- cgit v1.2.3 From fd578be828e1dd7c25160e7748b30b1421f4d0c7 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:25:16 +0200 Subject: identity: adapt to interface changes --- src/gallium/drivers/identity/id_context.c | 114 +++++++++++++++++------------- src/gallium/drivers/identity/id_screen.c | 2 + 2 files changed, 65 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 7e62213597c..bd1b5ea2d0e 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -601,55 +601,67 @@ identity_set_vertex_buffers(struct pipe_context *_pipe, buffers); } static void -identity_surface_copy(struct pipe_context *_pipe, - struct pipe_surface *_dst, - unsigned dstx, - unsigned dsty, - struct pipe_surface *_src, - unsigned srcx, - unsigned srcy, - unsigned width, - unsigned height) -{ - struct identity_context *id_pipe = identity_context(_pipe); - struct identity_surface *id_surface_dst = identity_surface(_dst); - struct identity_surface *id_surface_src = identity_surface(_src); - struct pipe_context *pipe = id_pipe->pipe; - struct pipe_surface *dst = id_surface_dst->surface; - struct pipe_surface *src = id_surface_src->surface; - - pipe->surface_copy(pipe, - dst, - dstx, - dsty, - src, - srcx, - srcy, - width, - height); -} - -static void -identity_surface_fill(struct pipe_context *_pipe, - struct pipe_surface *_dst, - unsigned dstx, - unsigned dsty, - unsigned width, - unsigned height, - unsigned value) -{ - struct identity_context *id_pipe = identity_context(_pipe); - struct identity_surface *id_surface_dst = identity_surface(_dst); - struct pipe_context *pipe = id_pipe->pipe; - struct pipe_surface *dst = id_surface_dst->surface; - - pipe->surface_fill(pipe, - dst, - dstx, - dsty, - width, - height, - value); +identity_resource_copy_region(struct pipe_context *_pipe, + struct pipe_resource *_dst, + struct pipe_subresource subdst, + unsigned dstx, + unsigned dsty, + unsigned dstz, + struct pipe_resource *_src, + struct pipe_subresource subsrc, + unsigned srcx, + unsigned srcy, + unsigned srcz, + unsigned width, + unsigned height) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct identity_resource *id_resource_dst = identity_resource(_dst); + struct identity_resource *id_resource_src = identity_resource(_src); + struct pipe_context *pipe = id_pipe->pipe; + struct pipe_resource *dst = id_resource_dst->resource; + struct pipe_resource *src = id_resource_src->resource; + + pipe->resource_copy_region(pipe, + dst, + subdst, + dstx, + dsty, + dstz, + src, + subsrc, + srcx, + srcy, + srcz, + width, + height); +} + +static void +identity_resource_fill_region(struct pipe_context *_pipe, + struct pipe_resource *_dst, + struct pipe_subresource subdst, + unsigned dstx, + unsigned dsty, + unsigned dstz, + unsigned width, + unsigned height, + unsigned value) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct identity_resource *id_resource_dst = identity_resource(_dst); + struct pipe_context *pipe = id_pipe->pipe; + struct pipe_resource *dst = id_resource_dst->resource; + + pipe->resource_fill_region(pipe, + dst, + subdst, + dstx, + dsty, + dstz, + width, + height, + value); } static void @@ -888,8 +900,8 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.set_fragment_sampler_views = identity_set_fragment_sampler_views; id_pipe->base.set_vertex_sampler_views = identity_set_vertex_sampler_views; id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers; - id_pipe->base.surface_copy = identity_surface_copy; - id_pipe->base.surface_fill = identity_surface_fill; + id_pipe->base.resource_copy_region = identity_resource_copy_region; + id_pipe->base.resource_fill_region = identity_resource_fill_region; id_pipe->base.clear = identity_clear; id_pipe->base.flush = identity_flush; id_pipe->base.is_resource_referenced = identity_is_resource_referenced; diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index 7671bded981..7082d60d1c9 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -91,6 +91,7 @@ static boolean identity_screen_is_format_supported(struct pipe_screen *_screen, enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned tex_usage, unsigned geom_flags) { @@ -100,6 +101,7 @@ identity_screen_is_format_supported(struct pipe_screen *_screen, return screen->is_format_supported(screen, format, target, + sample_count, tex_usage, geom_flags); } -- cgit v1.2.3 From 433701a7214fb792c3e8bdd71a0d025c09328f87 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:25:27 +0200 Subject: fo: adapt to interface changes --- src/gallium/drivers/failover/fo_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c index 9515cd8938c..2246c1468ca 100644 --- a/src/gallium/drivers/failover/fo_context.c +++ b/src/gallium/drivers/failover/fo_context.c @@ -156,8 +156,8 @@ struct pipe_context *failover_create( struct pipe_context *hw, failover_init_state_functions( failover ); - failover->pipe.surface_copy = hw->surface_copy; - failover->pipe.surface_fill = hw->surface_fill; + failover->pipe.resource_copy_region = hw->resource_copy_region; + failover->pipe.resource_fill_region = hw->resource_fill_region; #if 0 failover->pipe.texture_create = hw->texture_create; -- cgit v1.2.3 From b59b23a51dc17da59ccff0b3f8a73009056746e5 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:28:14 +0200 Subject: nouveau: adapt to interface changes this probably needs further cleanup (just getting a surface for the resource seems quite nonoptimal and potentially cause unnecessary copies I think) --- src/gallium/drivers/nouveau/nouveau_screen.c | 2 -- src/gallium/drivers/nv50/nv50_screen.c | 4 +++ src/gallium/drivers/nv50/nv50_surface.c | 38 ++++++++++++++++++++-------- src/gallium/drivers/nvfx/nv04_surface_2d.c | 9 +++---- src/gallium/drivers/nvfx/nvfx_miptree.c | 2 +- src/gallium/drivers/nvfx/nvfx_screen.c | 4 +++ src/gallium/drivers/nvfx/nvfx_surface.c | 37 ++++++++++++++++++++------- src/gallium/drivers/nvfx/nvfx_transfer.c | 6 +++-- 8 files changed, 72 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 233a91a2ffd..89d5ffa8aa3 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -51,8 +51,6 @@ nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment, if (bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL | - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SAMPLER_VIEW)) diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 2dd10424245..a8cb1e25d81 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -32,8 +32,12 @@ static boolean nv50_screen_is_format_supported(struct pipe_screen *pscreen, enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned tex_usage, unsigned geom_flags) { + if (sample_count > 1) + return FALSE; + if (tex_usage & PIPE_BIND_RENDER_TARGET) { switch (format) { case PIPE_FORMAT_B8G8R8X8_UNORM: diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index d905d95354f..40b8d255335 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -195,27 +195,40 @@ nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst, static void nv50_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, unsigned destx, unsigned desty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, + struct pipe_resource *dest, struct pipe_subresource subdst, + unsigned destx, unsigned desty, unsigned destz, + struct pipe_resource *src, struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, unsigned width, unsigned height) { struct nv50_context *nv50 = nv50_context(pipe); struct nv50_screen *screen = nv50->screen; + struct pipe_surface *ps_dst, *ps_src; assert((src->format == dest->format) || (nv50_2d_format_faithful(src->format) && nv50_2d_format_faithful(dest->format))); - nv50_surface_do_copy(screen, dest, destx, desty, src, srcx, - srcy, width, height); + ps_src = nv50_miptree_surface_new(pipe->screen, dest, subsrc.face, + subsrc.level, srcz, 0 /* bind flags */); + ps_dst = nv50_miptree_surface_new(pipe->screen, dest, subdst.face, + subdst.level, destz, 0 /* bindflags */); + + nv50_surface_do_copy(screen, ps_dst, destx, desty, ps_src, srcx, + srcy, width, height); + + nv50_miptree_surface_del(ps_src); + nv50_miptree_surface_del(ps_dst); } static void -nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, - unsigned destx, unsigned desty, unsigned width, - unsigned height, unsigned value) +nv50_surface_fill(struct pipe_context *pipe, struct pipe_resource *dest, + struct pipe_subresource subdst, + unsigned destx, unsigned desty, unsigned destz, + unsigned width, unsigned height, unsigned value) { struct nv50_context *nv50 = nv50_context(pipe); + struct pipe_surface *ps; struct nv50_screen *screen = nv50->screen; struct nouveau_channel *chan = screen->eng2d->channel; struct nouveau_grobj *eng2d = screen->eng2d; @@ -225,9 +238,12 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, if (format < 0) return; + ps = nv50_miptree_surface_new(pipe->screen, dest, subdst.face, + subdst.level, destz, 0 /* bind flags */); + WAIT_RING (chan, 32); - ret = nv50_surface_set(screen, dest, 1); + ret = nv50_surface_set(screen, ps, 1); if (ret) return; @@ -240,13 +256,15 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, OUT_RING (chan, desty); OUT_RING (chan, width); OUT_RING (chan, height); + + nv50_miptree_surface_del(ps); } void nv50_init_surface_functions(struct nv50_context *nv50) { - nv50->pipe.surface_copy = nv50_surface_copy; - nv50->pipe.surface_fill = nv50_surface_fill; + nv50->pipe.resource_copy_region = nv50_surface_copy; + nv50->pipe.resource_fill_region = nv50_surface_fill; } diff --git a/src/gallium/drivers/nvfx/nv04_surface_2d.c b/src/gallium/drivers/nvfx/nv04_surface_2d.c index 4ed574227d6..7acbb505df3 100644 --- a/src/gallium/drivers/nvfx/nv04_surface_2d.c +++ b/src/gallium/drivers/nvfx/nv04_surface_2d.c @@ -502,12 +502,9 @@ nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface* temp_ns; int temp_flags; - temp_flags = (ns->base.usage | - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION); + temp_flags = ns->base.usage; - ns->base.usage = (PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION); + ns->base.usage = 0; memset(&templ, 0, sizeof(templ)); templ.format = ns->base.texture->format; @@ -526,7 +523,7 @@ nv04_surface_wrap_for_render(struct pipe_screen *pscreen, temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags); temp_ns->backing = ns; - if(ns->base.usage & PIPE_BIND_BLIT_SOURCE) + if(1) /* hmm */ eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height); diff --git a/src/gallium/drivers/nvfx/nvfx_miptree.c b/src/gallium/drivers/nvfx/nvfx_miptree.c index aeb88e9ac96..b5639bb4645 100644 --- a/src/gallium/drivers/nvfx/nvfx_miptree.c +++ b/src/gallium/drivers/nvfx/nvfx_miptree.c @@ -300,7 +300,7 @@ nvfx_miptree_surface_del(struct pipe_surface *ps) if(ns->backing) { struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen; - if(ns->backing->base.usage & PIPE_BIND_BLIT_DESTINATION) + if(1 /*ns->backing->base.usage & PIPE_BIND_BLIT_DESTINATION*/) screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height); nvfx_miptree_surface_del(&ns->backing->base); } diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index 9f03ab1833b..1786af776aa 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -115,11 +115,15 @@ static boolean nvfx_screen_surface_format_supported(struct pipe_screen *pscreen, enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned tex_usage, unsigned geom_flags) { struct nvfx_screen *screen = nvfx_screen(pscreen); struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front; + if (sample_count > 1) + return FALSE; + if (tex_usage & PIPE_BIND_RENDER_TARGET) { switch (format) { case PIPE_FORMAT_B8G8R8A8_UNORM: diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c b/src/gallium/drivers/nvfx/nvfx_surface.c index 2e115650aeb..fc3a670d400 100644 --- a/src/gallium/drivers/nvfx/nvfx_surface.c +++ b/src/gallium/drivers/nvfx/nvfx_surface.c @@ -27,35 +27,54 @@ **************************************************************************/ #include "nvfx_context.h" +#include "nvfx_resource.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" static void nvfx_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, unsigned destx, unsigned desty, - struct pipe_surface *src, unsigned srcx, unsigned srcy, + struct pipe_resource *dest, struct pipe_subresource subdst, + unsigned destx, unsigned desty, unsigned destz, + struct pipe_resource *src, struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, unsigned width, unsigned height) { struct nvfx_context *nvfx = nvfx_context(pipe); struct nv04_surface_2d *eng2d = nvfx->screen->eng2d; + struct pipe_surface *ps_dst, *ps_src; - eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height); + ps_src = nvfx_miptree_surface_new(pipe->screen, dest, subsrc.face, + subsrc.level, srcz, 0 /* bind flags */); + ps_dst = nvfx_miptree_surface_new(pipe->screen, dest, subdst.face, + subdst.level, destz, 0 /* bindflags */); + + eng2d->copy(eng2d, ps_dst, destx, desty, ps_src, srcx, srcy, width, height); + + nvfx_miptree_surface_del(ps_src); + nvfx_miptree_surface_del(ps_dst); } static void -nvfx_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest, - unsigned destx, unsigned desty, unsigned width, - unsigned height, unsigned value) +nvfx_surface_fill(struct pipe_context *pipe, struct pipe_resource *dest, + struct pipe_subresource subdst, + unsigned destx, unsigned desty, unsigned destz, + unsigned width, unsigned height, unsigned value) { struct nvfx_context *nvfx = nvfx_context(pipe); + struct pipe_surface *ps; struct nv04_surface_2d *eng2d = nvfx->screen->eng2d; - eng2d->fill(eng2d, dest, destx, desty, width, height, value); + ps = nvfx_miptree_surface_new(pipe->screen, dest, subdst.face, + subdst.level, destz, 0 /* bind flags */); + + eng2d->fill(eng2d, ps, destx, desty, width, height, value); + + nvfx_miptree_surface_del(ps); } void nvfx_init_surface_functions(struct nvfx_context *nvfx) { - nvfx->pipe.surface_copy = nvfx_surface_copy; - nvfx->pipe.surface_fill = nvfx_surface_fill; + nvfx->pipe.resource_copy_region = nvfx_surface_copy; + nvfx->pipe.resource_fill_region = nvfx_surface_fill; } diff --git a/src/gallium/drivers/nvfx/nvfx_transfer.c b/src/gallium/drivers/nvfx/nvfx_transfer.c index b2ef27cf579..9ff0a93d307 100644 --- a/src/gallium/drivers/nvfx/nvfx_transfer.c +++ b/src/gallium/drivers/nvfx/nvfx_transfer.c @@ -40,11 +40,13 @@ static unsigned nvfx_transfer_bind_flags( unsigned transfer_usage ) { unsigned bind = 0; +#if 0 if (transfer_usage & PIPE_TRANSFER_WRITE) bind |= PIPE_BIND_BLIT_SOURCE; if (transfer_usage & PIPE_TRANSFER_READ) bind |= PIPE_BIND_BLIT_DESTINATION; +#endif return bind; } @@ -128,7 +130,7 @@ nvfx_miptree_transfer_new(struct pipe_context *pipe, src = pscreen->get_tex_surface(pscreen, pt, sr.face, sr.level, box->z, - PIPE_BIND_BLIT_SOURCE); + 0 /*PIPE_BIND_BLIT_SOURCE*/); /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ /* TODO: Check if SIFM can un-swizzle */ @@ -160,7 +162,7 @@ nvfx_miptree_transfer_del(struct pipe_context *pipe, ptx->sr.face, ptx->sr.level, ptx->box.z, - PIPE_BIND_BLIT_DESTINATION); + 0 /*PIPE_BIND_BLIT_DESTINATION*/); /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */ nvscreen->eng2d->copy(nvscreen->eng2d, -- cgit v1.2.3 From 39b4bf71b55ce4553e877868dcbf6e7502cbc696 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:29:17 +0200 Subject: r300g: adapt to interface changes might need further cleanup. Using surfaces internally for the u_blitter code seems nonoptimal. --- src/gallium/drivers/r300/r300_blit.c | 73 ++++++++++++++++++++++++-------- src/gallium/drivers/r300/r300_blit.h | 18 +++++--- src/gallium/drivers/r300/r300_context.c | 4 +- src/gallium/drivers/r300/r300_screen.c | 4 ++ src/gallium/drivers/r300/r300_transfer.c | 51 +++++++--------------- 5 files changed, 89 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 85c2c149016..2bf9317803e 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -117,25 +117,36 @@ static void r300_hw_copy(struct pipe_context* pipe, /* Copy a block of pixels from one surface to another. */ void r300_surface_copy(struct pipe_context* pipe, - struct pipe_surface* dst, - unsigned dstx, unsigned dsty, - struct pipe_surface* src, - unsigned srcx, unsigned srcy, + struct pipe_resource* dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource* src, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, unsigned width, unsigned height) { - enum pipe_format old_format = dst->texture->format; + struct pipe_screen *screen = pipe->screen; + enum pipe_format old_format = dst->format; enum pipe_format new_format = old_format; + struct pipe_surface *srcsurf, *dstsurf; + unsigned bind; - if (dst->texture->format != src->texture->format) { + if (util_format_is_depth_or_stencil(dst->format)) + bind = PIPE_BIND_DEPTH_STENCIL; + else + bind = PIPE_BIND_RENDER_TARGET; + + if (dst->format != src->format) { debug_printf("r300: Implementation error: Format mismatch in %s\n" " : src: %s dst: %s\n", __FUNCTION__, - util_format_short_name(src->texture->format), - util_format_short_name(dst->texture->format)); + util_format_short_name(src->format), + util_format_short_name(dst->format)); debug_assert(0); } if (!pipe->screen->is_format_supported(pipe->screen, - old_format, src->texture->target, + old_format, src->target, + src->nr_samples, PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW, 0) && util_format_is_plain(old_format)) { @@ -164,36 +175,64 @@ void r300_surface_copy(struct pipe_context* pipe, src->format = new_format; r300_texture_reinterpret_format(pipe->screen, - dst->texture, new_format); + dst, new_format); r300_texture_reinterpret_format(pipe->screen, - src->texture, new_format); + src, new_format); } - r300_hw_copy(pipe, dst, dstx, dsty, src, srcx, srcy, width, height); + srcsurf = screen->get_tex_surface(screen, src, + subsrc.face, subsrc.level, srcz, + PIPE_BIND_SAMPLER_VIEW); + + dstsurf = screen->get_tex_surface(screen, dst, + subdst.face, subdst.level, dstz, + bind); + + r300_hw_copy(pipe, dstsurf, dstx, dsty, srcsurf, srcx, srcy, width, height); + + pipe_surface_reference(&srcsurf, NULL); + pipe_surface_reference(&dstsurf, NULL); if (old_format != new_format) { dst->format = old_format; src->format = old_format; r300_texture_reinterpret_format(pipe->screen, - dst->texture, old_format); + dst, old_format); r300_texture_reinterpret_format(pipe->screen, - src->texture, old_format); + src, old_format); } } /* Fill a region of a surface with a constant value. */ void r300_surface_fill(struct pipe_context* pipe, - struct pipe_surface* dst, - unsigned dstx, unsigned dsty, + struct pipe_resource* dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, unsigned width, unsigned height, unsigned value) { + struct pipe_screen *screen = pipe->screen; struct r300_context* r300 = r300_context(pipe); + struct pipe_surface *dstsurf; + unsigned bind; + + if (util_format_is_depth_or_stencil(dst->format)) + bind = PIPE_BIND_DEPTH_STENCIL; + else + bind = PIPE_BIND_RENDER_TARGET; + + dstsurf = screen->get_tex_surface(screen, dst, + subdst.face, + subdst.level, + dstz, + bind); r300_blitter_save_states(r300); util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state); util_blitter_fill(r300->blitter, - dst, dstx, dsty, width, height, value); + dstsurf, dstx, dsty, width, height, value); + + pipe_surface_reference(&dstsurf, NULL); } diff --git a/src/gallium/drivers/r300/r300_blit.h b/src/gallium/drivers/r300/r300_blit.h index 029e4f98e7d..c97872662aa 100644 --- a/src/gallium/drivers/r300/r300_blit.h +++ b/src/gallium/drivers/r300/r300_blit.h @@ -24,7 +24,8 @@ #define R300_BLIT_H struct pipe_context; -struct pipe_surface; +struct pipe_resource; +struct pipe_subresource; void r300_clear(struct pipe_context* pipe, unsigned buffers, @@ -33,15 +34,18 @@ void r300_clear(struct pipe_context* pipe, unsigned stencil); void r300_surface_copy(struct pipe_context* pipe, - struct pipe_surface* dst, - unsigned dstx, unsigned dsty, - struct pipe_surface* src, - unsigned srcx, unsigned srcy, + struct pipe_resource* dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource* src, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, unsigned width, unsigned height); void r300_surface_fill(struct pipe_context* pipe, - struct pipe_surface* dst, - unsigned dstx, unsigned dsty, + struct pipe_resource* dst, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, unsigned width, unsigned height, unsigned value); diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index e84bce0010f..b3ef97fa52b 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -173,8 +173,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.destroy = r300_destroy_context; r300->context.clear = r300_clear; - r300->context.surface_copy = r300_surface_copy; - r300->context.surface_fill = r300_surface_fill; + r300->context.resource_copy_region = r300_surface_copy; + r300->context.resource_fill_region = r300_surface_fill; if (r300screen->caps.has_tcl) { r300->context.draw_arrays = r300_draw_arrays; diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index c0391267031..b7f1c617f03 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -198,6 +198,7 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param) static boolean r300_is_format_supported(struct pipe_screen* screen, enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned usage, unsigned geom_flags) { @@ -221,6 +222,9 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, return FALSE; } + if (sample_count > 1) + return FALSE; + /* Check sampler format support. */ if ((usage & PIPE_BIND_SAMPLER_VIEW) && /* Z24 cannot be sampled from on non-r5xx. */ diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index 0dae9ef98b7..f0f87c5e2bc 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -56,63 +56,44 @@ r300_transfer(struct pipe_transfer* transfer) static void r300_copy_from_tiled_texture(struct pipe_context *ctx, struct r300_transfer *r300transfer) { - struct pipe_screen *screen = ctx->screen; struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer; struct pipe_resource *tex = transfer->resource; - struct pipe_surface *src, *dst; + struct pipe_subresource subdst; - src = screen->get_tex_surface(screen, tex, - transfer->sr.face, - transfer->sr.level, - transfer->box.z, - PIPE_BIND_BLIT_SOURCE); + subdst.face = 0; + subdst.level = 0; - dst = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b, - 0, 0, 0, - PIPE_BIND_BLIT_DESTINATION); - - ctx->surface_copy(ctx, dst, 0, 0, src, - transfer->box.x, transfer->box.y, - transfer->box.width, transfer->box.height); - - pipe_surface_reference(&src, NULL); - pipe_surface_reference(&dst, NULL); + ctx->resource_copy_region(ctx, &r300transfer->detiled_texture->b.b, subdst, + 0, 0, 0, + tex, transfer->sr, + transfer->box.x, transfer->box.y, transfer->box.z, + transfer->box.width, transfer->box.height); } /* Copy a detiled texture to a tiled one. */ static void r300_copy_into_tiled_texture(struct pipe_context *ctx, struct r300_transfer *r300transfer) { - struct pipe_screen *screen = ctx->screen; struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer; struct pipe_resource *tex = transfer->resource; - struct pipe_surface *src, *dst; + struct pipe_subresource subsrc; - src = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b, - 0, 0, 0, - PIPE_BIND_BLIT_SOURCE); - - dst = screen->get_tex_surface(screen, tex, - transfer->sr.face, - transfer->sr.level, - transfer->box.z, - PIPE_BIND_BLIT_DESTINATION); + subsrc.face = 0; + subsrc.level = 0; /* XXX this flush prevents the following DRM error from occuring: * [drm:radeon_cs_ioctl] *ERROR* Failed to parse relocation ! * Reproducible with perf/copytex. */ ctx->flush(ctx, 0, NULL); - ctx->surface_copy(ctx, dst, - transfer->box.x, transfer->box.y, - src, 0, 0, - transfer->box.width, transfer->box.height); + ctx->resource_copy_region(ctx, tex, transfer->sr, + transfer->box.x, transfer->box.y, transfer->box.z, + &r300transfer->detiled_texture->b.b, subsrc, + 0, 0, 0, + transfer->box.width, transfer->box.height); /* XXX this flush fixes a few piglit tests (e.g. glean/pixelFormats). */ ctx->flush(ctx, 0, NULL); - - pipe_surface_reference(&src, NULL); - pipe_surface_reference(&dst, NULL); } struct pipe_transfer* -- cgit v1.2.3 From eb2b668b3705f8091df716f342d72d32d9f31aea Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:30:01 +0200 Subject: svga: adapt to interface changes might need further cleanup. Using surfaces internally just to be able to use the existing code might cause unnecessary copies afaict. --- src/gallium/drivers/svga/svga_pipe_blit.c | 51 +++++++++++++++++++++---------- src/gallium/drivers/svga/svga_screen.c | 10 ++++-- 2 files changed, 42 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c b/src/gallium/drivers/svga/svga_pipe_blit.c index 889da29e28b..2dd99b46316 100644 --- a/src/gallium/drivers/svga/svga_pipe_blit.c +++ b/src/gallium/drivers/svga/svga_pipe_blit.c @@ -28,33 +28,47 @@ #include "svga_debug.h" #include "svga_cmd.h" #include "svga_surface.h" +#include "util/u_surface.h" #define FILE_DEBUG_FLAG DEBUG_BLIT +/* XXX I got my doubts about this, should maybe use svga_texture_copy_handle directly? */ static void svga_surface_copy(struct pipe_context *pipe, - struct pipe_surface *dest, - unsigned destx, unsigned desty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, + struct pipe_resource* dst_tex, + struct pipe_subresource subdst, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_resource* src_tex, + struct pipe_subresource subsrc, + unsigned srcx, unsigned srcy, unsigned srcz, unsigned width, unsigned height) { struct svga_context *svga = svga_context(pipe); + struct pipe_screen *screen = pipe->screen; SVGA3dCopyBox *box; enum pipe_error ret; + struct pipe_surface *srcsurf, *dstsurf; svga_hwtnl_flush_retry( svga ); + srcsurf = screen->get_tex_surface(screen, src_tex, + subsrc.face, subsrc.level, srcz, + PIPE_BIND_SAMPLER_VIEW); + + dstsurf = screen->get_tex_surface(screen, dst_tex, + subdst.face, subdst.level, dstz, + PIPE_BIND_RENDER_TARGET); + SVGA_DBG(DEBUG_DMA, "blit to sid %p (%d,%d), from sid %p (%d,%d) sz %dx%d\n", - svga_surface(dest)->handle, - destx, desty, - svga_surface(src)->handle, + svga_surface(dstsurf)->handle, + dstx, dsty, + svga_surface(srcsurf)->handle, srcx, srcy, width, height); ret = SVGA3D_BeginSurfaceCopy(svga->swc, - src, - dest, + srcsurf, + dstsurf, &box, 1); if(ret != PIPE_OK) { @@ -62,15 +76,15 @@ static void svga_surface_copy(struct pipe_context *pipe, svga_context_flush(svga, NULL); ret = SVGA3D_BeginSurfaceCopy(svga->swc, - src, - dest, + srcsurf, + dstsurf, &box, 1); assert(ret == PIPE_OK); } - box->x = destx; - box->y = desty; + box->x = dstx; + box->y = dsty; box->z = 0; box->w = width; box->h = height; @@ -81,13 +95,18 @@ static void svga_surface_copy(struct pipe_context *pipe, SVGA_FIFOCommitAll(svga->swc); - svga_surface(dest)->dirty = TRUE; - svga_propagate_surface(pipe, dest); + svga_surface(dstsurf)->dirty = TRUE; + svga_propagate_surface(pipe, dstsurf); + + pipe_surface_reference(&srcsurf, NULL); + pipe_surface_reference(&dstsurf, NULL); + } void svga_init_blit_functions(struct svga_context *svga) { - svga->pipe.surface_copy = svga_surface_copy; + svga->pipe.resource_copy_region = svga_surface_copy; + svga->pipe.resource_fill_region = util_resource_fill_region; } diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 27ac09e275d..b24af329218 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -237,17 +237,21 @@ svga_translate_format_cap(enum pipe_format format) static boolean svga_is_format_supported( struct pipe_screen *screen, - enum pipe_format format, + enum pipe_format format, enum pipe_texture_target target, - unsigned tex_usage, + unsigned sample_count, + unsigned tex_usage, unsigned geom_flags ) { struct svga_winsys_screen *sws = svga_screen(screen)->sws; SVGA3dDevCapIndex index; SVGA3dDevCapResult result; - + assert(tex_usage); + if (sample_count > 1) + return FALSE; + /* Override host capabilities */ if (tex_usage & PIPE_BIND_RENDER_TARGET) { switch(format) { -- cgit v1.2.3 From 8bd87b662f70070686fdfbea36f3660bd2586e32 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:32:41 +0200 Subject: st/python: adapt to interface changes compile tested only. Should probably change the python surface_copy/fill functions also into resource_copy/fill_region functions and adapt the code using them. --- src/gallium/state_trackers/python/p_context.i | 30 +++++++++++++++++----- src/gallium/state_trackers/python/p_device.i | 10 +++++--- src/gallium/tests/python/retrace/interpreter.py | 4 +-- src/gallium/tests/python/tests/surface_copy.py | 7 ++--- src/gallium/tests/python/tests/texture_blit.py | 18 +++++++------ src/gallium/tests/python/tests/texture_transfer.py | 7 ++--- 6 files changed, 49 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 3c5509cb5e4..3d7b640b472 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -413,16 +413,17 @@ error1: /* * Surface functions */ - + void surface_copy(struct st_surface *dst, unsigned destx, unsigned desty, struct st_surface *src, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { +/* XXX struct pipe_surface *_dst = NULL; struct pipe_surface *_src = NULL; - + _dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION); if(!_dst) SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing"); @@ -430,12 +431,20 @@ error1: _src = st_pipe_surface(src, PIPE_BIND_BLIT_SOURCE); if(!_src) SWIG_exception(SWIG_ValueError, "couldn't acquire source surface for reading"); - + $self->pipe->surface_copy($self->pipe, _dst, destx, desty, _src, srcx, srcy, width, height); - + fail: pipe_surface_reference(&_src, NULL); pipe_surface_reference(&_dst, NULL); +*/ + struct pipe_subresource subdst, subsrc; + subsrc.face = src->face; + subsrc.level = src->level; + subdst.face = dst->face; + subdst.level = dst->level; + $self->pipe->resource_copy_region($self->pipe, dst->texture, subdst, destx, desty, dst->zslice, + src->texture, subsrc, srcx, srcy, src->zslice, width, height); } void surface_fill(struct st_surface *dst, @@ -443,16 +452,23 @@ error1: unsigned width, unsigned height, unsigned value) { +/* XXX struct pipe_surface *_dst = NULL; - - _dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION); + + _dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION); if(!_dst) SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing"); $self->pipe->surface_fill($self->pipe, _dst, x, y, width, height, value); - + fail: pipe_surface_reference(&_dst, NULL); +*/ + struct pipe_subresource subdst; + subdst.face = dst->face; + subdst.level = dst->level; + $self->pipe->resource_fill_region($self->pipe, dst->texture, subdst, x, y, dst->zslice, + width, height, value); } %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); diff --git a/src/gallium/state_trackers/python/p_device.i b/src/gallium/state_trackers/python/p_device.i index 959c13f54d9..d55086fefd5 100644 --- a/src/gallium/state_trackers/python/p_device.i +++ b/src/gallium/state_trackers/python/p_device.i @@ -85,16 +85,18 @@ struct st_device { */ int is_format_supported( enum pipe_format format, enum pipe_texture_target target, + unsigned sample_count, unsigned bind, unsigned geom_flags ) { /* We can't really display surfaces with the python statetracker so mask * out that usage */ bind &= ~PIPE_BIND_DISPLAY_TARGET; - return $self->screen->is_format_supported( $self->screen, - format, - target, - bind, + return $self->screen->is_format_supported( $self->screen, + format, + target, + sample_count, + bind, geom_flags ); } diff --git a/src/gallium/tests/python/retrace/interpreter.py b/src/gallium/tests/python/retrace/interpreter.py index e58a69322ea..4599d68d7d5 100755 --- a/src/gallium/tests/python/retrace/interpreter.py +++ b/src/gallium/tests/python/retrace/interpreter.py @@ -230,8 +230,8 @@ class Screen(Object): context = self.real.context_create() return Context(self.interpreter, context) - def is_format_supported(self, format, target, bind, geom_flags): - return self.real.is_format_supported(format, target, bind, geom_flags) + def is_format_supported(self, format, target, sample_count, bind, geom_flags): + return self.real.is_format_supported(format, target, sample_count, bind, geom_flags) def resource_create(self, templat): return self.real.resource_create( diff --git a/src/gallium/tests/python/tests/surface_copy.py b/src/gallium/tests/python/tests/surface_copy.py index 8d841644035..7a6ede38044 100755 --- a/src/gallium/tests/python/tests/surface_copy.py +++ b/src/gallium/tests/python/tests/surface_copy.py @@ -70,13 +70,14 @@ class TextureTest(TestCase): face = self.face level = self.level zslice = self.zslice - + bind = PIPE_BIND_SAMPLER_VIEW geom_flags = 0 - if not dev.is_format_supported(format, target, bind, geom_flags): + sample_count = 0 + if not dev.is_format_supported(format, target, sample_count, bind, geom_flags): raise TestSkip - if not dev.is_format_supported(format, target, bind, geom_flags): + if not dev.is_format_supported(format, target, sample_count, bind, geom_flags): raise TestSkip # textures diff --git a/src/gallium/tests/python/tests/texture_blit.py b/src/gallium/tests/python/tests/texture_blit.py index 77f006ea04e..58706dab93d 100755 --- a/src/gallium/tests/python/tests/texture_blit.py +++ b/src/gallium/tests/python/tests/texture_blit.py @@ -130,17 +130,18 @@ class TextureColorSampleTest(TestCase): zslice = self.zslice minz = 0.0 maxz = 1.0 - + bind = PIPE_BIND_SAMPLER_VIEW geom_flags = 0 + sample_count = 0 if width != height: geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE if not is_pot(width) or not is_pot(height) or not is_pot(depth): geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO - - if not dev.is_format_supported(format, target, bind, geom_flags): + + if not dev.is_format_supported(format, target, sample_count, bind, geom_flags): raise TestSkip - + # disabled blending/masking blend = Blend() blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE @@ -348,17 +349,18 @@ class TextureDepthSampleTest(TestCase): zslice = self.zslice minz = 0.0 maxz = 1.0 - + bind = PIPE_BIND_SAMPLER_VIEW geom_flags = 0 + sample_count = 0 if width != height: geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE if not is_pot(width) or not is_pot(height) or not is_pot(depth): geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO - - if not dev.is_format_supported(format, target, bind, geom_flags): + + if not dev.is_format_supported(format, target, sample_count, bind, geom_flags): raise TestSkip - + # disabled blending/masking blend = Blend() blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE diff --git a/src/gallium/tests/python/tests/texture_transfer.py b/src/gallium/tests/python/tests/texture_transfer.py index 4aa3d6c709b..65c919bc64d 100755 --- a/src/gallium/tests/python/tests/texture_transfer.py +++ b/src/gallium/tests/python/tests/texture_transfer.py @@ -71,12 +71,13 @@ class TextureTest(TestCase): face = self.face level = self.level zslice = self.zslice - + bind = PIPE_BIND_SAMPLER_VIEW geom_flags = 0 - if not dev.is_format_supported(format, target, bind, geom_flags): + sample_count = 0 + if not dev.is_format_supported(format, target, sample_count, bind, geom_flags): raise TestSkip - + # textures texture = dev.resource_create( target = target, -- cgit v1.2.3 From 48780ec9f99d7af4e98614be597adc3534d6918c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:33:27 +0200 Subject: st/xorg: adapt to interface changes --- src/gallium/state_trackers/xorg/xorg_dri2.c | 2 + src/gallium/state_trackers/xorg/xorg_exa.c | 91 ++++++++++--------------- src/gallium/state_trackers/xorg/xorg_exa.h | 1 - src/gallium/state_trackers/xorg/xorg_renderer.c | 36 ++++------ 4 files changed, 54 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index b90f9c908d2..35741f86842 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -437,10 +437,12 @@ xorg_dri2_init(ScreenPtr pScreen) ms->d_depth_bits_last = ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24X8_UNORM, PIPE_TEXTURE_2D, + 0, PIPE_BIND_DEPTH_STENCIL, 0); ms->ds_depth_bits_last = ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, + 0, PIPE_BIND_DEPTH_STENCIL, 0); return DRI2ScreenInit(pScreen, &dri2info); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 65be8c332a5..6657f7391b2 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -347,7 +347,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) XORG_FALLBACK("not GXcopy"); if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, - priv->tex->target, + priv->tex->target, 0, PIPE_BIND_RENDER_TARGET, 0)) { XORG_FALLBACK("format %s", util_format_name(priv->tex->format)); } @@ -428,39 +428,26 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, XORG_FALLBACK("alu not GXcopy"); if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, - priv->tex->target, + priv->tex->target, 0, PIPE_BIND_RENDER_TARGET, 0)) XORG_FALLBACK("pDst format %s", util_format_name(priv->tex->format)); if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format, - src_priv->tex->target, + src_priv->tex->target, 0, PIPE_BIND_SAMPLER_VIEW, 0)) XORG_FALLBACK("pSrc format %s", util_format_name(src_priv->tex->format)); exa->copy.src = src_priv; exa->copy.dst = priv; - /* For same-surface copies, the pipe->surface_copy path is clearly - * superior, providing it is implemented. In other cases it's not - * clear what the better path would be, and eventually we'd - * probably want to gather timings and choose dynamically. + /* XXX this used to use resource_copy_region for same-surface copies, + * but they were redefined to not allow overlaps (some of the util code + * always assumed this anyway). + * Drivers should implement accelerated resource_copy_region or it will + * be slow - disable for now. */ - if (exa->pipe->surface_copy && - exa->copy.src == exa->copy.dst) { - + if (0 && exa->copy.src != exa->copy.dst) { exa->copy.use_surface_copy = TRUE; - - exa->copy.src_surface = - exa->scrn->get_tex_surface( exa->scrn, - exa->copy.src->tex, - 0, 0, 0, - PIPE_BIND_BLIT_SOURCE); - - exa->copy.dst_surface = - exa->scrn->get_tex_surface( exa->scrn, - exa->copy.dst->tex, - 0, 0, 0, - PIPE_BIND_BLIT_DESTINATION ); } else { exa->copy.use_surface_copy = FALSE; @@ -476,7 +463,7 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, exa->scrn->get_tex_surface(exa->scrn, exa->copy.dst->tex, 0, 0, 0, - PIPE_BIND_BLIT_DESTINATION); + PIPE_BIND_RENDER_TARGET); renderer_copy_prepare(exa->renderer, @@ -506,14 +493,19 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, (void) priv; if (exa->copy.use_surface_copy) { - /* XXX: consider exposing >1 box in surface_copy interface. - */ - exa->pipe->surface_copy( exa->pipe, - exa->copy.dst_surface, - dstX, dstY, - exa->copy.src_surface, - srcX, srcY, - width, height ); + struct pipe_subresource subdst, subsrc; + subdst.face = 0; + subdst.level = 0; + subsrc.face = 0; + subsrc.level = 0; + exa->pipe->resource_copy_region( exa->pipe, + exa->copy.dst->tex, + subdst, + dstX, dstY, 0, + exa->copy.src->tex, + subsrc, + srcX, srcY, 0, + width, height ); } else { renderer_copy_pixmap(exa->renderer, @@ -540,7 +532,6 @@ ExaDoneCopy(PixmapPtr pPixmap) exa->copy.src = NULL; exa->copy.dst = NULL; - pipe_surface_reference(&exa->copy.src_surface, NULL); pipe_surface_reference(&exa->copy.dst_surface, NULL); pipe_resource_reference(&exa->copy.src_texture, NULL); } @@ -639,7 +630,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex"); if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, - priv->tex->target, + priv->tex->target, 0, PIPE_BIND_RENDER_TARGET, 0)) XORG_FALLBACK("pDst format: %s", util_format_name(priv->tex->format)); @@ -654,7 +645,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, XORG_FALLBACK("pSrc %s", !priv ? "!priv" : "!priv->tex"); if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, - priv->tex->target, + priv->tex->target, 0, PIPE_BIND_SAMPLER_VIEW, 0)) XORG_FALLBACK("pSrc format: %s", util_format_name(priv->tex->format)); @@ -671,7 +662,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, XORG_FALLBACK("pMask %s", !priv ? "!priv" : "!priv->tex"); if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, - priv->tex->target, + priv->tex->target, 0, PIPE_BIND_SAMPLER_VIEW, 0)) XORG_FALLBACK("pMask format: %s", util_format_name(priv->tex->format)); @@ -890,23 +881,19 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, texture = exa->scrn->resource_create(exa->scrn, &template); if (priv->tex) { - struct pipe_surface *dst_surf; + struct pipe_subresource subdst, subsrc; struct pipe_surface *src_surf; - dst_surf = exa->scrn->get_tex_surface( - exa->scrn, texture, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION); - src_surf = xorg_gpu_surface(exa->pipe->screen, priv); - if (exa->pipe->surface_copy) { - exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf, - 0, 0, min(width, texture->width0), - min(height, texture->height0)); - } else { - util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf, - 0, 0, min(width, texture->width0), - min(height, texture->height0)); - } - exa->scrn->tex_surface_destroy(dst_surf); - exa->scrn->tex_surface_destroy(src_surf); + subdst.face = 0; + subdst.level = 0; + subsrc.face = 0; + subsrc.level = 0; + exa->pipe->resource_copy_region(exa->pipe, texture, + subdst, 0, 0, 0, + priv->tex, + subsrc, 0, 0, 0, + min(width, texture->width0), + min(height, texture->height0)); } pipe_resource_reference(&priv->tex, texture); @@ -1074,11 +1061,7 @@ out_err: struct pipe_surface * xorg_gpu_surface(struct pipe_screen *scrn, struct exa_pixmap_priv *priv) { - - /* seems to get called both for blits and render target usage */ return scrn->get_tex_surface(scrn, priv->tex, 0, 0, 0, - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_RENDER_TARGET); } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index a35e9a5c901..86a1afc06e6 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -40,7 +40,6 @@ struct exa_context struct exa_pixmap_priv *src; struct exa_pixmap_priv *dst; - struct pipe_surface *src_surface; struct pipe_surface *dst_surface; struct pipe_resource *src_texture; diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 583493116d5..1576e5ea01b 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -449,7 +449,7 @@ void renderer_copy_prepare(struct xorg_renderer *r, struct xorg_shader shader; assert(screen->is_format_supported(screen, dst_surface->format, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0)); (void) screen; @@ -525,7 +525,7 @@ renderer_clone_texture(struct xorg_renderer *r, /* the coming in texture should already have that invariance */ debug_assert(screen->is_format_supported(screen, src->format, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, 0)); format = src->format; @@ -548,25 +548,19 @@ renderer_clone_texture(struct xorg_renderer *r, { /* copy source framebuffer surface into texture */ - struct pipe_surface *ps_read = screen->get_tex_surface( - screen, src, 0, 0, 0, PIPE_BIND_BLIT_SOURCE); - struct pipe_surface *ps_tex = screen->get_tex_surface( - screen, pt, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION ); - if (pipe->surface_copy) { - pipe->surface_copy(pipe, - ps_tex, /* dest */ - 0, 0, /* destx/y */ - ps_read, - 0, 0, src->width0, src->height0); - } else { - util_surface_copy(pipe, FALSE, - ps_tex, /* dest */ - 0, 0, /* destx/y */ - ps_read, - 0, 0, src->width0, src->height0); - } - pipe_surface_reference(&ps_read, NULL); - pipe_surface_reference(&ps_tex, NULL); + struct pipe_subresource subsrc, subdst; + subsrc.face = 0; + subsrc.level = 0; + subdst.face = 0; + subdst.level = 0; + pipe->resource_copy_region(pipe, + pt, /* dest */ + subdst, + 0, 0, 0, /* destx/y/z */ + src, + subsrc, + 0, 0, 0, + src->width0, src->height0); } return pt; -- cgit v1.2.3 From c36c3d86b62b525291b1c6527de3ac5de93a2faf Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:33:37 +0200 Subject: st/vega: adapt to interface changes --- src/gallium/state_trackers/vega/image.c | 6 ++-- src/gallium/state_trackers/vega/renderer.c | 36 +++++++++------------- src/gallium/state_trackers/vega/vg_context.c | 6 ++-- src/gallium/state_trackers/vega/vg_manager.c | 46 +++++++++++----------------- 4 files changed, 37 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index 9c323b1809c..7c421dfcd4e 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -270,7 +270,7 @@ struct vg_image * image_create(VGImageFormat format, image->sampler.normalized_coords = 1; assert(screen->is_format_supported(screen, pformat, PIPE_TEXTURE_2D, - PIPE_BIND_SAMPLER_VIEW, 0)); + 0, PIPE_BIND_SAMPLER_VIEW, 0)); memset(&pt, 0, sizeof(pt)); pt.target = PIPE_TEXTURE_2D; @@ -576,7 +576,7 @@ void image_set_pixels(VGint dx, VGint dy, pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); surf = screen->get_tex_surface(screen, image_texture(src), 0, 0, 0, - PIPE_BIND_BLIT_SOURCE); + 0 /* no bind flags as surf isn't actually used??? */); vg_copy_surface(ctx, strb->surface, dx, dy, surf, sx+src->x, sy+src->y, width, height); @@ -601,7 +601,7 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy, pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); surf = screen->get_tex_surface(screen, image_texture(dst), 0, 0, 0, - PIPE_BIND_BLIT_SOURCE); + 0 /* no bind flags as surf isn't actually used??? */); vg_copy_surface(ctx, surf, dst->x + dx, dst->y + dy, strb->surface, sx, sy, width, height); diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index e6aea482a76..fe0f166e885 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -308,7 +308,7 @@ void renderer_copy_texture(struct renderer *ctx, #endif assert(screen->is_format_supported(screen, dst_surf->format, PIPE_TEXTURE_2D, - PIPE_BIND_RENDER_TARGET, 0)); + 0, PIPE_BIND_RENDER_TARGET, 0)); /* save state (restored below) */ cso_save_blend(ctx->cso); @@ -415,7 +415,7 @@ void renderer_copy_surface(struct renderer *ctx, struct pipe_sampler_view view_templ; struct pipe_sampler_view *view; struct pipe_resource texTemp, *tex; - struct pipe_surface *texSurf; + struct pipe_subresource subsrc, subdst; struct pipe_framebuffer_state fb; struct st_framebuffer *stfb = ctx->owner->draw_buffer; const int srcW = abs(srcX1 - srcX0); @@ -441,11 +441,11 @@ void renderer_copy_surface(struct renderer *ctx, } assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D, - PIPE_BIND_SAMPLER_VIEW, 0)); + 0, PIPE_BIND_SAMPLER_VIEW, 0)); assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, - PIPE_BIND_SAMPLER_VIEW, 0)); + 0, PIPE_BIND_SAMPLER_VIEW, 0)); assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, - PIPE_BIND_RENDER_TARGET, 0)); + 0, PIPE_BIND_RENDER_TARGET, 0)); /* * XXX for now we're always creating a temporary texture. @@ -460,6 +460,7 @@ void renderer_copy_surface(struct renderer *ctx, texTemp.width0 = srcW; texTemp.height0 = srcH; texTemp.depth0 = 1; + texTemp.bind = PIPE_BIND_SAMPLER_VIEW; tex = screen->resource_create(screen, &texTemp); if (!tex) @@ -471,24 +472,15 @@ void renderer_copy_surface(struct renderer *ctx, if (!view) return; - texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, - PIPE_BIND_RENDER_TARGET); - - /* load temp texture */ - if (pipe->surface_copy) { - pipe->surface_copy(pipe, - texSurf, 0, 0, /* dest */ - src, srcLeft, srcTop, /* src */ - srcW, srcH); /* size */ - } else { - util_surface_copy(pipe, FALSE, - texSurf, 0, 0, /* dest */ - src, srcLeft, srcTop, /* src */ - srcW, srcH); /* size */ - } + subdst.face = 0; + subdst.level = 0; + subsrc.face = src->face; + subsrc.level = src->level; - /* free the surface, update the texture if necessary.*/ - screen->tex_surface_destroy(texSurf); + pipe->resource_copy_region(pipe, + tex, subdst, 0, 0, 0, /* dest */ + src->texture, subsrc, srcLeft, srcTop, src->zslice, /* src */ + srcW, srcH); /* size */ /* save state (restored below) */ cso_save_blend(ctx->cso); diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 1a8952ce34a..b55a2b57bed 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -451,8 +451,7 @@ void vg_prepare_blend_surface(struct vg_context *ctx) dest_surface = pipe->screen->get_tex_surface(pipe->screen, stfb->blend_texture_view->texture, 0, 0, 0, - PIPE_BIND_BLIT_DESTINATION | - PIPE_BIND_RENDER_TARGET); + PIPE_BIND_RENDER_TARGET); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, view, @@ -488,8 +487,7 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx) dest_surface = pipe->screen->get_tex_surface(pipe->screen, stfb->blend_texture_view->texture, 0, 0, 0, - PIPE_BIND_BLIT_DESTINATION | - PIPE_BIND_RENDER_TARGET); + PIPE_BIND_RENDER_TARGET); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c index aecac28e7ee..8a62a191207 100644 --- a/src/gallium/state_trackers/vega/vg_manager.c +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -122,28 +122,22 @@ setup_new_alpha_mask(struct vg_context *ctx, struct st_framebuffer *stfb) /* if we had an old surface copy it over */ if (old_sampler_view) { - struct pipe_surface *surface = pipe->screen->get_tex_surface( - pipe->screen, - stfb->alpha_mask_view->texture, - 0, 0, 0, - PIPE_BIND_RENDER_TARGET | - PIPE_BIND_BLIT_DESTINATION); - struct pipe_surface *old_surface = pipe->screen->get_tex_surface( - pipe->screen, - old_sampler_view->texture, - 0, 0, 0, - PIPE_BIND_BLIT_SOURCE); - pipe->surface_copy(pipe, - surface, - 0, 0, - old_surface, - 0, 0, - MIN2(old_surface->width, surface->width), - MIN2(old_surface->height, surface->height)); - if (surface) - pipe_surface_reference(&surface, NULL); - if (old_surface) - pipe_surface_reference(&old_surface, NULL); + struct pipe_subresource subsurf, subold_surf; + subsurf.face = 0; + subsurf.level = 0; + subold_surf.face = 0; + subold_surf.level = 0; + pipe->resource_copy_region(pipe, + stfb->alpha_mask_view->texture, + subsurf, + 0, 0, 0, + old_sampler_view->texture, + subold_surf, + 0, 0, 0, + MIN2(old_sampler_view->texture->width0, + stfb->alpha_mask_view->texture->width0), + MIN2(old_sampler_view->texture->height0, + stfb->alpha_mask_view->texture->height0)); } /* Free the old texture @@ -170,9 +164,7 @@ vg_context_update_depth_stencil_rb(struct vg_context * ctx, /* Probably need dedicated flags for surface usage too: */ - surface_usage = (PIPE_BIND_RENDER_TARGET | - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION); + surface_usage = PIPE_BIND_DEPTH_STENCIL; /* XXX: was: RENDER_TARGET */ dsrb->texture = create_texture(pipe, dsrb->format, width, height); if (!dsrb->texture) @@ -214,9 +206,7 @@ vg_context_update_color_rb(struct vg_context *ctx, struct pipe_resource *pt) strb->texture = pt; strb->surface = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - PIPE_BIND_RENDER_TARGET | - PIPE_BIND_BLIT_SOURCE | - PIPE_BIND_BLIT_DESTINATION); + PIPE_BIND_RENDER_TARGET); if (!strb->surface) { pipe_resource_reference(&strb->texture, NULL); return TRUE; -- cgit v1.2.3 From a127e4709dcafa409dde25061481c130064a1c42 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:33:45 +0200 Subject: st/wgl: adapt to interface changes --- src/gallium/state_trackers/wgl/stw_pixelformat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index 11e779d25f8..e606477e975 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -225,8 +225,8 @@ stw_pixelformat_init( void ) for(j = 0; j < Elements(stw_pf_color); ++j) { const struct stw_pf_color_info *color = &stw_pf_color[j]; - if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D, - PIPE_BIND_RENDER_TARGET | + if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D, + 0, PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET, 0)) continue; @@ -237,7 +237,7 @@ stw_pixelformat_init( void ) const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l]; if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D, - PIPE_BIND_DEPTH_STENCIL, 0)) + 0, PIPE_BIND_DEPTH_STENCIL, 0)) continue; stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples ); -- cgit v1.2.3 From 685bb6941681f89f71a9169594d87c8e314b94d0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:33:53 +0200 Subject: st/glx: adapt to interface changes --- src/gallium/state_trackers/glx/xlib/xm_api.c | 4 +++- src/gallium/state_trackers/glx/xlib/xm_st.c | 18 ++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index f3b0617f76b..a6f808bc964 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -342,6 +342,7 @@ choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil) const unsigned tex_usage = PIPE_BIND_DEPTH_STENCIL; const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE | PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO); + const unsigned sample_count = 0; enum pipe_format formats[8], fmt; int count, i; @@ -365,7 +366,8 @@ choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil) fmt = PIPE_FORMAT_NONE; for (i = 0; i < count; i++) { if (xmdpy->screen->is_format_supported(xmdpy->screen, formats[i], - target, tex_usage, geom_flags)) { + target, sample_count, + tex_usage, geom_flags)) { fmt = formats[i]; break; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index 1c678b4f760..c62eb8bfbd1 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -96,7 +96,7 @@ xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi, struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi); struct pipe_resource *src_ptex = xstfb->textures[src_statt]; struct pipe_resource *dst_ptex = xstfb->textures[dst_statt]; - struct pipe_surface *src, *dst; + struct pipe_subresource subsrc, subdst; struct pipe_context *pipe; if (!src_ptex || !dst_ptex) @@ -110,16 +110,14 @@ xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi, xstfb->display->pipe = pipe; } - src = xstfb->screen->get_tex_surface(xstfb->screen, - src_ptex, 0, 0, 0, PIPE_BIND_BLIT_SOURCE); - dst = xstfb->screen->get_tex_surface(xstfb->screen, - dst_ptex, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION); + subsrc.face = 0; + subsrc.level = 0; + subdst.face = 0; + subdst.level = 0; - if (src && dst) - pipe->surface_copy(pipe, dst, x, y, src, x, y, width, height); - - pipe_surface_reference(&src, NULL); - pipe_surface_reference(&dst, NULL); + if (src_ptex && dst_ptex) + pipe->resource_copy_region(pipe, dst_ptex, subdst, x, y, 0, + src_ptex, subsrc, x, y, 0, width, height); } /** -- cgit v1.2.3 From bf3c8ed481047d0c446d2d3d6d1de82403783fb0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:34:03 +0200 Subject: st/dri: adapt to interface changes --- .../state_trackers/dri/common/dri1_helper.c | 2 +- src/gallium/state_trackers/dri/common/dri_screen.c | 65 ++++++++++++++++------ src/gallium/state_trackers/dri/drm/dri1.c | 26 ++++----- 3 files changed, 61 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.c b/src/gallium/state_trackers/dri/common/dri1_helper.c index f641b41ff8b..ad6c7d37504 100644 --- a/src/gallium/state_trackers/dri/common/dri1_helper.c +++ b/src/gallium/state_trackers/dri/common/dri1_helper.c @@ -93,7 +93,7 @@ dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_resource *ptex) pipe_surface_reference(&drawable->dri1_surface, NULL); drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen, - ptex, 0, 0, 0, PIPE_BIND_BLIT_SOURCE); + ptex, 0, 0, 0, 0/* no bind flag???*/); psurf = drawable->dri1_surface; } diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 064c73f54c2..81523b82ba9 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -72,13 +72,13 @@ dri_fill_in_modes(struct dri_screen *screen, __DRIconfig **configs_r5g6b5 = NULL; __DRIconfig **configs_a8r8g8b8 = NULL; __DRIconfig **configs_x8r8g8b8 = NULL; - unsigned num_modes; uint8_t depth_bits_array[5]; uint8_t stencil_bits_array[5]; - uint8_t msaa_samples_array[2]; + uint8_t msaa_samples_array[5]; unsigned depth_buffer_factor; unsigned back_buffer_factor; unsigned msaa_samples_factor; + unsigned i; struct pipe_screen *p_screen = screen->base.screen; boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8; boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32; @@ -92,34 +92,34 @@ dri_fill_in_modes(struct dri_screen *screen, depth_buffer_factor = 1; pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0); pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0); pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0); pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0); pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0); pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0); pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET, 0); /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */ if (dri_with_format(screen->sPriv)) { pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0); pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM, - PIPE_TEXTURE_2D, + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0); } else { pf_z16 = FALSE; @@ -146,22 +146,39 @@ dri_fill_in_modes(struct dri_screen *screen, } msaa_samples_array[0] = 0; - msaa_samples_array[1] = 4; back_buffer_factor = 3; - msaa_samples_factor = 2; - num_modes = - depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; + /* also test color for msaa 2/4/6/8 - just assume it'll work for all depth buffers */ + if (pf_r5g6b5) { + msaa_samples_factor = 1; + for (i = 1; i < 5; i++) { + if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM, + PIPE_TEXTURE_2D, i*2, + PIPE_BIND_RENDER_TARGET, 0)) { + msaa_samples_array[msaa_samples_factor] = i * 2; + msaa_samples_factor++; + } + } - if (pf_r5g6b5) configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, back_buffer_factor, msaa_samples_array, msaa_samples_factor, GL_TRUE); + } + + if (pf_a8r8g8b8) { + msaa_samples_factor = 1; + for (i = 1; i < 5; i++) { + if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_TEXTURE_2D, i*2, + PIPE_BIND_RENDER_TARGET, 0)) { + msaa_samples_array[msaa_samples_factor] = i * 2; + msaa_samples_factor++; + } + } - if (pf_a8r8g8b8) configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, depth_bits_array, stencil_bits_array, @@ -171,8 +188,19 @@ dri_fill_in_modes(struct dri_screen *screen, msaa_samples_array, msaa_samples_factor, GL_TRUE); + } + + if (pf_x8r8g8b8) { + msaa_samples_factor = 1; + for (i = 1; i < 5; i++) { + if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_TEXTURE_2D, i*2, + PIPE_BIND_RENDER_TARGET, 0)) { + msaa_samples_array[msaa_samples_factor] = i * 2; + msaa_samples_factor++; + } + } - if (pf_x8r8g8b8) configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV, depth_bits_array, stencil_bits_array, @@ -182,6 +210,7 @@ dri_fill_in_modes(struct dri_screen *screen, msaa_samples_array, msaa_samples_factor, GL_TRUE); + } if (pixel_bits == 16) { configs = configs_r5g6b5; diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 326ff8bcada..9f0b9257312 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -156,24 +156,22 @@ dri1_swap_copy(struct pipe_context *pipe, struct drm_clip_rect clip; struct drm_clip_rect *cur; int i; + struct pipe_subresource subdst, subsrc; + subsrc.face = 0; + subsrc.level = 0; + subdst.face = 0; + subdst.level = 0; cur = dPriv->pClipRects; for (i = 0; i < dPriv->numClipRects; ++i) { if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) { - if (pipe->surface_copy) { - pipe->surface_copy(pipe, dst, clip.x1, clip.y1, - src, - (int)clip.x1 - dPriv->x, - (int)clip.y1 - dPriv->y, - clip.x2 - clip.x1, clip.y2 - clip.y1); - } else { - util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1, - src, - (int)clip.x1 - dPriv->x, - (int)clip.y1 - dPriv->y, - clip.x2 - clip.x1, clip.y2 - clip.y1); - } + pipe->resource_copy_region(pipe, dst->texture, subdst, + clip.x1, clip.y1, 0, + src->texture, subsrc, + (int)clip.x1 - dPriv->x, + (int)clip.y1 - dPriv->y, 0, + clip.x2 - clip.x1, clip.y2 - clip.y1); } } } @@ -204,6 +202,8 @@ dri1_present_texture_locked(__DRIdrawable * dPriv, return; pipe = dri1_get_pipe_context(screen); + /* XXX should probably use resources instead of surfaces in the api + - we get surface but only use the texture from it it seems... */ psurf = dri1_get_pipe_surface(drawable, ptex); if (!pipe || !psurf) return; -- cgit v1.2.3 From 2a15553e431f04d13b757a3a76e4eb7d794f1219 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 17 May 2010 21:34:30 +0200 Subject: st/egl: adapt to interface changes --- src/gallium/state_trackers/egl/common/egl_g3d.c | 2 +- .../state_trackers/egl/common/egl_g3d_api.c | 37 +++++++++------------- src/gallium/state_trackers/egl/kms/native_kms.c | 2 +- src/gallium/state_trackers/egl/x11/native_dri2.c | 7 ++-- 4 files changed, 21 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 3ab72dce2f3..871c33267ae 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -351,7 +351,7 @@ egl_g3d_fill_depth_stencil_formats(_EGLDisplay *dpy, /* pick the first supported format */ for (i = 0; i < n; i++) { if (screen->is_format_supported(screen, fmt[i], - PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL, 0)) { + PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL, 0)) { formats[count++] = fmt[i]; break; } diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c index 478516453ce..4615a5829a6 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c @@ -407,24 +407,16 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) /** * Get the pipe surface of the given attachment of the native surface. */ -static struct pipe_surface * -get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, - enum native_attachment natt, - unsigned bind) +static struct pipe_resource * +get_pipe_resource(struct native_display *ndpy, struct native_surface *nsurf, + enum native_attachment natt) { struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS]; - struct pipe_surface *psurf; textures[natt] = NULL; nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL); - if (!textures[natt]) - return NULL; - - psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt], - 0, 0, 0, bind); - pipe_resource_reference(&textures[natt], NULL); - return psurf; + return textures[natt]; } static EGLBoolean @@ -437,7 +429,7 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, struct egl_g3d_config *gconf; struct native_surface *nsurf; struct pipe_screen *screen = gdpy->native->screen; - struct pipe_surface *psurf; + struct pipe_resource *ptex; if (!gsurf->render_texture) return EGL_TRUE; @@ -466,22 +458,23 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, return EGL_FALSE; } - psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT, - PIPE_BIND_BLIT_DESTINATION); - if (psurf) { + ptex = get_pipe_resource(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); + if (ptex) { struct pipe_surface *psrc; + struct pipe_subresource subsrc, subdst; + subsrc.face = 0; + subsrc.level = 0; + subdst.face = 0; + subdst.level = 0; - psrc = screen->get_tex_surface(screen, gsurf->render_texture, - 0, 0, 0, PIPE_BIND_BLIT_SOURCE); if (psrc) { - gdpy->pipe->surface_copy(gdpy->pipe, psurf, 0, 0, - psrc, 0, 0, psurf->width, psurf->height); - pipe_surface_reference(&psrc, NULL); + gdpy->pipe->resource_copy_region(gdpy->pipe, ptex, subdst, 0, 0, 0, + gsurf->render_texture, subsrc, 0, 0, 0, ptex->width0, ptex->height0); nsurf->flush_frontbuffer(nsurf); } - pipe_surface_reference(&psurf, NULL); + pipe_resource_reference(&ptex, NULL); } nsurf->destroy(nsurf); diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index cf7188dfdb7..d81178e5592 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -563,7 +563,7 @@ kms_display_is_format_supported(struct native_display *ndpy, enum pipe_format fmt, boolean is_color) { return ndpy->screen->is_format_supported(ndpy->screen, - fmt, PIPE_TEXTURE_2D, + fmt, PIPE_TEXTURE_2D, 0, (is_color) ? PIPE_BIND_RENDER_TARGET : PIPE_BIND_DEPTH_STENCIL, 0); } diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index d37f66da07e..63877ed5e51 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -498,9 +498,9 @@ choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32]) static boolean is_format_supported(struct pipe_screen *screen, - enum pipe_format fmt, boolean is_color) + enum pipe_format fmt, unsigned sample_count, boolean is_color) { - return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, + return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, sample_count, (is_color) ? PIPE_BIND_RENDER_TARGET : PIPE_BIND_DEPTH_STENCIL, 0); } @@ -512,6 +512,7 @@ dri2_display_convert_config(struct native_display *ndpy, { enum pipe_format formats[32]; int num_formats, i; + int sample_count = 0; if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode) return FALSE; @@ -536,7 +537,7 @@ dri2_display_convert_config(struct native_display *ndpy, /* choose color format */ num_formats = choose_color_format(mode, formats); for (i = 0; i < num_formats; i++) { - if (is_format_supported(ndpy->screen, formats[i], TRUE)) { + if (is_format_supported(ndpy->screen, formats[i], sample_count, TRUE)) { nconf->color_format = formats[i]; break; } -- cgit v1.2.3 From 43234cee40c48e14a3eab4268181d9b0b2b7cf79 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 18 May 2010 16:20:44 +0200 Subject: gallium: implement set_sample_mask() in all drivers prevents segfault when state trackers try to set default mask. Other option would be to make this required only for drivers supporting multisampling, but this seems more clean. Only dummy implementations (for normal drivers) provided (no driver supports multisampling yet neither). --- src/gallium/drivers/cell/ppu/cell_pipe_state.c | 9 ++++++++- src/gallium/drivers/failover/fo_context.h | 2 ++ src/gallium/drivers/failover/fo_state.c | 14 ++++++++++++++ src/gallium/drivers/failover/fo_state_emit.c | 3 +++ src/gallium/drivers/i915/i915_state.c | 7 +++++++ src/gallium/drivers/i965/brw_pipe_depth.c | 7 +++++++ src/gallium/drivers/identity/id_context.c | 12 ++++++++++++ src/gallium/drivers/llvmpipe/lp_state_blend.c | 6 ++++++ src/gallium/drivers/nv50/nv50_state.c | 7 +++++++ src/gallium/drivers/nvfx/nvfx_state.c | 7 +++++++ src/gallium/drivers/r300/r300_state.c | 8 ++++++++ src/gallium/drivers/softpipe/sp_context.c | 1 + src/gallium/drivers/softpipe/sp_state.h | 3 +++ src/gallium/drivers/softpipe/sp_state_blend.c | 7 +++++++ src/gallium/drivers/svga/svga_pipe_depthstencil.c | 7 +++++++ src/gallium/drivers/trace/tr_context.c | 17 +++++++++++++++++ 16 files changed, 116 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c index 8c975c6ae2a..ecc9de4df66 100644 --- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c +++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c @@ -125,6 +125,7 @@ cell_set_stencil_ref(struct pipe_context *pipe, cell->dirty |= CELL_NEW_DEPTH_STENCIL; } + static void cell_set_clip_state(struct pipe_context *pipe, const struct pipe_clip_state *clip) @@ -136,6 +137,12 @@ cell_set_clip_state(struct pipe_context *pipe, } +static void +cell_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + /* Called when driver state tracker notices changes to the viewport * matrix: @@ -430,7 +437,6 @@ cell_set_framebuffer_state(struct pipe_context *pipe, } - void cell_init_state_functions(struct cell_context *cell) { @@ -457,6 +463,7 @@ cell_init_state_functions(struct cell_context *cell) cell->pipe.set_blend_color = cell_set_blend_color; cell->pipe.set_stencil_ref = cell_set_stencil_ref; cell->pipe.set_clip_state = cell_set_clip_state; + cell->pipe.set_sample_mask = cell_set_sample_mask; cell->pipe.set_framebuffer_state = cell_set_framebuffer_state; diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h index 88ae5ad60d5..9d3e0d0dba0 100644 --- a/src/gallium/drivers/failover/fo_context.h +++ b/src/gallium/drivers/failover/fo_context.h @@ -55,6 +55,7 @@ #define FO_NEW_CLEAR_COLOR 0x20000 #define FO_NEW_VERTEX_BUFFER 0x40000 #define FO_NEW_VERTEX_ELEMENT 0x80000 +#define FO_NEW_SAMPLE_MASK 0x100000 @@ -90,6 +91,7 @@ struct failover_context { struct pipe_blend_color blend_color; struct pipe_stencil_ref stencil_ref; struct pipe_clip_state clip; + unsigned sample_mask; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index 272e683067e..12e42379f98 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -125,6 +125,19 @@ failover_set_clip_state( struct pipe_context *pipe, failover->hw->set_clip_state( failover->hw, clip ); } +static void +failover_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ + struct failover_context *failover = failover_context(pipe); + + failover->sample_mask = sample_mask; + failover->dirty |= FO_NEW_SAMPLE_MASK; + failover->sw->set_sample_mask( failover->sw, sample_mask ); + failover->hw->set_sample_mask( failover->hw, sample_mask ); + +} + static void * failover_create_depth_stencil_state(struct pipe_context *pipe, @@ -614,6 +627,7 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_blend_color = failover_set_blend_color; failover->pipe.set_stencil_ref = failover_set_stencil_ref; failover->pipe.set_clip_state = failover_set_clip_state; + failover->pipe.set_sample_mask = failover_set_sample_mask; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; failover->pipe.set_scissor_state = failover_set_scissor_state; diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c index 42bd6929a7f..147f23269ca 100644 --- a/src/gallium/drivers/failover/fo_state_emit.c +++ b/src/gallium/drivers/failover/fo_state_emit.c @@ -63,6 +63,9 @@ failover_state_emit( struct failover_context *failover ) if (failover->dirty & FO_NEW_CLIP) failover->sw->set_clip_state( failover->sw, &failover->clip ); + if (failover->dirty & FO_NEW_SAMPLE_MASK) + failover->sw->set_sample_mask( failover->sw, failover->sample_mask ); + if (failover->dirty & FO_NEW_DEPTH_STENCIL) failover->sw->bind_depth_stencil_alpha_state( failover->sw, failover->depth_stencil->sw_state ); diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index f883883852a..e008195a910 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -806,6 +806,12 @@ i915_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) FREE( velems ); } +static void +i915_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + void i915_init_state_functions( struct i915_context *i915 ) { @@ -837,6 +843,7 @@ i915_init_state_functions( struct i915_context *i915 ) i915->base.set_blend_color = i915_set_blend_color; i915->base.set_stencil_ref = i915_set_stencil_ref; i915->base.set_clip_state = i915_set_clip_state; + i915->base.set_sample_mask = i915_set_sample_mask; i915->base.set_constant_buffer = i915_set_constant_buffer; i915->base.set_framebuffer_state = i915_set_framebuffer_state; diff --git a/src/gallium/drivers/i965/brw_pipe_depth.c b/src/gallium/drivers/i965/brw_pipe_depth.c index b7000d5e334..31c2c343d89 100644 --- a/src/gallium/drivers/i965/brw_pipe_depth.c +++ b/src/gallium/drivers/i965/brw_pipe_depth.c @@ -167,12 +167,19 @@ static void brw_set_stencil_ref(struct pipe_context *pipe, brw->state.dirty.mesa |= PIPE_NEW_DEPTH_STENCIL_ALPHA; } +static void +brw_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + void brw_pipe_depth_stencil_init( struct brw_context *brw ) { brw->base.set_stencil_ref = brw_set_stencil_ref; brw->base.create_depth_stencil_alpha_state = brw_create_depth_stencil_state; brw->base.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state; brw->base.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state; + brw->base.set_sample_mask = brw_set_sample_mask; } void brw_pipe_depth_stencil_cleanup( struct brw_context *brw ) diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index bd1b5ea2d0e..9813170fb18 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -451,6 +451,17 @@ identity_set_clip_state(struct pipe_context *_pipe, clip); } +static void +identity_set_sample_mask(struct pipe_context *_pipe, + unsigned sample_mask) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct pipe_context *pipe = id_pipe->pipe; + + pipe->set_sample_mask(pipe, + sample_mask); +} + static void identity_set_constant_buffer(struct pipe_context *_pipe, uint shader, @@ -892,6 +903,7 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.set_blend_color = identity_set_blend_color; id_pipe->base.set_stencil_ref = identity_set_stencil_ref; id_pipe->base.set_clip_state = identity_set_clip_state; + id_pipe->base.set_sample_mask = identity_set_sample_mask; id_pipe->base.set_constant_buffer = identity_set_constant_buffer; id_pipe->base.set_framebuffer_state = identity_set_framebuffer_state; id_pipe->base.set_polygon_stipple = identity_set_polygon_stipple; diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c index 8569507f4e5..5b39d9d1a91 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c @@ -148,6 +148,11 @@ llvmpipe_set_stencil_ref(struct pipe_context *pipe, llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA; } +static void +llvmpipe_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} void llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe) @@ -163,4 +168,5 @@ llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe) llvmpipe->pipe.set_blend_color = llvmpipe_set_blend_color; llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref; + llvmpipe->pipe.set_sample_mask = llvmpipe_set_sample_mask; } diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index e885a2b7196..3fde8592143 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -688,6 +688,12 @@ nv50_set_clip_state(struct pipe_context *pipe, { } +static void +nv50_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + static void nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, struct pipe_resource *buf ) @@ -833,6 +839,7 @@ nv50_init_state_functions(struct nv50_context *nv50) nv50->pipe.set_blend_color = nv50_set_blend_color; nv50->pipe.set_stencil_ref = nv50_set_stencil_ref; nv50->pipe.set_clip_state = nv50_set_clip_state; + nv50->pipe_set_sample_mask = nv50_set_sample_mask; nv50->pipe.set_constant_buffer = nv50_set_constant_buffer; nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state; nv50->pipe.set_polygon_stipple = nv50_set_polygon_stipple; diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c index 315de492dab..3c566808d03 100644 --- a/src/gallium/drivers/nvfx/nvfx_state.c +++ b/src/gallium/drivers/nvfx/nvfx_state.c @@ -505,6 +505,12 @@ nvfx_set_clip_state(struct pipe_context *pipe, nvfx->draw_dirty |= NVFX_NEW_UCP; } +static void +nvfx_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + static void nvfx_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, struct pipe_resource *buf ) @@ -644,6 +650,7 @@ nvfx_init_state_functions(struct nvfx_context *nvfx) nvfx->pipe.set_blend_color = nvfx_set_blend_color; nvfx->pipe.set_stencil_ref = nvfx_set_stencil_ref; nvfx->pipe.set_clip_state = nvfx_set_clip_state; + nvfx->pipe.set_sample_mask = nvfx_set_sample_mask; nvfx->pipe.set_constant_buffer = nvfx_set_constant_buffer; nvfx->pipe.set_framebuffer_state = nvfx_set_framebuffer_state; nvfx->pipe.set_polygon_stipple = nvfx_set_polygon_stipple; diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 446422ca0f0..4f41530c16a 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -404,6 +404,13 @@ static void r300_set_clip_state(struct pipe_context* pipe, r300->clip_state.dirty = TRUE; } +static void +r300_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + + /* Create a new depth, stencil, and alpha state based on the CSO dsa state. * * This contains the depth buffer, stencil buffer, alpha test, and such. @@ -1502,6 +1509,7 @@ void r300_init_state_functions(struct r300_context* r300) r300->context.set_blend_color = r300_set_blend_color; r300->context.set_clip_state = r300_set_clip_state; + r300->context.set_sample_mask = r300_set_sample_mask; r300->context.set_constant_buffer = r300_set_constant_buffer; diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index f6e2b80d46e..0f1bcc21bd6 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -251,6 +251,7 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref; softpipe->pipe.set_clip_state = softpipe_set_clip_state; + softpipe->pipe.set_sample_mask = softpipe_set_sample_mask; softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index f97fc6eca8f..5b0faabeaef 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -148,6 +148,9 @@ void softpipe_set_stencil_ref( struct pipe_context *pipe, void softpipe_set_clip_state( struct pipe_context *, const struct pipe_clip_state * ); +void softpipe_set_sample_mask( struct pipe_context *, + unsigned sample_mask ); + void softpipe_set_constant_buffer(struct pipe_context *, uint shader, uint index, struct pipe_resource *buf); diff --git a/src/gallium/drivers/softpipe/sp_state_blend.c b/src/gallium/drivers/softpipe/sp_state_blend.c index c63a49e90b0..2a203f44e50 100644 --- a/src/gallium/drivers/softpipe/sp_state_blend.c +++ b/src/gallium/drivers/softpipe/sp_state_blend.c @@ -111,3 +111,10 @@ void softpipe_set_stencil_ref( struct pipe_context *pipe, softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA; } + +void +softpipe_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c index c317bec6d57..c84615a1f3b 100644 --- a/src/gallium/drivers/svga/svga_pipe_depthstencil.c +++ b/src/gallium/drivers/svga/svga_pipe_depthstencil.c @@ -147,6 +147,12 @@ static void svga_set_stencil_ref( struct pipe_context *pipe, svga->dirty |= SVGA_NEW_STENCIL_REF; } +static void +svga_set_sample_mask(struct pipe_context *pipe, + unsigned sample_mask) +{ +} + void svga_init_depth_stencil_functions( struct svga_context *svga ) { @@ -155,6 +161,7 @@ void svga_init_depth_stencil_functions( struct svga_context *svga ) svga->pipe.delete_depth_stencil_alpha_state = svga_delete_depth_stencil_state; svga->pipe.set_stencil_ref = svga_set_stencil_ref; + svga->pipe.set_sample_mask = svga_set_sample_mask; } diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 0edb685ac7b..64a4316984b 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -876,6 +876,22 @@ trace_context_set_clip_state(struct pipe_context *_pipe, trace_dump_call_end(); } +static INLINE void +trace_context_set_sample_mask(struct pipe_context *_pipe, + unsigned sample_mask) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + trace_dump_call_begin("pipe_context", "set_sample_mask"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(uint, sample_mask); + + pipe->set_sample_mask(pipe, sample_mask); + + trace_dump_call_end(); +} static INLINE void trace_context_set_constant_buffer(struct pipe_context *_pipe, @@ -1561,6 +1577,7 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.set_blend_color = trace_context_set_blend_color; tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref; tr_ctx->base.set_clip_state = trace_context_set_clip_state; + tr_ctx->base.set_sample_mask = trace_context_set_sample_mask; tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer; tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state; tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple; -- cgit v1.2.3 From 6f3721a8ecb3695344e9a878bb452342ee502764 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 18 May 2010 18:03:37 +0200 Subject: st/mesa: fix wrong argument order --- src/mesa/state_tracker/st_cb_fbo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index f67197de94f..46f27ced6c3 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -441,8 +441,9 @@ st_validate_attachment(struct pipe_screen *screen, if (!stObj) return GL_FALSE; - return screen->is_format_supported(screen, stObj->pt->format, stObj->pt->nr_samples, - PIPE_TEXTURE_2D, bindings, 0); + return screen->is_format_supported(screen, stObj->pt->format, + PIPE_TEXTURE_2D, + stObj->pt->nr_samples, bindings, 0); } -- cgit v1.2.3 From f4ad68a5288abe714f4c98307ed676869aa661fa Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 18 May 2010 21:41:15 +0200 Subject: util: fix some leftover util_surface_fill/copy calls --- src/gallium/auxiliary/util/u_blitter.c | 22 ++++++++++++++++------ src/gallium/auxiliary/util/u_surface.c | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 8e0901104a2..70625dab181 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -26,8 +26,8 @@ /** * @file - * Blitter utility to facilitate acceleration of the clear, surface_copy, - * and surface_fill functions. + * Blitter utility to facilitate acceleration of the clear, resource_copy_region, + * and resource_fill_region functions. * * @author Marek Olšák */ @@ -787,7 +787,7 @@ void util_blitter_copy(struct blitter_context *blitter, return; } } - + is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0; is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0; dst_tex_usage = is_depth || is_stencil ? PIPE_BIND_DEPTH_STENCIL : @@ -800,8 +800,14 @@ void util_blitter_copy(struct blitter_context *blitter, dst->texture->nr_samples, dst_tex_usage, 0) || !screen->is_format_supported(screen, src->format, src->texture->target, src->texture->nr_samples, PIPE_BIND_SAMPLER_VIEW, 0)) { - util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy, - width, height); + struct pipe_subresource subdst, subsrc; + subdst.face = dst->face; + subdst.level = dst->level; + subsrc.face = src->face; + subsrc.level = src->level; + util_resource_copy_region(pipe, dst, subdst, dstx, dsty, dst->zslice, + src, subsrc, srcx, srcy, src->zslice, + width, height); return; } @@ -838,7 +844,11 @@ void util_blitter_fill(struct blitter_context *blitter, !screen->is_format_supported(screen, dst->format, dst->texture->target, dst->texture->nr_samples, PIPE_BIND_RENDER_TARGET, 0)) { - util_surface_fill(pipe, dst, dstx, dsty, width, height, value); + struct pipe_subresource subdst; + subdst.face = dst->face; + subdst.level = dst->level; + util_resource_fill_region(pipe, dst->texture, subdst, dstx, dsty, + dst->zslice, width, height, value); return; } diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 029bff44eb1..6f49a723557 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -120,7 +120,7 @@ util_destroy_rgba_surface(struct pipe_resource *texture, /** - * Fallback function for pipe->surface_copy(). + * Fallback function for pipe->resource_copy_region(). * Note: (X,Y)=(0,0) is always the upper-left corner. */ void @@ -196,7 +196,7 @@ util_resource_copy_region(struct pipe_context *pipe, /** - * Fallback for pipe->surface_fill() function. + * Fallback for pipe->resource_fill_region() function. */ void util_resource_fill_region(struct pipe_context *pipe, -- cgit v1.2.3 From db0ddb7c0196c11cd47066bbf6af3febbefb7100 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 18 May 2010 21:42:09 +0200 Subject: docs: update differences to d3d11 --- src/gallium/docs/d3d11ddi.txt | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/gallium/docs/d3d11ddi.txt b/src/gallium/docs/d3d11ddi.txt index 8f2509ce035..d9c2b441a94 100644 --- a/src/gallium/docs/d3d11ddi.txt +++ b/src/gallium/docs/d3d11ddi.txt @@ -79,7 +79,7 @@ set_clip_state set_polygon_stipple + Gallium supports polygon stipple -surface_fill +resource_fill_region + Gallium supports subrectangle fills of surfaces, D3D10 only supports full clears of views * DirectX 10/11 DDI functions and Gallium equivalents @@ -114,11 +114,10 @@ CheckDeferredContextHandleSizes (D3D11 only) CheckFormatSupport -> screen->is_format_supported ! Gallium passes usages to this function, D3D11 returns them - Gallium does not differentiate between blendable and non-blendable render targets - - Gallium lacks multisampled-texture and multisampled-render-target usages + ! Gallium includes sample count directly, D3D11 uses additional query CheckMultisampleQualityLevels - * could merge this with is_format_supported - - Gallium lacks multisampling support + ! is merged with is_format_supported CommandListExecute (D3D11 only) - Gallium does not support command lists @@ -139,7 +138,6 @@ ClearUnorderedAccessViewUint (D3D11 only) CreateBlendState (extended in D3D10.1) -> create_blend_state # D3D10 does not support per-RT blend modes (but per-RT blending), only D3D10.1 does - - Gallium lacks alpha-to-coverage + Gallium supports logic ops + Gallium supports dithering + Gallium supports using the broadcast alpha component of the blend constant color @@ -198,7 +196,6 @@ CreateQuery -> create_query CreateRasterizerState - Gallium lacks clamping of polygon offset depth biases - Gallium lacks support to disable depth clipping - - Gallium lacks multisampling + Gallium, like OpenGL, supports PIPE_POLYGON_MODE_POINT + Gallium, like OpenGL, supports per-face polygon fill modes + Gallium, like OpenGL, supports culling everything @@ -228,7 +225,6 @@ CreateResource -> texture_create or buffer_create ! D3D11 specifies mapping flags (i.e. read/write/discard);:it's unclear what they are used for here - D3D11 supports odd things in the D3D10_DDI_RESOURCE_MISC_FLAG enum (D3D10_DDI_RESOURCE_MISC_DISCARD_ON_PRESENT, D3D11_DDI_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS, D3D11_DDI_RESOURCE_MISC_BUFFER_STRUCTURED) - Gallium does not support indirect draw call parameter buffers - - Gallium lacks multisampling - Gallium lacks array textures ! D3D11 supports specifying hardware modes and other stuff here for scanout resources + Gallium allows specifying minimum buffer alignment @@ -400,7 +396,7 @@ ResourceCopy ResourceCopyRegion ResourceConvert (D3D10.1+ only) ResourceConvertRegion (D3D10.1+ only) - -> surface_copy + -> resource_copy_region - Gallium does not support hardware buffer copies - Gallium does not support copying 3D texture subregions in a single call @@ -410,8 +406,7 @@ ResourceIsStagingBusy -> is_texture_referenced, is_buffer_referenced ResourceReadAfterWriteHazard ! Gallium specifies hides this, except for the render and texture caches -ResourceResolveSubresource - - Gallium does not support multisample sample resolution +ResourceResolveSubresource -> resource_resolve ResourceMap ResourceUnmap @@ -433,9 +428,8 @@ StagingResourceUnmap ResourceUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources DefaultConstantBufferUpdateSubresourceUP -> transfer functionality, transfer_inline_write in gallium-resources -SetBlendState -> bind_blend_state and set_blend_color - ! D3D11 fuses bind_blend_state and set_blend_color in a single function - - Gallium lacks the sample mask +SetBlendState -> bind_blend_state, set_blend_color and set_sample_mask + ! D3D11 fuses bind_blend_state, set_blend_color and set_sample_mask in a single function SetDepthStencilState -> bind_depth_stencil_alpha_state and set_stencil_ref ! D3D11 fuses bind_depth_stencil_alpha_state and set_stencil_ref in a single function -- cgit v1.2.3 From 1adbe2c82dc64b85398d04784ee10c899551479c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 19 May 2010 17:14:06 +0200 Subject: i915g: remove unused flip parameter --- src/gallium/drivers/i915/i915_blit.c | 1 - src/gallium/drivers/i915/i915_blit.h | 1 - src/gallium/drivers/i915/i915_surface.c | 1 - 3 files changed, 3 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/i915/i915_blit.c b/src/gallium/drivers/i915/i915_blit.c index 533fa81219b..6717e46e1b4 100644 --- a/src/gallium/drivers/i915/i915_blit.c +++ b/src/gallium/drivers/i915/i915_blit.c @@ -84,7 +84,6 @@ i915_fill_blit(struct i915_context *i915, void i915_copy_blit(struct i915_context *i915, - unsigned do_flip, unsigned cpp, unsigned short src_pitch, struct i915_winsys_buffer *src_buffer, diff --git a/src/gallium/drivers/i915/i915_blit.h b/src/gallium/drivers/i915/i915_blit.h index db576ed4c90..43f8e7c9aad 100644 --- a/src/gallium/drivers/i915/i915_blit.h +++ b/src/gallium/drivers/i915/i915_blit.h @@ -31,7 +31,6 @@ #include "i915_context.h" extern void i915_copy_blit(struct i915_context *i915, - unsigned do_flip, unsigned cpp, unsigned short src_pitch, struct i915_winsys_buffer *src_buffer, diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 0deee24754f..41b1fed36d0 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -85,7 +85,6 @@ i915_surface_copy(struct pipe_context *pipe, assert( util_format_get_blockheight(dpt->format) == 1 ); i915_copy_blit( i915_context(pipe), - FALSE, util_format_get_blocksize(dpt->format), (unsigned short) src_tex->stride, src_tex->buffer, src_offset, (unsigned short) dst_tex->stride, dst_tex->buffer, dst_offset, -- cgit v1.2.3 From 5be35de0fbffec9a45e969ffd2104f464da41505 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 19 May 2010 17:20:26 +0200 Subject: util: util_blitter_fill no longer needs to handle overlap --- src/gallium/auxiliary/util/u_blitter.c | 54 ++-------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 70625dab181..8b18ba35f01 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -712,53 +712,6 @@ static void util_blitter_do_copy(struct blitter_context *blitter, } -static void util_blitter_overlap_copy(struct blitter_context *blitter, - struct pipe_surface *dst, - unsigned dstx, unsigned dsty, - struct pipe_surface *src, - unsigned srcx, unsigned srcy, - unsigned width, unsigned height) -{ - struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; - struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; - - struct pipe_resource texTemp; - struct pipe_resource *texture; - struct pipe_surface *tex_surf; - - /* check whether the states are properly saved */ - blitter_check_saved_CSOs(ctx); - - memset(&texTemp, 0, sizeof(texTemp)); - texTemp.target = PIPE_TEXTURE_2D; - texTemp.format = dst->texture->format; /* XXX verify supported by driver! */ - texTemp.last_level = 0; - texTemp.width0 = width; - texTemp.height0 = height; - texTemp.depth0 = 1; - - texture = screen->resource_create(screen, &texTemp); - if (!texture) - return; - - tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BIND_SAMPLER_VIEW | - PIPE_BIND_RENDER_TARGET); - - /* blit from the src to the temp */ - util_blitter_do_copy(blitter, tex_surf, 0, 0, - src, srcx, srcy, - width, height, - FALSE); - util_blitter_do_copy(blitter, dst, dstx, dsty, - tex_surf, 0, 0, - width, height, - FALSE); - pipe_surface_reference(&tex_surf, NULL); - pipe_resource_reference(&texture, NULL); - blitter_restore_CSOs(ctx); -} void util_blitter_copy(struct blitter_context *blitter, struct pipe_surface *dst, @@ -780,11 +733,8 @@ void util_blitter_copy(struct blitter_context *blitter, return; if (dst->texture == src->texture) { - if (is_overlap(srcx, srcx + width, srcy, srcy + height, - dstx, dstx + width, dsty, dsty + height)) { - util_blitter_overlap_copy(blitter, dst, dstx, dsty, src, srcx, srcy, - width, height); - return; + assert(!is_overlap(srcx, srcx + width, srcy, srcy + height, + dstx, dstx + width, dsty, dsty + height)) } } -- cgit v1.2.3 From 23808f1b5e88373534c7ff546cdd89030ce1e935 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 19 May 2010 09:30:25 -0600 Subject: nv50: fix typo: s/_/./ --- src/gallium/drivers/nv50/nv50_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 3fde8592143..cf4105bcb77 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -839,7 +839,7 @@ nv50_init_state_functions(struct nv50_context *nv50) nv50->pipe.set_blend_color = nv50_set_blend_color; nv50->pipe.set_stencil_ref = nv50_set_stencil_ref; nv50->pipe.set_clip_state = nv50_set_clip_state; - nv50->pipe_set_sample_mask = nv50_set_sample_mask; + nv50->pipe.set_sample_mask = nv50_set_sample_mask; nv50->pipe.set_constant_buffer = nv50_set_constant_buffer; nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state; nv50->pipe.set_polygon_stipple = nv50_set_polygon_stipple; -- cgit v1.2.3 From ce65caba846b03b5ef4144e311b85cfd48ab9bbb Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 19 May 2010 18:33:28 +0200 Subject: util: fix obvious util_blitter_copy bugs... --- src/gallium/auxiliary/util/u_blitter.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 8b18ba35f01..d603c7ac06d 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -734,8 +734,7 @@ void util_blitter_copy(struct blitter_context *blitter, if (dst->texture == src->texture) { assert(!is_overlap(srcx, srcx + width, srcy, srcy + height, - dstx, dstx + width, dsty, dsty + height)) - } + dstx, dstx + width, dsty, dsty + height)); } is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0; @@ -755,8 +754,8 @@ void util_blitter_copy(struct blitter_context *blitter, subdst.level = dst->level; subsrc.face = src->face; subsrc.level = src->level; - util_resource_copy_region(pipe, dst, subdst, dstx, dsty, dst->zslice, - src, subsrc, srcx, srcy, src->zslice, + util_resource_copy_region(pipe, dst->texture, subdst, dstx, dsty, dst->zslice, + src->texture, subsrc, srcx, srcy, src->zslice, width, height); return; } -- cgit v1.2.3