struct r300_blend_color_state *state =
(struct r300_blend_color_state*)r300->blend_color_state.state;
struct pipe_blend_color c;
- enum pipe_format format = fb->nr_cbufs ? fb->cbufs[0]->format : 0;
+ struct pipe_surface *cb;
float tmp;
CB_LOCALS;
state->state = *color; /* Save it, so that we can reuse it in set_fb_state */
c = *color;
+ cb = fb->nr_cbufs ? r300_get_nonnull_cb(fb, 0) : NULL;
/* The blend color is dependent on the colorbuffer format. */
- if (fb->nr_cbufs) {
- switch (format) {
+ if (cb) {
+ switch (cb->format) {
case PIPE_FORMAT_R8_UNORM:
case PIPE_FORMAT_L8_UNORM:
case PIPE_FORMAT_I8_UNORM:
BEGIN_CB(state->cb, 3);
OUT_CB_REG_SEQ(R500_RB3D_CONSTANT_COLOR_AR, 2);
- switch (format) {
+ switch (cb ? cb->format : 0) {
case PIPE_FORMAT_R16G16B16A16_FLOAT:
case PIPE_FORMAT_R16G16B16X16_FLOAT:
OUT_CB(util_float_to_half(c.color[2]) |
util_pack_color(c.color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
BEGIN_CB(state->cb, 2);
- OUT_CB_REG(R300_RB3D_BLEND_COLOR, uc.ui);
+ OUT_CB_REG(R300_RB3D_BLEND_COLOR, uc.ui[0]);
END_CB;
}
tex->tex.macrotile[level]) {
r300->rws->buffer_set_tiling(tex->buf, r300->cs,
tex->tex.microtile, tex->tex.macrotile[level],
- 0, 0, 0, 0, 0,
- tex->tex.stride_in_bytes[0]);
+ 0, 0, 0, 0, 0, 0, 0,
+ tex->tex.stride_in_bytes[0], false);
tex->surface_level = level;
}
/* Set tiling flags for new surfaces. */
for (i = 0; i < state->nr_cbufs; i++) {
+ if (!state->cbufs[i])
+ continue;
+
r300_tex_set_tiling_flags(r300,
r300_resource(state->cbufs[i]->texture),
state->cbufs[i]->u.tex.level);
/* The size of the rest of atoms stays the same. */
}
-static unsigned r300_get_num_samples(struct r300_context *r300)
-{
- struct pipe_framebuffer_state* fb =
- (struct pipe_framebuffer_state*)r300->fb_state.state;
- unsigned i, num_samples;
-
- if (!fb->nr_cbufs && !fb->zsbuf)
- return 1;
-
- num_samples = 6;
-
- for (i = 0; i < fb->nr_cbufs; i++)
- num_samples = MIN2(num_samples, fb->cbufs[i]->texture->nr_samples);
-
- if (fb->zsbuf)
- num_samples = MIN2(num_samples, fb->zsbuf->texture->nr_samples);
-
- if (!num_samples)
- num_samples = 1;
-
- return num_samples;
-}
-
static void
r300_set_framebuffer_state(struct pipe_context* pipe,
const struct pipe_framebuffer_state* state)
{
struct r300_context* r300 = r300_context(pipe);
struct r300_aa_state *aa = (struct r300_aa_state*)r300->aa_state.state;
- struct pipe_framebuffer_state *old_state = r300->fb_state.state;
+ struct pipe_framebuffer_state *current_state = r300->fb_state.state;
unsigned max_width, max_height, i;
uint32_t zbuffer_bpp = 0;
boolean unlock_zbuffer = FALSE;
return;
}
- if (old_state->zsbuf && r300->zmask_in_use && !r300->locked_zbuffer) {
+ if (current_state->zsbuf && r300->zmask_in_use && !r300->locked_zbuffer) {
/* There is a zmask in use, what are we gonna do? */
if (state->zsbuf) {
- if (!pipe_surface_equal(old_state->zsbuf, state->zsbuf)) {
+ if (!pipe_surface_equal(current_state->zsbuf, state->zsbuf)) {
/* Decompress the currently bound zbuffer before we bind another one. */
r300_decompress_zmask(r300);
r300->hiz_in_use = FALSE;
}
} else {
/* We don't bind another zbuffer, so lock the current one. */
- pipe_surface_reference(&r300->locked_zbuffer, old_state->zsbuf);
+ pipe_surface_reference(&r300->locked_zbuffer, current_state->zsbuf);
}
} else if (r300->locked_zbuffer) {
/* We have a locked zbuffer now, what are we gonna do? */
}
assert(state->zsbuf || (r300->locked_zbuffer && !unlock_zbuffer) || !r300->zmask_in_use);
+ /* If zsbuf is set from NULL to non-NULL or vice versa.. */
+ if (!!current_state->zsbuf != !!state->zsbuf) {
+ r300_mark_atom_dirty(r300, &r300->dsa_state);
+ }
+
+ util_copy_framebuffer_state(r300->fb_state.state, state);
+
+ /* Remove trailing NULL colorbuffers. */
+ while (current_state->nr_cbufs && !current_state->cbufs[current_state->nr_cbufs-1])
+ current_state->nr_cbufs--;
+
/* Set whether CMASK can be used. */
r300->cmask_in_use =
- state->nr_cbufs == 1 &&
+ state->nr_cbufs == 1 && state->cbufs[0] &&
r300->screen->cmask_resource == state->cbufs[0]->texture;
/* Need to reset clamping or colormask. */
/* Re-swizzle the blend color. */
r300_set_blend_color(pipe, &((struct r300_blend_color_state*)r300->blend_color_state.state)->state);
- /* If zsbuf is set from NULL to non-NULL or vice versa.. */
- if (!!old_state->zsbuf != !!state->zsbuf) {
- r300_mark_atom_dirty(r300, &r300->dsa_state);
- }
-
if (r300->screen->info.drm_minor < 12) {
/* The tiling flags are dependent on the surface miplevel, unfortunately.
* This workarounds a bad design decision in old kernels which were
r300_fb_set_tiling_flags(r300, state);
}
- util_copy_framebuffer_state(r300->fb_state.state, state);
-
if (unlock_zbuffer) {
pipe_surface_reference(&r300->locked_zbuffer, NULL);
}
}
}
- r300->num_samples = r300_get_num_samples(r300);
+ r300->num_samples = util_framebuffer_get_num_samples(state);
/* Set up AA config. */
if (r300->num_samples > 1) {
if (DBG_ON(r300, DBG_FB)) {
fprintf(stderr, "r300: set_framebuffer_state:\n");
for (i = 0; i < state->nr_cbufs; i++) {
- r300_print_fb_surf_info(state->cbufs[i], i, "CB");
+ if (state->cbufs[i])
+ r300_print_fb_surf_info(state->cbufs[i], i, "CB");
}
if (state->zsbuf) {
r300_print_fb_surf_info(state->zsbuf, 0, "ZB");
struct r300_context* r300 = r300_context(pipe);
struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
- if (fs == NULL) {
+ if (!fs) {
r300->fs.state = NULL;
return;
}
static void r300_set_polygon_stipple(struct pipe_context* pipe,
const struct pipe_poly_stipple* state)
{
- /* XXX no idea how to set this up, but not terribly important */
}
/* Create a new rasterizer state based on the CSO rasterizer state.
boolean last_two_sided_color = r300->two_sided_color;
boolean last_msaa_enable = r300->msaa_enable;
boolean last_flatshade = r300->flatshade;
+ boolean last_clip_halfz = r300->clip_halfz;
if (r300->draw && rs) {
draw_set_rasterizer_state(r300->draw, &rs->rs_draw, state);
r300->two_sided_color = rs->rs.light_twoside;
r300->msaa_enable = rs->rs.multisample;
r300->flatshade = rs->rs.flatshade;
+ r300->clip_halfz = rs->rs.clip_halfz;
} else {
r300->polygon_offset_enabled = FALSE;
r300->sprite_coord_enable = 0;
r300->two_sided_color = FALSE;
r300->msaa_enable = FALSE;
r300->flatshade = FALSE;
+ r300->clip_halfz = FALSE;
}
UPDATE_STATE(state, r300->rs_state);
r300->fs_status = FRAGMENT_SHADER_MAYBE_DIRTY;
}
}
+
+ if (r300->screen->caps.has_tcl && last_clip_halfz != r300->clip_halfz) {
+ r300_mark_atom_dirty(r300, &r300->vs_state);
+ }
}
/* Free rasterizer state. */
struct r300_context *r300 = r300_context(pipe);
struct r300_vertex_element_state *velems = state;
- if (velems == NULL) {
+ if (!velems) {
return;
}
struct r300_context* r300 = r300_context(pipe);
struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
- if (vs == NULL) {
+ if (!vs) {
r300->vs_state.state = NULL;
return;
}
r300_mark_atom_dirty(r300, &r300->texture_cache_inval);
}
+static void r300_memory_barrier(struct pipe_context *pipe, unsigned flags)
+{
+}
+
void r300_init_state_functions(struct r300_context* r300)
{
r300->context.create_blend_state = r300_create_blend_state;
r300->context.delete_vs_state = r300_delete_vs_state;
r300->context.texture_barrier = r300_texture_barrier;
+ r300->context.memory_barrier = r300_memory_barrier;
}