xgl: Add framebuffer-no-attachment support
Add default values if no attachments are present, correctly handle
override values when attachments are present. Bug# 13212, header
revision #36.
diff --git a/icd/intel/cmd_pipeline.c b/icd/intel/cmd_pipeline.c
index 5b69174..23fcae9 100644
--- a/icd/intel/cmd_pipeline.c
+++ b/icd/intel/cmd_pipeline.c
@@ -535,6 +535,11 @@
0x7ff << GEN6_CLIP_DW3_MAX_POINT_WIDTH__SHIFT |
(viewport->viewport_count - 1);
+ /* TODO: framebuffer requests layer_count > 1 */
+ if (cmd->bind.render_pass->fb->layer_count == 1) {
+ dw3 |= GEN6_CLIP_DW3_RTAINDEX_FORCED_ZERO;
+ }
+
cmd_batch_pointer(cmd, cmd_len, &dw);
dw[0] = dw0;
dw[1] = dw1;
diff --git a/icd/intel/fb.c b/icd/intel/fb.c
index 6ccc3ee..2b4925b 100644
--- a/icd/intel/fb.c
+++ b/icd/intel/fb.c
@@ -47,7 +47,9 @@
if (!fb)
return XGL_ERROR_OUT_OF_MEMORY;
- XGL_UINT width = 0, height = 0;
+ XGL_UINT width = info->width;
+ XGL_UINT height = info->height;
+ XGL_UINT layers = info->layers;
XGL_UINT i;
for (i = 0; i < info->colorAttachmentCount; i++) {
@@ -55,38 +57,55 @@
const struct intel_rt_view *rt = intel_rt_view(att->view);
const struct intel_layout *layout = &rt->img->layout;
- if (i == 0) {
+ if (width > layout->width0)
width = layout->width0;
+ if (height > layout->height0)
height = layout->height0;
- } else {
- if (width > layout->width0)
- width = layout->width0;
- if (height > layout->height0)
- height = layout->height0;
- }
+ if (layers > rt->array_size)
+ layers = rt->array_size;
+ if (rt->img->samples != info->sampleCount) {
+ intel_fb_destroy(fb);
+ return XGL_ERROR_INVALID_VALUE;
+ }
fb->rt[i] = rt;
}
+
fb->rt_count = info->colorAttachmentCount;
if (info->pDepthStencilAttachment) {
const struct intel_layout *layout;
fb->ds = intel_ds_view(info->pDepthStencilAttachment->view);
+
layout = &fb->ds->img->layout;
if (width > layout->width0)
width = layout->width0;
if (height > layout->height0)
height = layout->height0;
+ if (layers > fb->ds->array_size)
+ layers = fb->ds->array_size;
+
+ if (fb->ds->img->samples != info->sampleCount) {
+ intel_fb_destroy(fb);
+ return XGL_ERROR_INVALID_VALUE;
+ }
+
} else {
fb->ds = NULL;
}
+ /* Behavior is undefined if width,height are larger
+ than an attachment in some direction, but Intel hardware
+ cannot handle this case */
+ fb->width = width;
+ fb->height = height;
+ fb->layer_count = layers;
+ /* This information must match pipeline state */
fb->sample_count = info->sampleCount;
- fb->width = width;
- fb->height = height;
- fb->obj.destroy = fb_destroy;
+
+ fb->obj.destroy = fb_destroy;
*fb_ret = fb;
diff --git a/icd/intel/fb.h b/icd/intel/fb.h
index 81a1a33..68ad027 100644
--- a/icd/intel/fb.h
+++ b/icd/intel/fb.h
@@ -33,7 +33,9 @@
const struct intel_ds_view *ds;
XGL_UINT sample_count;
- XGL_UINT width, height;
+ XGL_UINT width;
+ XGL_UINT height;
+ XGL_UINT layer_count;
};
struct intel_render_pass {
diff --git a/icd/intel/view.c b/icd/intel/view.c
index 5f0deea..6991450 100644
--- a/icd/intel/view.c
+++ b/icd/intel/view.c
@@ -1249,6 +1249,8 @@
view->img = img;
+ view->array_size = info->arraySize;
+
if (intel_gpu_gen(dev->gpu) >= INTEL_GEN(7)) {
surface_state_tex_gen7(dev->gpu, img,
img_type_to_view_type(img->type),
@@ -1298,6 +1300,8 @@
view->img = img;
+ view->array_size = info->arraySize;
+
ds_view_init(view, dev->gpu, img, img->layout.format, info->mipLevel,
info->baseArraySlice, info->arraySize);
diff --git a/icd/intel/view.h b/icd/intel/view.h
index 8956123..e36cb43 100644
--- a/icd/intel/view.h
+++ b/icd/intel/view.h
@@ -71,6 +71,8 @@
struct intel_img *img;
+ XGL_UINT array_size;
+
/* SURFACE_STATE */
uint32_t cmd[8];
XGL_UINT cmd_len;
@@ -81,6 +83,8 @@
struct intel_img *img;
+ XGL_UINT array_size;
+
/*
* 3DSTATE_DEPTH_BUFFER
* 3DSTATE_STENCIL_BUFFER