diff options
Diffstat (limited to 'src/gallium/drivers/r300')
29 files changed, 524 insertions, 624 deletions
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index 66d900ebb5f..c9401b99f1c 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -29,8 +29,7 @@ C_SOURCES = \ r300_transfer.c LIBRARY_INCLUDES = \ - -I$(TOP)/src/mesa/drivers/dri/r300/compiler \ - -I$(TOP)/src/gallium/winsys/drm/radeon/core + -I$(TOP)/src/mesa/drivers/dri/r300/compiler COMPILER_ARCHIVE = $(TOP)/src/mesa/drivers/dri/r300/compiler/libr300compiler.a diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript index b49db937994..3af157a7956 100644 --- a/src/gallium/drivers/r300/SConscript +++ b/src/gallium/drivers/r300/SConscript @@ -6,7 +6,6 @@ env = env.Clone() # add the paths for r300compiler env.Append(CPPPATH = [ '#/src/mesa/drivers/dri/r300/compiler', - '#/src/gallium/winsys/drm/radeon/core', '#/include', '#/src/mesa', ]) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 37b635fd120..1217488bac7 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -23,10 +23,10 @@ #include "r300_context.h" #include "r300_emit.h" #include "r300_texture.h" -#include "r300_winsys.h" #include "util/u_format.h" #include "util/u_pack_color.h" +#include "util/u_surface.h" enum r300_blitter_op /* bitmask */ { @@ -206,7 +206,7 @@ static void r300_clear(struct pipe_context* pipe, (struct r300_hyperz_state*)r300->hyperz_state.state; uint32_t width = fb->width; uint32_t height = fb->height; - boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ); + boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ); uint32_t hyperz_dcv = hyperz->zb_depthclearvalue; /* Enable fast Z clear. @@ -253,17 +253,15 @@ static void r300_clear(struct pipe_context* pipe, } else if (r300->zmask_clear.dirty || r300->hiz_clear.dirty) { /* Just clear zmask and hiz now, this does not use the standard draw * procedure. */ - unsigned dwords; - /* Calculate zmask_clear and hiz_clear atom sizes. */ - r300_update_hyperz_state(r300); - dwords = (r300->zmask_clear.dirty ? r300->zmask_clear.size : 0) + - (r300->hiz_clear.dirty ? r300->hiz_clear.size : 0) + - r300_get_num_cs_end_dwords(r300); + unsigned dwords = + (r300->zmask_clear.dirty ? r300->zmask_clear.size : 0) + + (r300->hiz_clear.dirty ? r300->hiz_clear.size : 0) + + r300_get_num_cs_end_dwords(r300); /* Reserve CS space. */ - if (dwords > (R300_MAX_CMDBUF_DWORDS - r300->cs->cdw)) { - r300_flush(&r300->context, R300_FLUSH_ASYNC, NULL); + if (dwords > (RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw)) { + r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL); } /* Emit clear packets. */ @@ -306,16 +304,10 @@ static void r300_clear_render_target(struct pipe_context *pipe, { struct r300_context *r300 = r300_context(pipe); - r300->hyperz_locked = TRUE; - r300_mark_atom_dirty(r300, &r300->hyperz_state); - r300_blitter_begin(r300, R300_CLEAR_SURFACE); util_blitter_clear_render_target(r300->blitter, dst, rgba, dstx, dsty, width, height); r300_blitter_end(r300); - - r300->hyperz_locked = FALSE; - r300_mark_atom_dirty(r300, &r300->hyperz_state); } /* Clear a region of a depth stencil surface. */ @@ -334,21 +326,14 @@ static void r300_clear_depth_stencil(struct pipe_context *pipe, if (r300->zmask_in_use && !r300->hyperz_locked) { if (fb->zsbuf->texture == dst->texture) { r300_decompress_zmask(r300); - } else { - r300->hyperz_locked = TRUE; - r300_mark_atom_dirty(r300, &r300->hyperz_state); } } + /* XXX Do not decompress ZMask of the currently-set zbuffer. */ r300_blitter_begin(r300, R300_CLEAR_SURFACE); util_blitter_clear_depth_stencil(r300->blitter, dst, clear_flags, depth, stencil, dstx, dsty, width, height); r300_blitter_end(r300); - - if (r300->hyperz_locked) { - r300->hyperz_locked = FALSE; - r300_mark_atom_dirty(r300, &r300->hyperz_state); - } } void r300_decompress_zmask(struct r300_context *r300) @@ -431,13 +416,17 @@ static void r300_resource_copy_region(struct pipe_context *pipe, util_format_description(dst->format); struct pipe_box box; + /* Fallback for buffers. */ + if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { + util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz, + src, src_level, src_box); + return; + } + if (r300->zmask_in_use && !r300->hyperz_locked) { if (fb->zsbuf->texture == src || fb->zsbuf->texture == dst) { r300_decompress_zmask(r300); - } else { - r300->hyperz_locked = TRUE; - r300_mark_atom_dirty(r300, &r300->hyperz_state); } } @@ -513,11 +502,6 @@ static void r300_resource_copy_region(struct pipe_context *pipe, r300_resource_set_properties(pipe->screen, src, 0, &old_src); if (old_dst.format != new_dst.format) r300_resource_set_properties(pipe->screen, dst, 0, &old_dst); - - if (r300->hyperz_locked) { - r300->hyperz_locked = FALSE; - r300_mark_atom_dirty(r300, &r300->hyperz_state); - } } void r300_init_blit_functions(struct r300_context *r300) diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index 990acea9f44..4949703120d 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -419,4 +419,5 @@ void r300_parse_chipset(struct r300_capabilities* caps) caps->is_rv350 = caps->family >= CHIP_FAMILY_RV350; caps->z_compress = caps->is_rv350 ? R300_ZCOMP_8X8 : R300_ZCOMP_4X4; caps->dxtc_swizzle = caps->is_r400 || caps->is_r500; + caps->has_us_format = caps->family == CHIP_FAMILY_R520; } diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h index 68943d561ba..d0050bed2e8 100644 --- a/src/gallium/drivers/r300/r300_chipset.h +++ b/src/gallium/drivers/r300/r300_chipset.h @@ -90,6 +90,8 @@ struct r300_capabilities { boolean high_second_pipe; /* DXTC texture swizzling. */ boolean dxtc_swizzle; + /* Whether R500_US_FORMAT0_0 exists (R520-only and depends on DRM). */ + boolean has_us_format; }; /* Enumerations for legibility and telling which card we're running on. */ diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 720d666d98c..15d1278c3bb 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -32,7 +32,6 @@ #include "r300_emit.h" #include "r300_screen.h" #include "r300_screen_buffer.h" -#include "r300_winsys.h" static void r300_update_num_contexts(struct r300_screen *r300screen, int diff) @@ -167,8 +166,8 @@ static boolean r300_setup_atoms(struct r300_context* r300) boolean is_rv350 = r300->screen->caps.is_rv350; boolean is_r500 = r300->screen->caps.is_r500; boolean has_tcl = r300->screen->caps.has_tcl; - boolean drm_2_6_0 = r300->rws->get_value(r300->rws, R300_VID_DRM_2_6_0); - boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ); + boolean drm_2_6_0 = r300->rws->get_value(r300->rws, RADEON_VID_DRM_2_6_0); + boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ); boolean has_hiz_ram = r300->screen->caps.hiz_ram > 0; /* Create the actual atom list. @@ -379,7 +378,7 @@ static void r300_init_states(struct pipe_context *pipe) if (r300->screen->caps.is_r500 || (r300->screen->caps.is_rv350 && - r300->rws->get_value(r300->rws, R300_VID_DRM_2_6_0))) { + r300->rws->get_value(r300->rws, RADEON_VID_DRM_2_6_0))) { OUT_CB_REG(R300_GB_Z_PEQ_CONFIG, 0); } END_CB; @@ -391,7 +390,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, { struct r300_context* r300 = CALLOC_STRUCT(r300_context); struct r300_screen* r300screen = r300_screen(screen); - struct r300_winsys_screen *rws = r300screen->rws; + struct radeon_winsys *rws = r300screen->rws; if (!r300) return NULL; @@ -514,19 +513,19 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, "r300: DRM version: %d.%d.%d, Name: %s, ID: 0x%04x, GB: %d, Z: %d\n" "r300: GART size: %d MB, VRAM size: %d MB\n" "r300: AA compression: %s, Z compression: %s, HiZ: %s\n", - rws->get_value(rws, R300_VID_DRM_MAJOR), - rws->get_value(rws, R300_VID_DRM_MINOR), - rws->get_value(rws, R300_VID_DRM_PATCHLEVEL), + rws->get_value(rws, RADEON_VID_DRM_MAJOR), + rws->get_value(rws, RADEON_VID_DRM_MINOR), + rws->get_value(rws, RADEON_VID_DRM_PATCHLEVEL), screen->get_name(screen), - rws->get_value(rws, R300_VID_PCI_ID), - rws->get_value(rws, R300_VID_GB_PIPES), - rws->get_value(rws, R300_VID_Z_PIPES), - rws->get_value(rws, R300_VID_GART_SIZE) >> 20, - rws->get_value(rws, R300_VID_VRAM_SIZE) >> 20, - rws->get_value(rws, R300_CAN_AACOMPRESS) ? "YES" : "NO", - rws->get_value(rws, R300_CAN_HYPERZ) && + rws->get_value(rws, RADEON_VID_PCI_ID), + rws->get_value(rws, RADEON_VID_R300_GB_PIPES), + rws->get_value(rws, RADEON_VID_R300_Z_PIPES), + rws->get_value(rws, RADEON_VID_GART_SIZE) >> 20, + rws->get_value(rws, RADEON_VID_VRAM_SIZE) >> 20, + rws->get_value(rws, RADEON_VID_CAN_AACOMPRESS) ? "YES" : "NO", + rws->get_value(rws, RADEON_VID_CAN_HYPERZ) && r300->screen->caps.zmask_ram ? "YES" : "NO", - rws->get_value(rws, R300_CAN_HYPERZ) && + rws->get_value(rws, RADEON_VID_CAN_HYPERZ) && r300->screen->caps.hiz_ram ? "YES" : "NO"); } diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index e395f41290e..8a0a54cf1e9 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -34,7 +34,7 @@ #include "r300_defines.h" #include "r300_screen.h" -#include "r300_winsys.h" +#include "../../winsys/radeon/drm/radeon_winsys.h" struct u_upload_mgr; struct r300_context; @@ -190,6 +190,7 @@ struct r300_texture_format_state { uint32_t format1; /* R300_TX_FORMAT1: 0x44c0 */ uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */ uint32_t tile_config; /* R300_TX_OFFSET (subset thereof) */ + uint32_t us_format0; /* R500_US_FORMAT0_0: 0x4640 (through 15) */ }; struct r300_sampler_view { @@ -211,7 +212,7 @@ struct r300_texture_sampler_state { struct r300_texture_format_state format; uint32_t filter0; /* R300_TX_FILTER0: 0x4400 */ uint32_t filter1; /* R300_TX_FILTER1: 0x4440 */ - uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */ + uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */ }; struct r300_textures_state { @@ -290,12 +291,12 @@ struct r300_query { boolean begin_emitted; /* The buffer where query results are stored. */ - struct r300_winsys_bo *buf; - struct r300_winsys_cs_handle *cs_buf; + struct pb_buffer *buf; + struct radeon_winsys_cs_handle *cs_buf; /* The size of the buffer. */ unsigned buffer_size; /* The domain of the buffer. */ - enum r300_buffer_domain domain; + enum radeon_bo_domain domain; /* Linked list members. */ struct r300_query* prev; @@ -306,10 +307,10 @@ struct r300_surface { struct pipe_surface base; /* Winsys buffer backing the texture. */ - struct r300_winsys_bo *buf; - struct r300_winsys_cs_handle *cs_buf; + struct pb_buffer *buf; + struct radeon_winsys_cs_handle *cs_buf; - enum r300_buffer_domain domain; + enum radeon_bo_domain domain; uint32_t offset; /* COLOROFFSET or DEPTHOFFSET. */ uint32_t pitch; /* COLORPITCH or DEPTHPITCH. */ @@ -339,8 +340,8 @@ struct r300_texture_desc { /* Buffer tiling. * Macrotiling is specified per-level because small mipmaps cannot * be macrotiled. */ - enum r300_buffer_tiling microtile; - enum r300_buffer_tiling macrotile[R300_MAX_TEXTURE_LEVELS]; + enum radeon_bo_layout microtile; + enum radeon_bo_layout macrotile[R300_MAX_TEXTURE_LEVELS]; /* Offsets into the buffer. */ unsigned offset_in_bytes[R300_MAX_TEXTURE_LEVELS]; @@ -396,9 +397,9 @@ struct r300_resource struct u_vbuf_resource b; /* Winsys buffer backing this resource. */ - struct r300_winsys_bo *buf; - struct r300_winsys_cs_handle *cs_buf; - enum r300_buffer_domain domain; + struct pb_buffer *buf; + struct radeon_winsys_cs_handle *cs_buf; + enum radeon_bo_domain domain; unsigned buf_size; /* Constant buffers are in user memory. */ @@ -447,14 +448,21 @@ enum r300_hiz_func { HIZ_FUNC_MIN, }; +/* For deferred fragment shader state validation. */ +enum r300_fs_validity_status { + FRAGMENT_SHADER_VALID, /* No need to change/validate the FS. */ + FRAGMENT_SHADER_MAYBE_DIRTY,/* Validate the FS if external state was changed. */ + FRAGMENT_SHADER_DIRTY /* Always validate the FS (if the FS was changed) */ +}; + struct r300_context { /* Parent class */ struct pipe_context context; /* The interface to the windowing system, etc. */ - struct r300_winsys_screen *rws; + struct radeon_winsys *rws; /* The command stream. */ - struct r300_winsys_cs *cs; + struct radeon_winsys_cs *cs; /* Screen. */ struct r300_screen *screen; @@ -580,6 +588,8 @@ struct r300_context { int sprite_coord_enable; /* Whether two-sided color selection is enabled (AKA light_twoside). */ boolean two_sided_color; + /* Whether fragment color clamping is enabled. */ + boolean frag_clamp; /* Whether fast color clear is enabled. */ boolean cbzb_clear; /* Whether ZMASK is enabled. */ @@ -596,6 +606,10 @@ struct r300_context { enum r300_hiz_func hiz_func; /* HiZ clear value. */ uint32_t hiz_clear_value; + /* Whether fragment shader needs to be validated. */ + enum r300_fs_validity_status fs_status; + /* Framebuffer multi-write. */ + boolean fb_multiwrite; void *dsa_decompress_zmask; diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 2e52dfa43c6..c208e672f42 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -29,7 +29,6 @@ #include "r300_reg.h" #include "r300_context.h" -#include "r300_winsys.h" /* Yes, I know macros are ugly. However, they are much prettier than the code * that they neatly hide away, and don't have the cost of function setup,so @@ -40,14 +39,14 @@ */ #define CS_LOCALS(context) \ - struct r300_winsys_cs *cs_copy = (context)->cs; \ - struct r300_winsys_screen *cs_winsys = (context)->rws; \ + struct radeon_winsys_cs *cs_copy = (context)->cs; \ + struct radeon_winsys *cs_winsys = (context)->rws; \ int cs_count = 0; (void) cs_count; (void) cs_winsys; #ifdef DEBUG #define BEGIN_CS(size) do { \ - assert(size <= (R300_MAX_CMDBUF_DWORDS - cs_copy->cdw)); \ + assert(size <= (RADEON_MAX_CMDBUF_DWORDS - cs_copy->cdw)); \ cs_count = size; \ } while (0) diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h index 2d111f9158d..30e9befad21 100644 --- a/src/gallium/drivers/r300/r300_defines.h +++ b/src/gallium/drivers/r300/r300_defines.h @@ -32,19 +32,4 @@ #define R300_INVALID_FORMAT 0xffff -/* Tiling flags. */ -enum r300_buffer_tiling { - R300_BUFFER_LINEAR = 0, - R300_BUFFER_TILED, - R300_BUFFER_SQUARETILED, - - R300_BUFFER_UNKNOWN, - R300_BUFFER_SELECT_LAYOUT = R300_BUFFER_UNKNOWN -}; - -enum r300_buffer_domain { /* bitfield */ - R300_DOMAIN_GTT = 2, - R300_DOMAIN_VRAM = 4 -}; - #endif diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index e17a907e77e..62435c5e2e2 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -375,7 +375,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state) struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)state; struct r300_surface* surf; unsigned i; - boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ); + boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ); uint32_t rb3d_cctl = 0; CS_LOCALS(r300); @@ -387,8 +387,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state) if (r300->screen->caps.is_r500) { rb3d_cctl = R300_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_ENABLE; } - if (fb->nr_cbufs && - r300_fragment_shader_writes_all(r300_fs(r300))) { + if (fb->nr_cbufs && r300->fb_multiwrite) { rb3d_cctl |= R300_RB3D_CCTL_NUM_MULTIWRITES(fb->nr_cbufs); } @@ -483,7 +482,7 @@ void r300_emit_fb_state_pipelined(struct r300_context *r300, /* If we use the multiwrite feature, the colorbuffers 2,3,4 must be * marked as UNUSED in the US block. */ - if (r300_fragment_shader_writes_all(r300_fs(r300))) { + if (r300->fb_multiwrite) { num_cbufs = MIN2(num_cbufs, 1); } @@ -495,6 +494,11 @@ void r300_emit_fb_state_pipelined(struct r300_context *r300, for (i = 0; i < num_cbufs; i++) { OUT_CS(r300_surface(fb->cbufs[i])->format); } + for (; i < 1; i++) { + OUT_CS(R300_US_OUT_FMT_C4_8 | + R300_C0_SEL_B | R300_C1_SEL_G | + R300_C2_SEL_R | R300_C3_SEL_A); + } for (; i < 4; i++) { OUT_CS(R300_US_OUT_FMT_UNUSED); } @@ -771,6 +775,7 @@ void r300_emit_textures_state(struct r300_context *r300, struct r300_texture_sampler_state *texstate; struct r300_resource *tex; unsigned i; + boolean has_us_format = r300->screen->caps.has_us_format; CS_LOCALS(r300); BEGIN_CS(size); @@ -792,6 +797,11 @@ void r300_emit_textures_state(struct r300_context *r300, OUT_CS_REG(R300_TX_OFFSET_0 + (i * 4), texstate->format.tile_config); OUT_CS_RELOC(tex); + + if (has_us_format) { + OUT_CS_REG(R500_US_FORMAT0_0 + (i * 4), + texstate->format.us_format0); + } } } END_CS; @@ -1221,7 +1231,7 @@ validate: if (flushed) return FALSE; - r300_flush(&r300->context, R300_FLUSH_ASYNC, NULL); + r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL); flushed = TRUE; goto validate; } diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index b3d0d344ec4..de7d77d608b 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -38,7 +38,7 @@ void r300_flush(struct pipe_context *pipe, { struct r300_context *r300 = r300_context(pipe); struct r300_atom *atom; - struct r300_winsys_bo **rfence = (struct r300_winsys_bo**)fence; + struct pb_buffer **rfence = (struct pb_buffer**)fence; if (r300->draw && !r300->draw_vbo_locked) r300_draw_flush_vbuf(r300); @@ -48,11 +48,11 @@ void r300_flush(struct pipe_context *pipe, *rfence = r300->rws->buffer_create(r300->rws, 1, 1, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STATIC, - R300_DOMAIN_GTT); + RADEON_DOMAIN_GTT); /* Add the fence as a dummy relocation. */ r300->rws->cs_add_reloc(r300->cs, r300->rws->buffer_get_cs_handle(*rfence), - R300_DOMAIN_GTT, R300_DOMAIN_GTT); + RADEON_DOMAIN_GTT, RADEON_DOMAIN_GTT); } if (r300->dirty_hw) { diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 4c502fefb3f..e3a1bc4a0f4 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -22,6 +22,7 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" @@ -34,6 +35,7 @@ #include "r300_screen.h" #include "r300_fs.h" #include "r300_reg.h" +#include "r300_texture.h" #include "r300_tgsi_to_rc.h" #include "radeon_code.h" @@ -146,10 +148,10 @@ static void get_external_state( struct r300_fragment_program_external_state* state) { struct r300_textures_state *texstate = r300->textures_state.state; + struct r300_rs_state *rs = r300->rs_state.state; unsigned i; - unsigned char *swizzle; - state->frag_clamp = 0; + state->frag_clamp = rs ? rs->rs.clamp_fragment_color : 0; for (i = 0; i < texstate->sampler_state_count; i++) { struct r300_sampler_state *s = texstate->sampler_states[i]; @@ -160,27 +162,37 @@ static void get_external_state( continue; } - t = r300_resource(texstate->sampler_views[i]->base.texture); + t = r300_resource(v->base.texture); if (s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { state->unit[i].compare_mode_enabled = 1; - /* Pass depth texture swizzling to the compiler. */ - if (texstate->sampler_views[i]) { - swizzle = texstate->sampler_views[i]->swizzle; - - state->unit[i].depth_texture_swizzle = - RC_MAKE_SWIZZLE(swizzle[0], swizzle[1], - swizzle[2], swizzle[3]); - } else { - state->unit[i].depth_texture_swizzle = RC_SWIZZLE_XYZW; - } - /* Fortunately, no need to translate this. */ state->unit[i].texture_compare_func = s->state.compare_func; } state->unit[i].non_normalized_coords = !s->state.normalized_coords; + state->unit[i].convert_unorm_to_snorm = + v->base.format == PIPE_FORMAT_RGTC1_SNORM || + v->base.format == PIPE_FORMAT_LATC1_SNORM; + + /* Pass texture swizzling to the compiler, some lowering passes need it. */ + if (v->base.format == PIPE_FORMAT_RGTC1_SNORM || + v->base.format == PIPE_FORMAT_LATC1_SNORM) { + unsigned char swizzle[4]; + + util_format_combine_swizzles(swizzle, + util_format_description(v->base.format)->swizzle, + v->swizzle); + + state->unit[i].texture_swizzle = + RC_MAKE_SWIZZLE(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); + } else if (state->unit[i].compare_mode_enabled) { + state->unit[i].texture_swizzle = + RC_MAKE_SWIZZLE(v->swizzle[0], v->swizzle[1], + v->swizzle[2], v->swizzle[3]); + } /* XXX this should probably take into account STR, not just S. */ if (t->tex.is_npot) { diff --git a/src/gallium/drivers/r300/r300_hyperz.c b/src/gallium/drivers/r300/r300_hyperz.c index ecaadf4af8e..ef330f34c9e 100644 --- a/src/gallium/drivers/r300/r300_hyperz.c +++ b/src/gallium/drivers/r300/r300_hyperz.c @@ -24,7 +24,6 @@ #include "r300_context.h" #include "r300_reg.h" #include "r300_fs.h" -#include "r300_winsys.h" #include "util/u_format.h" #include "util/u_mm.h" @@ -153,7 +152,7 @@ static void r300_update_hyperz(struct r300_context* r300) } if (!zstex || - !r300->rws->get_value(r300->rws, R300_CAN_HYPERZ)) + !r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ)) return; /* Zbuffer compression. */ diff --git a/src/gallium/drivers/r300/r300_public.h b/src/gallium/drivers/r300/r300_public.h index 8e7a963c55d..b6059203ff1 100644 --- a/src/gallium/drivers/r300/r300_public.h +++ b/src/gallium/drivers/r300/r300_public.h @@ -2,8 +2,8 @@ #ifndef R300_PUBLIC_H #define R300_PUBLIC_H -struct r300_winsys_screen; +struct radeon_winsys; -struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws); +struct pipe_screen* r300_screen_create(struct radeon_winsys *rws); #endif diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 717485f43cb..9752a519491 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -26,7 +26,6 @@ #include "r300_context.h" #include "r300_screen.h" #include "r300_emit.h" -#include "r300_winsys.h" #include <stdio.h> @@ -46,7 +45,7 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe, return NULL; q->type = query_type; - q->domain = R300_DOMAIN_GTT; + q->domain = RADEON_DOMAIN_GTT; q->buffer_size = 4096; if (r300screen->caps.family == CHIP_FAMILY_RV530) @@ -70,7 +69,7 @@ static void r300_destroy_query(struct pipe_context* pipe, { struct r300_query* q = r300_query(query); - r300_winsys_bo_reference(&q->buf, NULL); + pb_reference(&q->buf, NULL); remove_from_list(q); FREE(query); } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 26594dabe42..429b85545f7 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -218,8 +218,8 @@ static boolean r300_reserve_cs_dwords(struct r300_context *r300, cs_dwords += r300_get_num_cs_end_dwords(r300); /* Reserve requested CS space. */ - if (cs_dwords > (R300_MAX_CMDBUF_DWORDS - r300->cs->cdw)) { - r300_flush(&r300->context, R300_FLUSH_ASYNC, NULL); + if (cs_dwords > (RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw)) { + r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL); flushed = TRUE; } @@ -343,7 +343,7 @@ static boolean immd_is_good_idea(struct r300_context *r300, if (!checked[vbi]) { buf = r300->vbuf_mgr->real_vertex_buffer[vbi]; - if ((r300_resource(buf)->domain != R300_DOMAIN_GTT)) { + if ((r300_resource(buf)->domain != RADEON_DOMAIN_GTT)) { return FALSE; } @@ -1080,7 +1080,7 @@ static void r300_render_draw_elements(struct vbuf_render* render, end_cs_dwords = r300_get_num_cs_end_dwords(r300); while (count) { - free_dwords = R300_MAX_CMDBUF_DWORDS - r300->cs->cdw; + free_dwords = RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw; short_count = MIN2(count, (free_dwords - end_cs_dwords - 6) * 2); diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 8a69628c53e..9ec16c6562f 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -30,7 +30,6 @@ #include "r300_texture.h" #include "r300_screen_buffer.h" #include "r300_state_inlines.h" -#include "r300_winsys.h" #include "r300_public.h" #include "draw/draw_context.h" @@ -114,9 +113,12 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_TEXTURE_MIRROR_REPEAT: case PIPE_CAP_BLEND_EQUATION_SEPARATE: case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: - return 1; + case PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL: + return is_r500 ? 1 : 0; case PIPE_CAP_TEXTURE_SWIZZLE: return util_format_s3tc_enabled ? r300screen->caps.dxtc_swizzle : 1; + case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: + return is_r500 ? 1 : 0; /* Unsupported features (boolean caps). */ case PIPE_CAP_TIMER_QUERY: @@ -127,12 +129,12 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: case PIPE_CAP_SHADER_STENCIL_EXPORT: case PIPE_CAP_ARRAY_TEXTURES: + case PIPE_CAP_TGSI_INSTANCEID: return 0; /* SWTCL-only features. */ case PIPE_CAP_STREAM_OUTPUT: case PIPE_CAP_PRIMITIVE_RESTART: - case PIPE_CAP_TGSI_INSTANCEID: return !r300screen->caps.has_tcl; /* Texturing. */ @@ -209,7 +211,7 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e case PIPE_SHADER_CAP_MAX_PREDS: return is_r500 ? 1 : 0; case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: - return 1; + return 0; case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: @@ -247,7 +249,7 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e case PIPE_SHADER_CAP_MAX_PREDS: return is_r500 ? 4 : 0; /* XXX guessed. */ case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: - return 1; + return 0; case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: @@ -308,9 +310,9 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, unsigned sample_count, unsigned usage) { - struct r300_winsys_screen *rws = r300_screen(screen)->rws; + struct radeon_winsys *rws = r300_screen(screen)->rws; uint32_t retval = 0; - boolean drm_2_8_0 = rws->get_value(rws, R300_VID_DRM_2_8_0); + boolean drm_2_8_0 = rws->get_value(rws, RADEON_VID_DRM_2_8_0); boolean is_r500 = r300_screen(screen)->caps.is_r500; boolean is_r400 = r300_screen(screen)->caps.is_r400; boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM || @@ -325,11 +327,20 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, format == PIPE_FORMAT_RGTC2_SNORM || format == PIPE_FORMAT_LATC2_UNORM || format == PIPE_FORMAT_LATC2_SNORM; + boolean is_x16f_xy16f = format == PIPE_FORMAT_R16_FLOAT || + format == PIPE_FORMAT_R16G16_FLOAT || + format == PIPE_FORMAT_A16_FLOAT || + format == PIPE_FORMAT_L16_FLOAT || + format == PIPE_FORMAT_L16A16_FLOAT || + format == PIPE_FORMAT_I16_FLOAT; boolean is_half_float = format == PIPE_FORMAT_R16_FLOAT || format == PIPE_FORMAT_R16G16_FLOAT || format == PIPE_FORMAT_R16G16B16_FLOAT || format == PIPE_FORMAT_R16G16B16A16_FLOAT; + if (!util_format_is_supported(format, usage)) + return FALSE; + /* Check multisampling support. */ switch (sample_count) { case 0: @@ -358,6 +369,8 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, (is_r500 || !is_ati1n) && /* ATI2N is supported on r4xx-r5xx. */ (is_r400 || is_r500 || !is_ati2n) && + /* R16F and RG16F texture support was added in as late as DRM 2.8.0 */ + (drm_2_8_0 || !is_x16f_xy16f) && r300_is_sampler_format_supported(format)) { retval |= PIPE_BIND_SAMPLER_VIEW; } @@ -403,7 +416,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, static void r300_destroy_screen(struct pipe_screen* pscreen) { struct r300_screen* r300screen = r300_screen(pscreen); - struct r300_winsys_screen *rws = r300_winsys_screen(pscreen); + struct radeon_winsys *rws = radeon_winsys(pscreen); util_slab_destroy(&r300screen->pool_buffers); pipe_mutex_destroy(r300screen->num_contexts_mutex); @@ -418,15 +431,15 @@ static void r300_fence_reference(struct pipe_screen *screen, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence) { - r300_winsys_bo_reference((struct r300_winsys_bo**)ptr, - (struct r300_winsys_bo*)fence); + pb_reference((struct pb_buffer**)ptr, + (struct pb_buffer*)fence); } static boolean r300_fence_signalled(struct pipe_screen *screen, struct pipe_fence_handle *fence) { - struct r300_winsys_screen *rws = r300_screen(screen)->rws; - struct r300_winsys_bo *rfence = (struct r300_winsys_bo*)fence; + struct radeon_winsys *rws = r300_screen(screen)->rws; + struct pb_buffer *rfence = (struct pb_buffer*)fence; return !rws->buffer_is_busy(rfence); } @@ -435,8 +448,8 @@ static boolean r300_fence_finish(struct pipe_screen *screen, struct pipe_fence_handle *fence, uint64_t timeout) { - struct r300_winsys_screen *rws = r300_screen(screen)->rws; - struct r300_winsys_bo *rfence = (struct r300_winsys_bo*)fence; + struct radeon_winsys *rws = r300_screen(screen)->rws; + struct pb_buffer *rfence = (struct pb_buffer*)fence; if (timeout != PIPE_TIMEOUT_INFINITE) { int64_t start_time = os_time_get(); @@ -458,7 +471,7 @@ static boolean r300_fence_finish(struct pipe_screen *screen, return TRUE; } -struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws) +struct pipe_screen* r300_screen_create(struct radeon_winsys *rws) { struct r300_screen *r300screen = CALLOC_STRUCT(r300_screen); @@ -467,9 +480,9 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws) return NULL; } - r300screen->caps.pci_id = rws->get_value(rws, R300_VID_PCI_ID); - r300screen->caps.num_frag_pipes = rws->get_value(rws, R300_VID_GB_PIPES); - r300screen->caps.num_z_pipes = rws->get_value(rws, R300_VID_Z_PIPES); + r300screen->caps.pci_id = rws->get_value(rws, RADEON_VID_PCI_ID); + r300screen->caps.num_frag_pipes = rws->get_value(rws, RADEON_VID_R300_GB_PIPES); + r300screen->caps.num_z_pipes = rws->get_value(rws, RADEON_VID_R300_Z_PIPES); r300_init_debug(r300screen); r300_parse_chipset(&r300screen->caps); @@ -479,6 +492,9 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws) if (SCREEN_DBG_ON(r300screen, DBG_NO_HIZ)) r300screen->caps.hiz_ram = 0; + if (!rws->get_value(rws, RADEON_VID_DRM_2_8_0)) + r300screen->caps.has_us_format = FALSE; + pipe_mutex_init(r300screen->num_contexts_mutex); util_slab_create(&r300screen->pool_buffers, diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 576f9c1f4a9..bca86edb1d7 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -32,13 +32,13 @@ #include <stdio.h> -struct r300_winsys_screen; +struct radeon_winsys; struct r300_screen { /* Parent class */ struct pipe_screen screen; - struct r300_winsys_screen *rws; + struct radeon_winsys *rws; /* Chipset capabilities */ struct r300_capabilities caps; @@ -61,8 +61,8 @@ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) { return (struct r300_screen*)screen; } -static INLINE struct r300_winsys_screen * -r300_winsys_screen(struct pipe_screen *screen) { +static INLINE struct radeon_winsys * +radeon_winsys(struct pipe_screen *screen) { return r300_screen(screen)->rws; } diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index 986ae384fbf..4154c81512e 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -31,7 +31,6 @@ #include "util/u_math.h" #include "r300_screen_buffer.h" -#include "r300_winsys.h" void r300_upload_index_buffer(struct r300_context *r300, struct pipe_resource **index_buffer, @@ -62,7 +61,7 @@ static void r300_buffer_destroy(struct pipe_screen *screen, FREE(rbuf->constant_buffer); if (rbuf->buf) - r300_winsys_bo_reference(&rbuf->buf, NULL); + pb_reference(&rbuf->buf, NULL); util_slab_free(&r300screen->pool_buffers, rbuf); } @@ -105,7 +104,7 @@ r300_buffer_transfer_map( struct pipe_context *pipe, { struct r300_context *r300 = r300_context(pipe); struct r300_screen *r300screen = r300_screen(pipe->screen); - struct r300_winsys_screen *rws = r300screen->rws; + struct radeon_winsys *rws = r300screen->rws; struct r300_resource *rbuf = r300_resource(transfer->resource); uint8_t *map; @@ -126,7 +125,7 @@ static void r300_buffer_transfer_unmap( struct pipe_context *pipe, struct pipe_transfer *transfer ) { struct r300_screen *r300screen = r300_screen(pipe->screen); - struct r300_winsys_screen *rws = r300screen->rws; + struct radeon_winsys *rws = r300screen->rws; struct r300_resource *rbuf = r300_resource(transfer->resource); if (rbuf->buf) { @@ -144,7 +143,7 @@ static void r300_buffer_transfer_inline_write(struct pipe_context *pipe, unsigned layer_stride) { struct r300_context *r300 = r300_context(pipe); - struct r300_winsys_screen *rws = r300->screen->rws; + struct radeon_winsys *rws = r300->screen->rws; struct r300_resource *rbuf = r300_resource(resource); uint8_t *map = NULL; @@ -188,7 +187,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen, pipe_reference_init(&rbuf->b.b.b.reference, 1); rbuf->b.b.b.screen = screen; rbuf->b.user_ptr = NULL; - rbuf->domain = R300_DOMAIN_GTT; + rbuf->domain = RADEON_DOMAIN_GTT; rbuf->buf = NULL; rbuf->buf_size = templ->width0; rbuf->constant_buffer = NULL; @@ -237,7 +236,7 @@ struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen, rbuf->b.b.b.flags = 0; rbuf->b.b.vtbl = &r300_buffer_vtbl; rbuf->b.user_ptr = ptr; - rbuf->domain = R300_DOMAIN_GTT; + rbuf->domain = RADEON_DOMAIN_GTT; rbuf->buf = NULL; rbuf->buf_size = size; rbuf->constant_buffer = NULL; diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h index cdbc4425fcb..360ec509cc5 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.h +++ b/src/gallium/drivers/r300/r300_screen_buffer.h @@ -32,7 +32,6 @@ #include "util/u_transfer.h" #include "r300_screen.h" -#include "r300_winsys.h" #include "r300_context.h" /* Functions. */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index ecb4fc691cc..24b41d5085d 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -45,7 +45,6 @@ #include "r300_fs.h" #include "r300_texture.h" #include "r300_vs.h" -#include "r300_winsys.h" /* r300_state: Functions used to intialize state context by translating * Gallium state objects into semi-native r300 state objects. */ @@ -398,10 +397,6 @@ static void r300_bind_blend_state(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); UPDATE_STATE(state, r300->blend_state); - - if (r300->fs.state && r300_pick_fragment_shader(r300)) { - r300_mark_fs_code_dirty(r300); - } } /* Free blend state. */ @@ -773,7 +768,7 @@ void r300_mark_fb_state_dirty(struct r300_context *r300, enum r300_fb_state_change change) { struct pipe_framebuffer_state *state = r300->fb_state.state; - boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ); + boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ); r300_mark_atom_dirty(r300, &r300->gpu_flush); r300_mark_atom_dirty(r300, &r300->fb_state); @@ -860,6 +855,7 @@ r300_set_framebuffer_state(struct pipe_context* pipe, } } } + assert(state->zsbuf || r300->hyperz_locked || !r300->zmask_in_use); /* Need to reset clamping or colormask. */ r300_mark_atom_dirty(r300, &r300->blend_state); @@ -973,24 +969,14 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader) { struct r300_context* r300 = r300_context(pipe); struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader; - struct pipe_framebuffer_state *fb = r300->fb_state.state; - boolean last_multi_write; if (fs == NULL) { r300->fs.state = NULL; return; } - last_multi_write = r300_fragment_shader_writes_all(r300_fs(r300)); - r300->fs.state = fs; - r300_pick_fragment_shader(r300); - r300_mark_fs_code_dirty(r300); - - if (fb->nr_cbufs > 1 && - last_multi_write != r300_fragment_shader_writes_all(fs)) { - r300_mark_fb_state_dirty(r300, R300_CHANGED_MULTIWRITE); - } + r300->fs_status = FRAGMENT_SHADER_DIRTY; r300_mark_atom_dirty(r300, &r300->rs_block_state); /* Will be updated before the emission. */ } @@ -1047,7 +1033,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe, float point_texcoord_bottom = 0;/* R300_GA_POINT_T0: 0x4204 */ float point_texcoord_right = 1; /* R300_GA_POINT_S1: 0x4208 */ float point_texcoord_top = 0; /* R300_GA_POINT_T1: 0x420c */ - boolean vclamp = TRUE; + boolean vclamp = state->clamp_vertex_color; CB_LOCALS; /* Copy rasterizer state. */ @@ -1233,6 +1219,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) struct r300_rs_state* rs = (struct r300_rs_state*)state; int last_sprite_coord_enable = r300->sprite_coord_enable; boolean last_two_sided_color = r300->two_sided_color; + boolean last_frag_clamp = r300->frag_clamp; if (r300->draw && rs) { draw_set_rasterizer_state(r300->draw, &rs->rs_draw, state); @@ -1242,10 +1229,12 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) r300->polygon_offset_enabled = rs->polygon_offset_enable; r300->sprite_coord_enable = rs->rs.sprite_coord_enable; r300->two_sided_color = rs->rs.light_twoside; + r300->frag_clamp = rs->rs.clamp_fragment_color; } else { r300->polygon_offset_enabled = FALSE; r300->sprite_coord_enable = 0; r300->two_sided_color = FALSE; + r300->frag_clamp = FALSE; } UPDATE_STATE(state, r300->rs_state); @@ -1255,6 +1244,11 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) last_two_sided_color != r300->two_sided_color) { r300_mark_atom_dirty(r300, &r300->rs_block_state); } + + if (last_frag_clamp != r300->frag_clamp && + r300->fs_status == FRAGMENT_SHADER_VALID) { + r300->fs_status = FRAGMENT_SHADER_MAYBE_DIRTY; + } } /* Free rasterizer state. */ @@ -1551,7 +1545,8 @@ static void r300_set_viewport_state(struct pipe_context* pipe, } r300_mark_atom_dirty(r300, &r300->viewport_state); - if (r300->fs.state && r300_fs(r300)->shader->inputs.wpos != ATTR_UNUSED) { + if (r300->fs.state && r300_fs(r300)->shader && + r300_fs(r300)->shader->inputs.wpos != ATTR_UNUSED) { r300_mark_atom_dirty(r300, &r300->fs_rc_constant_state); } } diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index ec00e2552ca..afc1451183d 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -592,6 +592,13 @@ static void r300_update_rs_block(struct r300_context *r300) } } +static void rgba_to_bgra(float color[4]) +{ + float x = color[0]; + color[0] = color[2]; + color[2] = x; +} + static uint32_t r300_get_border_color(enum pipe_format format, const float border[4], boolean is_r500) @@ -625,13 +632,13 @@ static uint32_t r300_get_border_color(enum pipe_format format, for (i = 0; i < 4; i++) { switch (desc->swizzle[i]) { case UTIL_FORMAT_SWIZZLE_X: - border_swizzled[2] = border[i]; + border_swizzled[0] = border[i]; break; case UTIL_FORMAT_SWIZZLE_Y: border_swizzled[1] = border[i]; break; case UTIL_FORMAT_SWIZZLE_Z: - border_swizzled[0] = border[i]; + border_swizzled[2] = border[i]; break; case UTIL_FORMAT_SWIZZLE_W: border_swizzled[3] = border[i]; @@ -643,39 +650,46 @@ static uint32_t r300_get_border_color(enum pipe_format format, if (util_format_is_compressed(format)) { switch (format) { case PIPE_FORMAT_RGTC1_SNORM: - case PIPE_FORMAT_RGTC1_UNORM: case PIPE_FORMAT_LATC1_SNORM: + border_swizzled[0] = border_swizzled[0] < 0 ? + border_swizzled[0]*0.5+1 : + border_swizzled[0]*0.5; + /* Pass through. */ + + case PIPE_FORMAT_RGTC1_UNORM: case PIPE_FORMAT_LATC1_UNORM: /* Add 1/32 to round the border color instead of truncating. */ /* The Y component is used for the border color. */ - border_swizzled[1] = border_swizzled[2] + 1.0f/32; + border_swizzled[1] = border_swizzled[0] + 1.0f/32; util_pack_color(border_swizzled, PIPE_FORMAT_B4G4R4A4_UNORM, &uc); return uc.ui; case PIPE_FORMAT_RGTC2_SNORM: case PIPE_FORMAT_LATC2_SNORM: - border_swizzled[0] = border_swizzled[2]; util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc); return uc.ui; case PIPE_FORMAT_RGTC2_UNORM: case PIPE_FORMAT_LATC2_UNORM: - util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); + util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); return uc.ui; default: - util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); + util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); return uc.ui; } } switch (desc->channel[0].size) { case 2: + rgba_to_bgra(border_swizzled); util_pack_color(border_swizzled, PIPE_FORMAT_B2G3R3_UNORM, &uc); break; case 4: + rgba_to_bgra(border_swizzled); util_pack_color(border_swizzled, PIPE_FORMAT_B4G4R4A4_UNORM, &uc); break; case 5: + rgba_to_bgra(border_swizzled); if (desc->channel[1].size == 5) { util_pack_color(border_swizzled, PIPE_FORMAT_B5G5R5A1_UNORM, &uc); } else if (desc->channel[1].size == 6) { @@ -687,32 +701,39 @@ static uint32_t r300_get_border_color(enum pipe_format format, default: case 8: - util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); + if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) + util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc); + else + util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); break; case 10: - util_pack_color(border_swizzled, PIPE_FORMAT_B10G10R10A2_UNORM, &uc); + util_pack_color(border_swizzled, PIPE_FORMAT_R10G10B10A2_UNORM, &uc); break; case 16: if (desc->nr_channels <= 2) { - border_swizzled[0] = border_swizzled[2]; if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT) { util_pack_color(border_swizzled, PIPE_FORMAT_R16G16_FLOAT, &uc); + } else if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) { + util_pack_color(border_swizzled, PIPE_FORMAT_R16G16_SNORM, &uc); } else { util_pack_color(border_swizzled, PIPE_FORMAT_R16G16_UNORM, &uc); } } else { - util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); + if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) { + util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc); + } else { + util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); + } } break; case 32: if (desc->nr_channels == 1) { - border_swizzled[0] = border_swizzled[2]; util_pack_color(border_swizzled, PIPE_FORMAT_R32_FLOAT, &uc); } else { - util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); + util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc); } break; } @@ -720,25 +741,6 @@ static uint32_t r300_get_border_color(enum pipe_format format, return uc.ui; } -static boolean util_format_is_float(enum pipe_format format) -{ - const struct util_format_description *desc = util_format_description(format); - unsigned i; - - if (!format) - return FALSE; - - /* Find the first non-void channel. */ - for (i = 0; i < 4; i++) - if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) - break; - - if (i == 4) - return FALSE; - - return desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT ? TRUE : FALSE; -} - static void r300_merge_textures_and_samplers(struct r300_context* r300) { struct r300_textures_state *state = @@ -747,9 +749,10 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) struct r300_sampler_state *sampler; struct r300_sampler_view *view; struct r300_resource *tex; - unsigned min_level, max_level, i, j, size; + unsigned base_level, min_level, level_count, i, j, size; unsigned count = MIN2(state->sampler_view_count, state->sampler_state_count); + boolean has_us_format = r300->screen->caps.has_us_format; /* The KIL opcode fix, see below. */ if (!count && !r300->screen->caps.is_r500) @@ -779,21 +782,27 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) r300->screen->caps.is_r500); /* determine min/max levels */ - max_level = MIN3(sampler->max_lod + view->base.u.tex.first_level, - tex->b.b.b.last_level, view->base.u.tex.last_level); - min_level = MIN2(sampler->min_lod + view->base.u.tex.first_level, - max_level); - - if (tex->tex.is_npot && min_level > 0) { - /* Even though we do not implement mipmapping for NPOT - * textures, we should at least honor the minimum level - * which is allowed to be displayed. We do this by setting up - * the i-th mipmap level as the zero level. */ - unsigned offset = tex->tex_offset + - tex->tex.offset_in_bytes[min_level]; + base_level = view->base.u.tex.first_level; + min_level = sampler->min_lod; + level_count = MIN3(sampler->max_lod, + tex->b.b.b.last_level - base_level, + view->base.u.tex.last_level - base_level); + + if (base_level + min_level) { + unsigned offset; + + if (tex->tex.is_npot) { + /* Even though we do not implement mipmapping for NPOT + * textures, we should at least honor the minimum level + * which is allowed to be displayed. We do this by setting up + * an i-th mipmap level as the zero level. */ + base_level += min_level; + } + offset = tex->tex_offset + + tex->tex.offset_in_bytes[base_level]; r300_texture_setup_format_state(r300->screen, tex, - min_level, + base_level, &texstate->format); texstate->format.tile_config |= offset & 0xffffffe0; assert((offset & 0x1f) == 0); @@ -870,7 +879,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) } } else { /* the MAX_MIP level is the largest (finest) one */ - texstate->format.format0 |= R300_TX_NUM_LEVELS(max_level); + texstate->format.format0 |= R300_TX_NUM_LEVELS(level_count); texstate->filter0 |= R300_TX_MAX_MIP_LEVEL(min_level); } @@ -902,7 +911,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) texstate->filter0 |= i << 28; - size += 16; + size += 16 + (has_us_format ? 2 : 0); state->count = i+1; } else { /* For the KIL opcode to work on r3xx-r4xx, the texture unit @@ -931,7 +940,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) texstate->border_color = 0; texstate->filter0 |= i << 28; - size += 16; + size += 16 + (has_us_format ? 2 : 0); state->count = i+1; } } @@ -940,11 +949,10 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) r300->textures_state.size = size; /* Pick a fragment shader based on either the texture compare state - * or the uses_pitch flag. */ - if (r300->fs.state && count) { - if (r300_pick_fragment_shader(r300)) { - r300_mark_fs_code_dirty(r300); - } + * or the uses_pitch flag or some other external state. */ + if (count && + r300->fs_status == FRAGMENT_SHADER_VALID) { + r300->fs_status = FRAGMENT_SHADER_MAYBE_DIRTY; } } @@ -973,6 +981,34 @@ static void r300_decompress_depth_textures(struct r300_context *r300) } } +static void r300_validate_fragment_shader(struct r300_context *r300) +{ + struct pipe_framebuffer_state *fb = r300->fb_state.state; + + if (r300->fs.state && r300->fs_status != FRAGMENT_SHADER_VALID) { + /* Pick the fragment shader based on external states. + * Then mark the state dirty if the fragment shader is either dirty + * or the function r300_pick_fragment_shader changed the shader. */ + if (r300_pick_fragment_shader(r300) || + r300->fs_status == FRAGMENT_SHADER_DIRTY) { + /* Mark the state atom as dirty. */ + r300_mark_fs_code_dirty(r300); + + /* Does Multiwrite need to be changed? */ + if (fb->nr_cbufs > 1) { + boolean new_multiwrite = + r300_fragment_shader_writes_all(r300_fs(r300)); + + if (r300->fb_multiwrite != new_multiwrite) { + r300->fb_multiwrite = new_multiwrite; + r300_mark_fb_state_dirty(r300, R300_CHANGED_MULTIWRITE); + } + } + } + r300->fs_status = FRAGMENT_SHADER_VALID; + } +} + void r300_update_derived_state(struct r300_context* r300) { if (r300->textures_state.dirty) { @@ -980,6 +1016,8 @@ void r300_update_derived_state(struct r300_context* r300) r300_merge_textures_and_samplers(r300); } + r300_validate_fragment_shader(r300); + if (r300->rs_block_state.dirty) { r300_update_rs_block(r300); diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index c650fb7ed37..38ca9a24e45 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -29,7 +29,6 @@ #include "r300_texture_desc.h" #include "r300_transfer.h" #include "r300_screen.h" -#include "r300_winsys.h" #include "util/u_format.h" #include "util/u_format_s3tc.h" @@ -39,6 +38,18 @@ #include "pipe/p_screen.h" +void util_format_combine_swizzles(unsigned char *dst, + const unsigned char *swz1, + const unsigned char *swz2) +{ + unsigned i; + + for (i = 0; i < 4; i++) { + dst[i] = swz2[i] <= UTIL_FORMAT_SWIZZLE_W ? + swz1[swz2[i]] : swz2[i]; + } +} + unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format, const unsigned char *swizzle_view, boolean dxtc_swizzle) @@ -61,10 +72,7 @@ unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format, if (swizzle_view) { /* Combine two sets of swizzles. */ - for (i = 0; i < 4; i++) { - swizzle[i] = swizzle_view[i] <= UTIL_FORMAT_SWIZZLE_W ? - swizzle_format[swizzle_view[i]] : swizzle_view[i]; - } + util_format_combine_swizzles(swizzle, swizzle_format, swizzle_view); } else { memcpy(swizzle, swizzle_format, 4); } @@ -116,10 +124,10 @@ uint32_t r300_translate_texformat(enum pipe_format format, unsigned i; boolean uniform = TRUE; const uint32_t sign_bit[4] = { - R300_TX_FORMAT_SIGNED_X, - R300_TX_FORMAT_SIGNED_Y, - R300_TX_FORMAT_SIGNED_Z, R300_TX_FORMAT_SIGNED_W, + R300_TX_FORMAT_SIGNED_Z, + R300_TX_FORMAT_SIGNED_Y, + R300_TX_FORMAT_SIGNED_X, }; desc = util_format_description(format); @@ -171,17 +179,22 @@ uint32_t r300_translate_texformat(enum pipe_format format, } } - if (util_format_is_compressed(format) && - dxtc_swizzle && - format != PIPE_FORMAT_RGTC2_UNORM && - format != PIPE_FORMAT_RGTC2_SNORM && - format != PIPE_FORMAT_LATC2_UNORM && - format != PIPE_FORMAT_LATC2_SNORM) { - result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, - TRUE); - } else { - result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, - FALSE); + /* Add swizzling. */ + /* The RGTC1_SNORM and LATC1_SNORM swizzle is done in the shader. */ + if (format != PIPE_FORMAT_RGTC1_SNORM && + format != PIPE_FORMAT_LATC1_SNORM) { + if (util_format_is_compressed(format) && + dxtc_swizzle && + format != PIPE_FORMAT_RGTC2_UNORM && + format != PIPE_FORMAT_RGTC2_SNORM && + format != PIPE_FORMAT_LATC2_UNORM && + format != PIPE_FORMAT_LATC2_SNORM) { + result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, + TRUE); + } else { + result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view, + FALSE); + } } /* S3TC formats. */ @@ -212,14 +225,13 @@ uint32_t r300_translate_texformat(enum pipe_format format, switch (format) { case PIPE_FORMAT_RGTC1_SNORM: case PIPE_FORMAT_LATC1_SNORM: - result |= sign_bit[1]; case PIPE_FORMAT_LATC1_UNORM: case PIPE_FORMAT_RGTC1_UNORM: return R500_TX_FORMAT_ATI1N | result; case PIPE_FORMAT_RGTC2_SNORM: case PIPE_FORMAT_LATC2_SNORM: - result |= sign_bit[2] | sign_bit[3]; + result |= sign_bit[1] | sign_bit[0]; case PIPE_FORMAT_RGTC2_UNORM: case PIPE_FORMAT_LATC2_UNORM: return R400_TX_FORMAT_ATI2N | result; @@ -390,20 +402,33 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) switch (format) { /* 8-bit buffers. */ case PIPE_FORMAT_A8_UNORM: - /*case PIPE_FORMAT_A8_SNORM:*/ + case PIPE_FORMAT_A8_SNORM: case PIPE_FORMAT_I8_UNORM: - /*case PIPE_FORMAT_I8_SNORM:*/ + case PIPE_FORMAT_I8_SNORM: case PIPE_FORMAT_L8_UNORM: - /*case PIPE_FORMAT_L8_SNORM:*/ + case PIPE_FORMAT_L8_SNORM: case PIPE_FORMAT_R8_UNORM: case PIPE_FORMAT_R8_SNORM: return R300_COLOR_FORMAT_I8; /* 16-bit buffers. */ case PIPE_FORMAT_L8A8_UNORM: - /*case PIPE_FORMAT_L8A8_SNORM:*/ + case PIPE_FORMAT_L8A8_SNORM: case PIPE_FORMAT_R8G8_UNORM: case PIPE_FORMAT_R8G8_SNORM: + /* These formats work fine with UV88 if US_OUT_FMT is set correctly. */ + case PIPE_FORMAT_A16_UNORM: + case PIPE_FORMAT_A16_SNORM: + case PIPE_FORMAT_A16_FLOAT: + case PIPE_FORMAT_L16_UNORM: + case PIPE_FORMAT_L16_SNORM: + case PIPE_FORMAT_L16_FLOAT: + case PIPE_FORMAT_I16_UNORM: + case PIPE_FORMAT_I16_SNORM: + case PIPE_FORMAT_I16_FLOAT: + case PIPE_FORMAT_R16_UNORM: + case PIPE_FORMAT_R16_SNORM: + case PIPE_FORMAT_R16_FLOAT: return R300_COLOR_FORMAT_UV88; case PIPE_FORMAT_B5G6R5_UNORM: @@ -434,19 +459,33 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) /*case PIPE_FORMAT_X8B8G8R8_SNORM:*/ case PIPE_FORMAT_R8G8B8X8_UNORM: /*case PIPE_FORMAT_R8G8B8X8_SNORM:*/ - case PIPE_FORMAT_R8SG8SB8UX8U_NORM: + /* These formats work fine with ARGB8888 if US_OUT_FMT is set + * correctly. */ + case PIPE_FORMAT_R16G16_UNORM: + case PIPE_FORMAT_R16G16_SNORM: + case PIPE_FORMAT_R16G16_FLOAT: + case PIPE_FORMAT_L16A16_UNORM: + case PIPE_FORMAT_L16A16_SNORM: + case PIPE_FORMAT_L16A16_FLOAT: + case PIPE_FORMAT_A32_FLOAT: + case PIPE_FORMAT_L32_FLOAT: + case PIPE_FORMAT_I32_FLOAT: + case PIPE_FORMAT_R32_FLOAT: return R300_COLOR_FORMAT_ARGB8888; case PIPE_FORMAT_R10G10B10A2_UNORM: case PIPE_FORMAT_R10G10B10X2_SNORM: case PIPE_FORMAT_B10G10R10A2_UNORM: - case PIPE_FORMAT_R10SG10SB10SA2U_NORM: return R500_COLOR_FORMAT_ARGB2101010; /* R5xx-only? */ /* 64-bit buffers. */ case PIPE_FORMAT_R16G16B16A16_UNORM: case PIPE_FORMAT_R16G16B16A16_SNORM: case PIPE_FORMAT_R16G16B16A16_FLOAT: + /* These formats work fine with ARGB16161616 if US_OUT_FMT is set + * correctly. */ + case PIPE_FORMAT_R32G32_FLOAT: + case PIPE_FORMAT_L32A32_FLOAT: return R300_COLOR_FORMAT_ARGB16161616; /* 128-bit buffers. */ @@ -489,12 +528,7 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) uint32_t modifier = 0; unsigned i; const struct util_format_description *desc; - static const uint32_t sign_bit[4] = { - R300_OUT_SIGN(0x1), - R300_OUT_SIGN(0x2), - R300_OUT_SIGN(0x4), - R300_OUT_SIGN(0x8), - }; + boolean uniform_sign; desc = util_format_description(format); @@ -509,54 +543,109 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) return ~0; /* Unsupported/unknown. */ /* Specifies how the shader output is written to the fog unit. */ - if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT) { - if (desc->channel[i].size == 32) { - modifier |= R300_US_OUT_FMT_C4_32_FP; - } else { - modifier |= R300_US_OUT_FMT_C4_16_FP; + switch (desc->channel[i].type) { + case UTIL_FORMAT_TYPE_FLOAT: + switch (desc->channel[i].size) { + case 32: + switch (desc->nr_channels) { + case 1: + modifier |= R300_US_OUT_FMT_C_32_FP; + break; + case 2: + modifier |= R300_US_OUT_FMT_C2_32_FP; + break; + case 4: + modifier |= R300_US_OUT_FMT_C4_32_FP; + break; + } + break; + + case 16: + switch (desc->nr_channels) { + case 1: + modifier |= R300_US_OUT_FMT_C_16_FP; + break; + case 2: + modifier |= R300_US_OUT_FMT_C2_16_FP; + break; + case 4: + modifier |= R300_US_OUT_FMT_C4_16_FP; + break; + } + break; } - } else { - if (desc->channel[i].size == 16) { - modifier |= R300_US_OUT_FMT_C4_16; - } else if (desc->channel[i].size == 10) { + break; + + default: + switch (desc->channel[i].size) { + case 16: + switch (desc->nr_channels) { + case 1: + modifier |= R300_US_OUT_FMT_C_16; + break; + case 2: + modifier |= R300_US_OUT_FMT_C2_16; + break; + case 4: + modifier |= R300_US_OUT_FMT_C4_16; + break; + } + break; + + case 10: modifier |= R300_US_OUT_FMT_C4_10; - } else { + break; + + default: /* C4_8 seems to be used for the formats whose pixel size * is <= 32 bits. */ modifier |= R300_US_OUT_FMT_C4_8; + break; } } /* Add sign. */ - for (i = 0; i < 4; i++) - if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) { - modifier |= sign_bit[i]; - } + uniform_sign = TRUE; + for (i = 0; i < desc->nr_channels; i++) + if (desc->channel[i].type != UTIL_FORMAT_TYPE_SIGNED) + uniform_sign = FALSE; + + if (uniform_sign) + modifier |= R300_OUT_SIGN(0xf); /* Add swizzles and return. */ switch (format) { - /* 8-bit outputs, one channel. - * COLORFORMAT_I8 stores the C2 component. */ + /*** Special cases (non-standard channel mapping) ***/ + + /* X8 + * COLORFORMAT_I8 stores the Z component (C2). */ case PIPE_FORMAT_A8_UNORM: - /*case PIPE_FORMAT_A8_SNORM:*/ + case PIPE_FORMAT_A8_SNORM: return modifier | R300_C2_SEL_A; case PIPE_FORMAT_I8_UNORM: - /*case PIPE_FORMAT_I8_SNORM:*/ + case PIPE_FORMAT_I8_SNORM: case PIPE_FORMAT_L8_UNORM: - /*case PIPE_FORMAT_L8_SNORM:*/ + case PIPE_FORMAT_L8_SNORM: case PIPE_FORMAT_R8_UNORM: case PIPE_FORMAT_R8_SNORM: return modifier | R300_C2_SEL_R; - /* 16-bit outputs, two channels. - * COLORFORMAT_UV88 stores C2 and C0. */ + /* X8Y8 + * COLORFORMAT_UV88 stores ZX (C2 and C0). */ + case PIPE_FORMAT_L8A8_SNORM: case PIPE_FORMAT_L8A8_UNORM: - /*case PIPE_FORMAT_L8A8_SNORM:*/ return modifier | R300_C0_SEL_A | R300_C2_SEL_R; - case PIPE_FORMAT_R8G8_UNORM: case PIPE_FORMAT_R8G8_SNORM: + case PIPE_FORMAT_R8G8_UNORM: return modifier | R300_C0_SEL_G | R300_C2_SEL_R; + /* X32Y32 + * ARGB16161616 stores XZ for RG32F */ + case PIPE_FORMAT_R32G32_FLOAT: + return modifier | R300_C0_SEL_R | R300_C2_SEL_G; + + /*** Generic cases (standard channel mapping) ***/ + /* BGRA outputs. */ case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_B5G5R5A1_UNORM: @@ -577,6 +666,10 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) /*case PIPE_FORMAT_A8R8G8B8_SNORM:*/ case PIPE_FORMAT_X8R8G8B8_UNORM: /*case PIPE_FORMAT_X8R8G8B8_SNORM:*/ + case PIPE_FORMAT_A16_UNORM: + case PIPE_FORMAT_A16_SNORM: + case PIPE_FORMAT_A16_FLOAT: + case PIPE_FORMAT_A32_FLOAT: return modifier | R300_C0_SEL_A | R300_C1_SEL_R | R300_C2_SEL_G | R300_C3_SEL_B; @@ -595,18 +688,39 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) /*case PIPE_FORMAT_R8G8B8X8_SNORM:*/ case PIPE_FORMAT_R8G8B8A8_UNORM: case PIPE_FORMAT_R8G8B8A8_SNORM: - case PIPE_FORMAT_R8SG8SB8UX8U_NORM: case PIPE_FORMAT_R10G10B10A2_UNORM: case PIPE_FORMAT_R10G10B10X2_SNORM: - case PIPE_FORMAT_R10SG10SB10SA2U_NORM: + case PIPE_FORMAT_R16_UNORM: + case PIPE_FORMAT_R16G16_UNORM: case PIPE_FORMAT_R16G16B16A16_UNORM: + case PIPE_FORMAT_R16_SNORM: + case PIPE_FORMAT_R16G16_SNORM: case PIPE_FORMAT_R16G16B16A16_SNORM: + case PIPE_FORMAT_R16_FLOAT: + case PIPE_FORMAT_R16G16_FLOAT: case PIPE_FORMAT_R16G16B16A16_FLOAT: + case PIPE_FORMAT_R32_FLOAT: case PIPE_FORMAT_R32G32B32A32_FLOAT: + case PIPE_FORMAT_L16_UNORM: + case PIPE_FORMAT_L16_SNORM: + case PIPE_FORMAT_L16_FLOAT: + case PIPE_FORMAT_L32_FLOAT: + case PIPE_FORMAT_I16_UNORM: + case PIPE_FORMAT_I16_SNORM: + case PIPE_FORMAT_I16_FLOAT: + case PIPE_FORMAT_I32_FLOAT: return modifier | R300_C0_SEL_R | R300_C1_SEL_G | R300_C2_SEL_B | R300_C3_SEL_A; + /* LA outputs. */ + case PIPE_FORMAT_L16A16_UNORM: + case PIPE_FORMAT_L16A16_SNORM: + case PIPE_FORMAT_L16A16_FLOAT: + case PIPE_FORMAT_L32A32_FLOAT: + return modifier | + R300_C0_SEL_R | R300_C1_SEL_A; + default: return ~0; /* Unsupported. */ } @@ -636,6 +750,16 @@ void r300_texture_setup_format_state(struct r300_screen *screen, struct pipe_resource *pt = &tex->b.b.b; struct r300_texture_desc *desc = &tex->tex; boolean is_r500 = screen->caps.is_r500; + unsigned width, height, depth; + unsigned txwidth, txheight, txdepth; + + width = u_minify(desc->width0, level); + height = u_minify(desc->height0, level); + depth = u_minify(desc->depth0, level); + + txwidth = (width - 1) & 0x7ff; + txheight = (height - 1) & 0x7ff; + txdepth = util_logbase2(depth) & 0xf; /* Mask out all the fields we change. */ out->format0 = 0; @@ -645,9 +769,9 @@ void r300_texture_setup_format_state(struct r300_screen *screen, /* Set sampler state. */ out->format0 = - R300_TX_WIDTH((u_minify(desc->width0, level) - 1) & 0x7ff) | - R300_TX_HEIGHT((u_minify(desc->height0, level) - 1) & 0x7ff) | - R300_TX_DEPTH(util_logbase2(u_minify(desc->depth0, level)) & 0xf); + R300_TX_WIDTH(txwidth) | + R300_TX_HEIGHT(txheight) | + R300_TX_DEPTH(txdepth); if (desc->uses_stride_addressing) { /* rectangles love this */ @@ -665,12 +789,32 @@ void r300_texture_setup_format_state(struct r300_screen *screen, /* large textures on r500 */ if (is_r500) { - if (desc->width0 > 2048) { + unsigned us_width = txwidth; + unsigned us_height = txheight; + unsigned us_depth = txdepth; + + if (width > 2048) { out->format2 |= R500_TXWIDTH_BIT11; } - if (desc->height0 > 2048) { + if (height > 2048) { out->format2 |= R500_TXHEIGHT_BIT11; } + + /* The US_FORMAT register fixes an R500 TX addressing bug. + * Don't ask why it must be set like this. I don't know it either. */ + if (width > 2048) { + us_width = (0x000007FF + us_width) >> 1; + us_depth |= 0x0000000D; + } + if (height > 2048) { + us_height = (0x000007FF + us_height) >> 1; + us_depth |= 0x0000000E; + } + + out->us_format0 = + R300_TX_WIDTH(us_width) | + R300_TX_HEIGHT(us_height) | + R300_TX_DEPTH(us_depth); } out->tile_config = R300_TXO_MACRO_TILE(desc->macrotile[level]) | @@ -729,7 +873,7 @@ static void r300_texture_destroy(struct pipe_screen *screen, { struct r300_resource* tex = (struct r300_resource*)texture; - r300_winsys_bo_reference(&tex->buf, NULL); + pb_reference(&tex->buf, NULL); FREE(tex); } @@ -737,7 +881,7 @@ boolean r300_resource_get_handle(struct pipe_screen* screen, struct pipe_resource *texture, struct winsys_handle *whandle) { - struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys; + struct radeon_winsys *rws = (struct radeon_winsys *)screen->winsys; struct r300_resource* tex = (struct r300_resource*)texture; if (!tex) { @@ -764,17 +908,17 @@ static const struct u_resource_vtbl r300_texture_vtbl = static struct r300_resource* r300_texture_create_object(struct r300_screen *rscreen, const struct pipe_resource *base, - enum r300_buffer_tiling microtile, - enum r300_buffer_tiling macrotile, + enum radeon_bo_layout microtile, + enum radeon_bo_layout macrotile, unsigned stride_in_bytes_override, unsigned max_buffer_size, - struct r300_winsys_bo *buffer) + struct pb_buffer *buffer) { - struct r300_winsys_screen *rws = rscreen->rws; + struct radeon_winsys *rws = rscreen->rws; struct r300_resource *tex = CALLOC_STRUCT(r300_resource); if (!tex) { if (buffer) - r300_winsys_bo_reference(&buffer, NULL); + pb_reference(&buffer, NULL); return NULL; } @@ -788,13 +932,13 @@ r300_texture_create_object(struct r300_screen *rscreen, tex->tex.macrotile[0] = macrotile; tex->tex.stride_in_bytes_override = stride_in_bytes_override; tex->domain = base->flags & R300_RESOURCE_FLAG_TRANSFER ? - R300_DOMAIN_GTT : - R300_DOMAIN_VRAM | R300_DOMAIN_GTT; + RADEON_DOMAIN_GTT : + RADEON_DOMAIN_VRAM | RADEON_DOMAIN_GTT; tex->buf_size = max_buffer_size; if (!r300_resource_set_properties(&rscreen->screen, &tex->b.b.b, 0, base)) { if (buffer) - r300_winsys_bo_reference(&buffer, NULL); + pb_reference(&buffer, NULL); FREE(tex); return NULL; } @@ -827,15 +971,16 @@ struct pipe_resource *r300_texture_create(struct pipe_screen *screen, const struct pipe_resource *base) { struct r300_screen *rscreen = r300_screen(screen); - enum r300_buffer_tiling microtile, macrotile; + enum radeon_bo_layout microtile, macrotile; if ((base->flags & R300_RESOURCE_FLAG_TRANSFER) || (base->bind & PIPE_BIND_SCANOUT)) { - microtile = R300_BUFFER_LINEAR; - macrotile = R300_BUFFER_LINEAR; + microtile = RADEON_LAYOUT_LINEAR; + macrotile = RADEON_LAYOUT_LINEAR; } else { - microtile = R300_BUFFER_SELECT_LAYOUT; - macrotile = R300_BUFFER_SELECT_LAYOUT; + /* This will make the texture_create_function select the layout. */ + microtile = RADEON_LAYOUT_UNKNOWN; + macrotile = RADEON_LAYOUT_UNKNOWN; } return (struct pipe_resource*) @@ -847,10 +992,10 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen, const struct pipe_resource *base, struct winsys_handle *whandle) { - struct r300_winsys_screen *rws = (struct r300_winsys_screen*)screen->winsys; + struct radeon_winsys *rws = (struct radeon_winsys*)screen->winsys; struct r300_screen *rscreen = r300_screen(screen); - struct r300_winsys_bo *buffer; - enum r300_buffer_tiling microtile, macrotile; + struct pb_buffer *buffer; + enum radeon_bo_layout microtile, macrotile; unsigned stride, size; /* Support only 2D textures without mipmaps */ @@ -869,14 +1014,14 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen, /* Enforce a microtiled zbuffer. */ if (util_format_is_depth_or_stencil(base->format) && - microtile == R300_BUFFER_LINEAR) { + microtile == RADEON_LAYOUT_LINEAR) { switch (util_format_get_blocksize(base->format)) { case 4: - microtile = R300_BUFFER_TILED; + microtile = RADEON_LAYOUT_TILED; break; case 2: - microtile = R300_BUFFER_SQUARETILED; + microtile = RADEON_LAYOUT_SQUARETILED; break; } } @@ -917,8 +1062,8 @@ struct pipe_surface* r300_create_surface(struct pipe_context * ctx, /* Prefer VRAM if there are multiple domains to choose from. */ surface->domain = tex->domain; - if (surface->domain & R300_DOMAIN_VRAM) - surface->domain &= ~R300_DOMAIN_GTT; + if (surface->domain & RADEON_DOMAIN_VRAM) + surface->domain &= ~RADEON_DOMAIN_GTT; surface->offset = r300_texture_get_offset(tex, level, surf_tmpl->u.tex.first_layer); diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 158a387478f..4586bb2e4dc 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -35,6 +35,10 @@ struct r300_texture_desc; struct r300_resource; struct r300_screen; +void util_format_combine_swizzles(unsigned char *dst, + const unsigned char *swz1, + const unsigned char *swz2); + unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format, const unsigned char *swizzle_view, boolean dxtc_swizzle); diff --git a/src/gallium/drivers/r300/r300_texture_desc.c b/src/gallium/drivers/r300/r300_texture_desc.c index 2910666dd51..da5778be65e 100644 --- a/src/gallium/drivers/r300/r300_texture_desc.c +++ b/src/gallium/drivers/r300/r300_texture_desc.c @@ -22,9 +22,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "r300_texture_desc.h" - #include "r300_context.h" -#include "r300_winsys.h" #include "util/u_format.h" @@ -32,8 +30,8 @@ * in the given dimension. */ unsigned r300_get_pixel_alignment(enum pipe_format format, unsigned num_samples, - enum r300_buffer_tiling microtile, - enum r300_buffer_tiling macrotile, + enum radeon_bo_layout microtile, + enum radeon_bo_layout macrotile, enum r300_dim dim, boolean is_rs690) { static const unsigned table[2][5][3][2] = @@ -62,8 +60,8 @@ unsigned r300_get_pixel_alignment(enum pipe_format format, unsigned tile = 0; unsigned pixsize = util_format_get_blocksize(format); - assert(macrotile <= R300_BUFFER_TILED); - assert(microtile <= R300_BUFFER_SQUARETILED); + assert(macrotile <= RADEON_LAYOUT_TILED); + assert(microtile <= RADEON_LAYOUT_SQUARETILED); assert(pixsize <= 16); assert(dim <= DIM_HEIGHT); @@ -98,7 +96,7 @@ static boolean r300_texture_macro_switch(struct r300_resource *tex, unsigned tile, texdim; tile = r300_get_pixel_alignment(tex->b.b.b.format, tex->b.b.b.nr_samples, - tex->tex.microtile, R300_BUFFER_TILED, dim, 0); + tex->tex.microtile, RADEON_LAYOUT_TILED, dim, 0); if (dim == DIM_WIDTH) { texdim = u_minify(tex->tex.width0, level); } else { @@ -233,10 +231,10 @@ static void r300_setup_miptree(struct r300_screen *screen, for (i = 0; i <= base->last_level; i++) { /* Let's see if this miplevel can be macrotiled. */ tex->tex.macrotile[i] = - (tex->tex.macrotile[0] == R300_BUFFER_TILED && + (tex->tex.macrotile[0] == RADEON_LAYOUT_TILED && r300_texture_macro_switch(tex, i, rv350_mode, DIM_WIDTH) && r300_texture_macro_switch(tex, i, rv350_mode, DIM_HEIGHT)) ? - R300_BUFFER_TILED : R300_BUFFER_LINEAR; + RADEON_LAYOUT_TILED : RADEON_LAYOUT_LINEAR; stride = r300_texture_get_stride(screen, tex, i); @@ -424,8 +422,8 @@ static void r300_setup_tiling(struct r300_screen *screen, boolean is_zb = util_format_is_depth_or_stencil(format); boolean dbg_no_tiling = SCREEN_DBG_ON(screen, DBG_NO_TILING); - tex->tex.microtile = R300_BUFFER_LINEAR; - tex->tex.macrotile[0] = R300_BUFFER_LINEAR; + tex->tex.microtile = RADEON_LAYOUT_LINEAR; + tex->tex.macrotile[0] = RADEON_LAYOUT_LINEAR; if (!util_format_is_plain(format)) { return; @@ -441,11 +439,11 @@ static void r300_setup_tiling(struct r300_screen *screen, case 1: case 4: case 8: - tex->tex.microtile = R300_BUFFER_TILED; + tex->tex.microtile = RADEON_LAYOUT_TILED; break; case 2: - tex->tex.microtile = R300_BUFFER_SQUARETILED; + tex->tex.microtile = RADEON_LAYOUT_SQUARETILED; break; } @@ -456,7 +454,7 @@ static void r300_setup_tiling(struct r300_screen *screen, /* Set macrotiling. */ if (r300_texture_macro_switch(tex, 0, rv350_mode, DIM_WIDTH) && r300_texture_macro_switch(tex, 0, rv350_mode, DIM_HEIGHT)) { - tex->tex.macrotile[0] = R300_BUFFER_TILED; + tex->tex.macrotile[0] = RADEON_LAYOUT_TILED; } } @@ -501,7 +499,7 @@ boolean r300_texture_desc_init(struct r300_screen *rscreen, } /* Setup tiling. */ - if (tex->tex.microtile == R300_BUFFER_SELECT_LAYOUT) { + if (tex->tex.microtile == RADEON_LAYOUT_UNKNOWN) { r300_setup_tiling(rscreen, tex); } diff --git a/src/gallium/drivers/r300/r300_texture_desc.h b/src/gallium/drivers/r300/r300_texture_desc.h index ce6e9643ec6..a84d6fae0ea 100644 --- a/src/gallium/drivers/r300/r300_texture_desc.h +++ b/src/gallium/drivers/r300/r300_texture_desc.h @@ -25,7 +25,7 @@ #define R300_TEXTURE_DESC_H #include "pipe/p_format.h" -#include "r300_defines.h" +#include "r300_context.h" struct pipe_resource; struct r300_screen; @@ -39,8 +39,8 @@ enum r300_dim { unsigned r300_get_pixel_alignment(enum pipe_format format, unsigned num_samples, - enum r300_buffer_tiling microtile, - enum r300_buffer_tiling macrotile, + enum radeon_bo_layout microtile, + enum radeon_bo_layout macrotile, enum r300_dim dim, boolean is_rs690); boolean r300_texture_desc_init(struct r300_screen *rscreen, diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c index 97ec0a1a1f2..6a000cfe2c6 100644 --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c @@ -52,8 +52,7 @@ static unsigned translate_opcode(unsigned opcode) case TGSI_OPCODE_MAD: return RC_OPCODE_MAD; case TGSI_OPCODE_SUB: return RC_OPCODE_SUB; case TGSI_OPCODE_LRP: return RC_OPCODE_LRP; - /* case TGSI_OPCODE_CND: return RC_OPCODE_CND; */ - /* case TGSI_OPCODE_CND0: return RC_OPCODE_CND0; */ + case TGSI_OPCODE_CND: return RC_OPCODE_CND; /* case TGSI_OPCODE_DP2A: return RC_OPCODE_DP2A; */ /* gap */ case TGSI_OPCODE_FRC: return RC_OPCODE_FRC; diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index 65c5095be6a..e2ea4cbf6c5 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -226,7 +226,7 @@ void* r300_texture_transfer_map(struct pipe_context *ctx, struct pipe_transfer *transfer) { struct r300_context *r300 = r300_context(ctx); - struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys; + struct radeon_winsys *rws = (struct radeon_winsys *)ctx->winsys; struct r300_transfer *r300transfer = r300_transfer(transfer); struct r300_resource *tex = r300_resource(transfer->resource); char *map; @@ -256,7 +256,7 @@ void* r300_texture_transfer_map(struct pipe_context *ctx, void r300_texture_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *transfer) { - struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys; + struct radeon_winsys *rws = (struct radeon_winsys *)ctx->winsys; struct r300_transfer *r300transfer = r300_transfer(transfer); struct r300_resource *tex = r300_resource(transfer->resource); diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h deleted file mode 100644 index 3a6798a5423..00000000000 --- a/src/gallium/drivers/r300/r300_winsys.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson <[email protected]> - * Copyright 2010 Marek Olšák <[email protected]> - * - * 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 - * on 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 AUTHOR(S) AND/OR THEIR 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 R300_WINSYS_H -#define R300_WINSYS_H - -/* The public winsys interface header for the r300 pipe driver. - * Any winsys hosting this pipe needs to implement r300_winsys_screen and then - * call r300_screen_create to start things. */ - -#include "r300_defines.h" - -#include "pipebuffer/pb_bufmgr.h" -#include "pipe/p_defines.h" -#include "pipe/p_state.h" - -#define R300_MAX_CMDBUF_DWORDS (16 * 1024) -#define R300_FLUSH_ASYNC (1 << 0) - -struct winsys_handle; -struct r300_winsys_screen; - -#define r300_winsys_bo pb_buffer -#define r300_winsys_bo_reference(pdst, src) pb_reference(pdst, src) - -struct r300_winsys_cs_handle; /* for write_reloc etc. */ - -struct r300_winsys_cs { - unsigned cdw; /* Number of used dwords. */ - uint32_t *buf; /* The command buffer. */ -}; - -enum r300_value_id { - R300_VID_PCI_ID, - R300_VID_GB_PIPES, - R300_VID_Z_PIPES, - R300_VID_GART_SIZE, - R300_VID_VRAM_SIZE, - R300_VID_DRM_MAJOR, - R300_VID_DRM_MINOR, - R300_VID_DRM_PATCHLEVEL, - - /* These should probably go away: */ - R300_VID_DRM_2_6_0, /* Hyper-Z, GB_Z_PEQ_CONFIG on rv350->r4xx, R500 FG_ALPHA_VALUE */ - R300_VID_DRM_2_8_0, /* R500 US_FORMAT regs, R500 ARGB2101010 colorbuffer, CMask, R16F/RG16F */ - - R300_CAN_HYPERZ, /* ZMask + HiZ */ - R300_CAN_AACOMPRESS, /* CMask */ -}; - -struct r300_winsys_screen { - /** - * Destroy this winsys. - * - * \param ws The winsys this function is called from. - */ - void (*destroy)(struct r300_winsys_screen *ws); - - /** - * Query a system value from a winsys. - * - * \param ws The winsys this function is called from. - * \param vid One of the R300_VID_* enums. - */ - uint32_t (*get_value)(struct r300_winsys_screen *ws, - enum r300_value_id vid); - - /************************************************************************** - * Buffer management. Buffer attributes are mostly fixed over its lifetime. - * - * Remember that gallium gets to choose the interface it needs, and the - * window systems must then implement that interface (rather than the - * other way around...). - *************************************************************************/ - - /** - * Create a buffer object. - * - * \param ws The winsys this function is called from. - * \param size The size to allocate. - * \param alignment An alignment of the buffer in memory. - * \param bind A bitmask of the PIPE_BIND_* flags. - * \param usage A bitmask of the PIPE_USAGE_* flags. - * \param domain A bitmask of the R300_DOMAIN_* flags. - * \return The created buffer object. - */ - struct r300_winsys_bo *(*buffer_create)(struct r300_winsys_screen *ws, - unsigned size, - unsigned alignment, - unsigned bind, - unsigned usage, - enum r300_buffer_domain domain); - - struct r300_winsys_cs_handle *(*buffer_get_cs_handle)( - struct r300_winsys_bo *buf); - - /** - * Map the entire data store of a buffer object into the client's address - * space. - * - * \param buf A winsys buffer object to map. - * \param cs A command stream to flush if the buffer is referenced by it. - * \param usage A bitmask of the PIPE_TRANSFER_* flags. - * \return The pointer at the beginning of the buffer. - */ - void *(*buffer_map)(struct r300_winsys_bo *buf, - struct r300_winsys_cs *cs, - enum pipe_transfer_usage usage); - - /** - * Unmap a buffer object from the client's address space. - * - * \param buf A winsys buffer object to unmap. - */ - void (*buffer_unmap)(struct r300_winsys_bo *buf); - - /** - * Return TRUE if a buffer object is being used by the GPU. - * - * \param buf A winsys buffer object. - */ - boolean (*buffer_is_busy)(struct r300_winsys_bo *buf); - - /** - * Wait for a buffer object until it is not used by a GPU. This is - * equivalent to a fence placed after the last command using the buffer, - * and synchronizing to the fence. - * - * \param buf A winsys buffer object to wait for. - */ - void (*buffer_wait)(struct r300_winsys_bo *buf); - - /** - * Return tiling flags describing a memory layout of a buffer object. - * - * \param buf A winsys buffer object to get the flags from. - * \param macrotile A pointer to the return value of the microtile flag. - * \param microtile A pointer to the return value of the macrotile flag. - * - * \note microtile and macrotile are not bitmasks! - */ - void (*buffer_get_tiling)(struct r300_winsys_bo *buf, - enum r300_buffer_tiling *microtile, - enum r300_buffer_tiling *macrotile); - - /** - * Set tiling flags describing a memory layout of a buffer object. - * - * \param buf A winsys buffer object to set the flags for. - * \param cs A command stream to flush if the buffer is referenced by it. - * \param macrotile A macrotile flag. - * \param microtile A microtile flag. - * \param stride A stride of the buffer in bytes, for texturing. - * - * \note microtile and macrotile are not bitmasks! - */ - void (*buffer_set_tiling)(struct r300_winsys_bo *buf, - struct r300_winsys_cs *cs, - enum r300_buffer_tiling microtile, - enum r300_buffer_tiling macrotile, - unsigned stride); - - /** - * Get a winsys buffer from a winsys handle. The internal structure - * of the handle is platform-specific and only a winsys should access it. - * - * \param ws The winsys this function is called from. - * \param whandle A winsys handle pointer as was received from a state - * tracker. - * \param stride The returned buffer stride in bytes. - * \param size The returned buffer size. - */ - struct r300_winsys_bo *(*buffer_from_handle)(struct r300_winsys_screen *ws, - struct winsys_handle *whandle, - unsigned *stride, - unsigned *size); - - /** - * Get a winsys handle from a winsys buffer. The internal structure - * of the handle is platform-specific and only a winsys should access it. - * - * \param buf A winsys buffer object to get the handle from. - * \param whandle A winsys handle pointer. - * \param stride A stride of the buffer in bytes, for texturing. - * \return TRUE on success. - */ - boolean (*buffer_get_handle)(struct r300_winsys_bo *buf, - unsigned stride, - struct winsys_handle *whandle); - - /************************************************************************** - * Command submission. - * - * Each pipe context should create its own command stream and submit - * commands independently of other contexts. - *************************************************************************/ - - /** - * Create a command stream. - * - * \param ws The winsys this function is called from. - */ - struct r300_winsys_cs *(*cs_create)(struct r300_winsys_screen *ws); - - /** - * Destroy a command stream. - * - * \param cs A command stream to destroy. - */ - void (*cs_destroy)(struct r300_winsys_cs *cs); - - /** - * Add a new buffer relocation. Every relocation must first be added - * before it can be written. - * - * \param cs A command stream to add buffer for validation against. - * \param buf A winsys buffer to validate. - * \param rd A read domain containing a bitmask of the R300_DOMAIN_* flags. - * \param wd A write domain containing a bitmask of the R300_DOMAIN_* flags. - */ - void (*cs_add_reloc)(struct r300_winsys_cs *cs, - struct r300_winsys_cs_handle *buf, - enum r300_buffer_domain rd, - enum r300_buffer_domain wd); - - /** - * Return TRUE if there is enough memory in VRAM and GTT for the relocs - * added so far. - * - * \param cs A command stream to validate. - */ - boolean (*cs_validate)(struct r300_winsys_cs *cs); - - /** - * Write a relocated dword to a command buffer. - * - * \param cs A command stream the relocation is written to. - * \param buf A winsys buffer to write the relocation for. - * \param rd A read domain containing a bitmask of the R300_DOMAIN_* flags. - * \param wd A write domain containing a bitmask of the R300_DOMAIN_* flags. - */ - void (*cs_write_reloc)(struct r300_winsys_cs *cs, - struct r300_winsys_cs_handle *buf); - - /** - * Flush a command stream. - * - * \param cs A command stream to flush. - * \param flags, R300_FLUSH_ASYNC or 0. - */ - void (*cs_flush)(struct r300_winsys_cs *cs, unsigned flags); - - /** - * Set a flush callback which is called from winsys when flush is - * required. - * - * \param cs A command stream to set the callback for. - * \param flush A flush callback function associated with the command stream. - * \param user A user pointer that will be passed to the flush callback. - */ - void (*cs_set_flush)(struct r300_winsys_cs *cs, - void (*flush)(void *ctx, unsigned flags), - void *user); - - /** - * Return TRUE if a buffer is referenced by a command stream. - * - * \param cs A command stream. - * \param buf A winsys buffer. - */ - boolean (*cs_is_buffer_referenced)(struct r300_winsys_cs *cs, - struct r300_winsys_cs_handle *buf); -}; - -#endif /* R300_WINSYS_H */ |