const struct ilo_surface_cso *surface =
(const struct ilo_surface_cso *) fb->state.cbufs[i];
- if (fb->offset_to_layers) {
+ if (!surface) {
+ surface_state[i] =
+ gen6_emit_SURFACE_STATE(p->dev, &fb->null_rt, true, p->cp);
+ }
+ else if (fb->offset_to_layers) {
struct ilo_view_surface layer;
assert(surface->base.u.tex.first_layer ==
* brw_update_renderbuffer_surfaces() does. I don't know why.
*/
if (i == 0) {
- struct ilo_view_surface null_surface;
-
- ilo_gpe_init_view_surface_null(p->dev,
- fb->state.width, fb->state.height,
- 1, 0, &null_surface);
-
surface_state[i] =
- gen6_emit_SURFACE_STATE(p->dev, &null_surface, true, p->cp);
+ gen6_emit_SURFACE_STATE(p->dev, &fb->null_rt, true, p->cp);
i++;
}
}
}
- for (i = 0; i < fb->nr_cbufs; i++)
- ilo_blit_resolve_surface(ilo, fb->cbufs[i], ILO_TEXTURE_RENDER_WRITE);
+ for (i = 0; i < fb->nr_cbufs; i++) {
+ struct pipe_surface *surf = fb->cbufs[i];
+ if (surf)
+ ilo_blit_resolve_surface(ilo, surf, ILO_TEXTURE_RENDER_WRITE);
+ }
if (fb->zsbuf)
ilo_blit_resolve_surface(ilo, fb->zsbuf, ILO_TEXTURE_RENDER_WRITE);
struct ilo_fb_state {
struct pipe_framebuffer_state state;
+ struct ilo_view_surface null_rt;
struct ilo_zs_surface null_zs;
unsigned num_samples;
}
void
-ilo_gpe_init_fb(const struct ilo_dev_info *dev,
- const struct pipe_framebuffer_state *state,
- struct ilo_fb_state *fb);
+ilo_gpe_set_fb(const struct ilo_dev_info *dev,
+ const struct pipe_framebuffer_state *state,
+ struct ilo_fb_state *fb);
#endif /* ILO_GPE_H */
}
void
-ilo_gpe_init_fb(const struct ilo_dev_info *dev,
- const struct pipe_framebuffer_state *state,
- struct ilo_fb_state *fb)
+ilo_gpe_set_fb(const struct ilo_dev_info *dev,
+ const struct pipe_framebuffer_state *state,
+ struct ilo_fb_state *fb)
{
const struct pipe_surface *first;
- unsigned num_surfaces;
+ unsigned num_surfaces, first_idx;
ILO_GPE_VALID_GEN(dev, 6, 7.5);
util_copy_framebuffer_state(&fb->state, state);
- first = (state->nr_cbufs) ? state->cbufs[0] :
- (state->zsbuf) ? state->zsbuf :
- NULL;
- num_surfaces = state->nr_cbufs + !!state->zsbuf;
+ ilo_gpe_init_view_surface_null(dev,
+ state->width, state->height,
+ 1, 0, &fb->null_rt);
+
+ first = NULL;
+ for (first_idx = 0; first_idx < state->nr_cbufs; first_idx++) {
+ if (state->cbufs[first_idx]) {
+ first = state->cbufs[first_idx];
+ break;
+ }
+ }
+ if (!first)
+ first = state->zsbuf;
fb->num_samples = (first) ? first->texture->nr_samples : 1;
if (!fb->num_samples)
* The PRMs list several restrictions when the framebuffer has more than
* one surface, but it seems they are lifted on GEN7+.
*/
+ num_surfaces = state->nr_cbufs + !!state->zsbuf;
+
if (dev->gen < ILO_GEN(7) && num_surfaces > 1) {
const unsigned first_depth =
(first->texture->target == PIPE_TEXTURE_3D) ?
bool has_3d_target = (first->texture->target == PIPE_TEXTURE_3D);
unsigned i;
- for (i = 1; i < num_surfaces; i++) {
+ for (i = first_idx + 1; i < num_surfaces; i++) {
const struct pipe_surface *surf =
(i < state->nr_cbufs) ? state->cbufs[i] : state->zsbuf;
- const unsigned depth =
- (surf->texture->target == PIPE_TEXTURE_3D) ?
+ unsigned depth;
+
+ if (!surf)
+ continue;
+
+ depth = (surf->texture->target == PIPE_TEXTURE_3D) ?
surf->texture->depth0 :
surf->u.tex.last_layer - surf->u.tex.first_layer + 1;
const struct ilo_blend_cso *cso = &blend->cso[idx];
const int num_samples = fb->num_samples;
const struct util_format_description *format_desc =
- (idx < fb->state.nr_cbufs) ?
+ (idx < fb->state.nr_cbufs && fb->state.cbufs[idx]) ?
util_format_description(fb->state.cbufs[idx]->format) : NULL;
bool rt_is_unorm, rt_is_pure_integer, rt_dst_alpha_forced_one;
{
struct ilo_context *ilo = ilo_context(pipe);
- ilo_gpe_init_fb(ilo->dev, state, &ilo->fb);
+ ilo_gpe_set_fb(ilo->dev, state, &ilo->fb);
ilo->dirty |= ILO_DIRTY_FB;
}
/* for now? */
if (res->target != PIPE_BUFFER) {
for (i = 0; i < ilo->fb.state.nr_cbufs; i++) {
- if (ilo->fb.state.cbufs[i]->texture == res) {
+ const struct pipe_surface *surf = ilo->fb.state.cbufs[i];
+ if (surf && surf->texture == res) {
states |= ILO_DIRTY_FB;
break;
}