driver:implement changes for Dynamic State
diff --git a/demos/cube.c b/demos/cube.c
index d42cddc..f5b27cb 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -236,11 +236,10 @@
XGL_PIPELINE pipeline;
- XGL_VIEWPORT_STATE_OBJECT viewport;
- XGL_RASTER_STATE_OBJECT raster;
- XGL_MSAA_STATE_OBJECT msaa;
- XGL_COLOR_BLEND_STATE_OBJECT color_blend;
- XGL_DEPTH_STENCIL_STATE_OBJECT depth_stencil;
+ XGL_DYNAMIC_VP_STATE_OBJECT viewport;
+ XGL_DYNAMIC_RS_STATE_OBJECT raster;
+ XGL_DYNAMIC_CB_STATE_OBJECT color_blend;
+ XGL_DYNAMIC_DS_STATE_OBJECT depth_stencil;
mat4x4 projection_matrix;
mat4x4 view_matrix;
@@ -320,12 +319,11 @@
xglCmdBindDescriptorSet(demo->cmd, XGL_PIPELINE_BIND_POINT_GRAPHICS,
0, demo->dset, 0);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_VIEWPORT, demo->viewport);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_RASTER, demo->raster);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_MSAA, demo->msaa);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_COLOR_BLEND,
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_VIEWPORT, demo->viewport);
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_RASTER, demo->raster);
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_COLOR_BLEND,
demo->color_blend);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_DEPTH_STENCIL,
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_DEPTH_STENCIL,
demo->depth_stencil);
clear_range.aspect = XGL_IMAGE_ASPECT_COLOR;
@@ -495,8 +493,10 @@
mem_alloc.allocationSize = mem_reqs.size;
mem_alloc.alignment = mem_reqs.alignment;
mem_alloc.heapCount = mem_reqs.heapCount;
- memcpy(mem_alloc.heaps, mem_reqs.heaps,
- sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount);
+ XGL_UINT heapInfo[1];
+ mem_alloc.pHeaps = (const XGL_UINT *)&heapInfo;
+ memcpy(&heapInfo, mem_reqs.pHeaps,
+ sizeof(mem_reqs.pHeaps[0]) * mem_reqs.heapCount);
/* allocate memory */
err = xglAllocMemory(demo->device, &mem_alloc,
@@ -711,6 +711,7 @@
.alignment = 0,
.flags = 0,
.heapCount = 0,
+ .pHeaps = 0,
.memPriority = XGL_MEMORY_PRIORITY_NORMAL,
};
XGL_IMAGE_VIEW_CREATE_INFO view = {
@@ -747,8 +748,10 @@
mem_alloc.allocationSize = mem_reqs.size;
mem_alloc.alignment = mem_reqs.alignment;
mem_alloc.heapCount = mem_reqs.heapCount;
- memcpy(mem_alloc.heaps, mem_reqs.heaps,
- sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount);
+ XGL_UINT heapInfo[1];
+ mem_alloc.pHeaps = (const XGL_UINT *)&heapInfo;
+ memcpy(&heapInfo, mem_reqs.pHeaps,
+ sizeof(mem_reqs.pHeaps[0]) * mem_reqs.heapCount);
/* allocate memory */
err = xglAllocMemory(demo->device, &mem_alloc,
@@ -837,8 +840,10 @@
alloc_info.allocationSize = mem_reqs.size;
alloc_info.alignment = mem_reqs.alignment;
alloc_info.heapCount = mem_reqs.heapCount;
- memcpy(alloc_info.heaps, mem_reqs.heaps,
- sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount);
+ XGL_UINT heapInfo[1];
+ alloc_info.pHeaps = (const XGL_UINT *)&heapInfo;
+ memcpy(&heapInfo, mem_reqs.pHeaps,
+ sizeof(mem_reqs.pHeaps[0]) * mem_reqs.heapCount);
alloc_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
err = xglAllocMemory(demo->device, &alloc_info, &demo->uniform_data.mem);
@@ -1046,10 +1051,12 @@
XGL_GRAPHICS_PIPELINE_CREATE_INFO pipeline;
XGL_PIPELINE_IA_STATE_CREATE_INFO ia;
XGL_PIPELINE_RS_STATE_CREATE_INFO rs;
- XGL_PIPELINE_CB_STATE cb;
- XGL_PIPELINE_DB_STATE_CREATE_INFO db;
+ XGL_PIPELINE_CB_STATE_CREATE_INFO cb;
+ XGL_PIPELINE_DS_STATE_CREATE_INFO ds;
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO vs;
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO fs;
+ XGL_PIPELINE_VP_STATE_CREATE_INFO vp;
+ XGL_PIPELINE_MS_STATE_CREATE_INFO ms;
XGL_DESCRIPTOR_SLOT_INFO vs_slots[3];
XGL_DESCRIPTOR_SLOT_INFO fs_slots[3];
XGL_RESULT err;
@@ -1063,15 +1070,36 @@
memset(&rs, 0, sizeof(rs));
rs.sType = XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO;
+ rs.fillMode = XGL_FILL_SOLID;
+ rs.cullMode = XGL_CULL_NONE;
+ rs.frontFace = XGL_FRONT_FACE_CCW;
memset(&cb, 0, sizeof(cb));
cb.sType = XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO;
- cb.attachment[0].format = demo->format;
- cb.attachment[0].channelWriteMask = 0xf;
+ XGL_PIPELINE_CB_ATTACHMENT_STATE att_state[1];
+ memset(att_state, 0, sizeof(att_state));
+ att_state[0].format = demo->format;
+ att_state[0].channelWriteMask = 0xf;
+ att_state[0].blendEnable = XGL_FALSE;
+ cb.attachmentCount = 1;
+ cb.pAttachments = att_state;
- memset(&db, 0, sizeof(db));
- db.sType = XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO;
- db.format = demo->depth.format;
+ memset(&vp, 0, sizeof(vp));
+ vp.sType = XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO;
+ vp.scissorEnable = XGL_FALSE;
+
+ memset(&ds, 0, sizeof(ds));
+ ds.sType = XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO;
+ ds.format = demo->depth.format;
+ ds.depthTestEnable = XGL_TRUE;
+ ds.depthWriteEnable = XGL_TRUE;
+ ds.depthFunc = XGL_COMPARE_LESS_EQUAL;
+ ds.depthBoundsEnable = XGL_FALSE;
+ ds.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
+ ds.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
+ ds.back.stencilFunc = XGL_COMPARE_ALWAYS;
+ ds.stencilTestEnable = XGL_FALSE;
+ ds.front = ds.back;
memset(&vs_slots, 0, sizeof(vs_slots));
vs_slots[0].slotObjectType = XGL_SLOT_SHADER_RESOURCE;
@@ -1088,22 +1116,38 @@
vs.shader.stage = XGL_SHADER_STAGE_VERTEX;
vs.shader.shader = demo_prepare_vs(demo);
assert(vs.shader.shader != NULL);
- vs.shader.descriptorSetMapping[0].descriptorCount = 3;
- vs.shader.descriptorSetMapping[0].pDescriptorInfo = vs_slots;
+ XGL_DESCRIPTOR_SET_MAPPING ds_mapping1;
+ ds_mapping1.descriptorCount = 3;
+ ds_mapping1.pDescriptorInfo = vs_slots;
+ vs.shader.pDescriptorSetMapping = &ds_mapping1;
+ vs.shader.linkConstBufferCount = 0;
+ vs.shader.descriptorSetMappingCount = 1;
memset(&fs, 0, sizeof(fs));
fs.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fs.shader.stage = XGL_SHADER_STAGE_FRAGMENT;
fs.shader.shader = demo_prepare_fs(demo);
assert(fs.shader.shader != NULL);
- fs.shader.descriptorSetMapping[0].descriptorCount = 3;
- fs.shader.descriptorSetMapping[0].pDescriptorInfo = fs_slots;
+ XGL_DESCRIPTOR_SET_MAPPING ds_mapping2;
+ ds_mapping2.descriptorCount = 3;
+ ds_mapping2.pDescriptorInfo = fs_slots;
+ fs.shader.pDescriptorSetMapping = &ds_mapping2;
+ fs.shader.linkConstBufferCount = 0;
+ fs.shader.descriptorSetMappingCount = 1;
+
+ memset(&ms, 0, sizeof(ms));
+ ms.sType = XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO;
+ ms.sampleMask = 1;
+ ms.multisampleEnable = XGL_FALSE;
+ ms.samples = 1;
pipeline.pNext = (const XGL_VOID *) &ia;
ia.pNext = (const XGL_VOID *) &rs;
rs.pNext = (const XGL_VOID *) &cb;
- cb.pNext = (const XGL_VOID *) &db;
- db.pNext = (const XGL_VOID *) &vs;
+ cb.pNext = (const XGL_VOID *) &ms;
+ ms.pNext = (const XGL_VOID *) &vp;
+ vp.pNext = (const XGL_VOID *) &ds;
+ ds.pNext = (const XGL_VOID *) &vs;
vs.pNext = (const XGL_VOID *) &fs;
err = xglCreateGraphicsPipeline(demo->device, &pipeline, &demo->pipeline);
@@ -1115,56 +1159,46 @@
static void demo_prepare_dynamic_states(struct demo *demo)
{
- XGL_VIEWPORT_STATE_CREATE_INFO viewport;
- XGL_RASTER_STATE_CREATE_INFO raster;
- XGL_MSAA_STATE_CREATE_INFO msaa;
- XGL_COLOR_BLEND_STATE_CREATE_INFO color_blend;
- XGL_DEPTH_STENCIL_STATE_CREATE_INFO depth_stencil;
+ XGL_DYNAMIC_VP_STATE_CREATE_INFO viewport_create;
+ XGL_DYNAMIC_RS_STATE_CREATE_INFO raster;
+ XGL_DYNAMIC_CB_STATE_CREATE_INFO color_blend;
+ XGL_DYNAMIC_DS_STATE_CREATE_INFO depth_stencil;
XGL_RESULT err;
- memset(&viewport, 0, sizeof(viewport));
- viewport.viewportCount = 1;
- viewport.scissorEnable = XGL_FALSE;
- viewport.viewports[0].width = (XGL_FLOAT) demo->width;
- viewport.viewports[0].height = (XGL_FLOAT) demo->height;
- viewport.viewports[0].minDepth = (XGL_FLOAT) 0.0f;
- viewport.viewports[0].maxDepth = (XGL_FLOAT) 1.0f;
+ memset(&viewport_create, 0, sizeof(viewport_create));
+ viewport_create.sType = XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO;
+ viewport_create.viewportCount = 1;
+ XGL_VIEWPORT viewport;
+ viewport.height = (XGL_FLOAT) demo->height;
+ viewport.width = (XGL_FLOAT) demo->width;
+ viewport.minDepth = (XGL_FLOAT) 0.0f;
+ viewport.maxDepth = (XGL_FLOAT) 1.0f;
+ viewport_create.pViewports = &viewport;
memset(&raster, 0, sizeof(raster));
- raster.sType = XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO;
- raster.fillMode = XGL_FILL_SOLID;
- raster.cullMode = XGL_CULL_NONE;
- raster.frontFace = XGL_FRONT_FACE_CCW;
-
- memset(&msaa, 0, sizeof(msaa));
- msaa.sType = XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO;
- msaa.samples = 1;
- msaa.sampleMask = 0x1;
+ raster.sType = XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO;
memset(&color_blend, 0, sizeof(color_blend));
- color_blend.sType = XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO;
+ color_blend.sType = XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO;
memset(&depth_stencil, 0, sizeof(depth_stencil));
- depth_stencil.sType = XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO;
- depth_stencil.depthTestEnable = XGL_TRUE;
- depth_stencil.depthWriteEnable = XGL_TRUE;
- depth_stencil.depthFunc = XGL_COMPARE_LESS_EQUAL;
- depth_stencil.depthBoundsEnable = XGL_FALSE;
+ depth_stencil.sType = XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO;
+ depth_stencil.stencilBackRef = 0;
+ depth_stencil.stencilFrontRef = 0;
+ depth_stencil.stencilReadMask = 0xff;
+ depth_stencil.stencilWriteMask = 0xff;
- err = xglCreateViewportState(demo->device, &viewport, &demo->viewport);
+ err = xglCreateDynamicViewportState(demo->device, &viewport_create, &demo->viewport);
assert(!err);
- err = xglCreateRasterState(demo->device, &raster, &demo->raster);
+ err = xglCreateDynamicRasterState(demo->device, &raster, &demo->raster);
assert(!err);
- err = xglCreateMsaaState(demo->device, &msaa, &demo->msaa);
- assert(!err);
-
- err = xglCreateColorBlendState(demo->device,
+ err = xglCreateDynamicColorBlendState(demo->device,
&color_blend, &demo->color_blend);
assert(!err);
- err = xglCreateDepthStencilState(demo->device,
+ err = xglCreateDynamicDepthStencilState(demo->device,
&depth_stencil, &demo->depth_stencil);
assert(!err);
}
@@ -1400,7 +1434,6 @@
xglDestroyObject(demo->viewport);
xglDestroyObject(demo->raster);
- xglDestroyObject(demo->msaa);
xglDestroyObject(demo->color_blend);
xglDestroyObject(demo->depth_stencil);
diff --git a/demos/tri.c b/demos/tri.c
index a4b3656..82aadc7 100644
--- a/demos/tri.c
+++ b/demos/tri.c
@@ -68,11 +68,10 @@
XGL_PIPELINE pipeline;
- XGL_VIEWPORT_STATE_OBJECT viewport;
- XGL_RASTER_STATE_OBJECT raster;
- XGL_MSAA_STATE_OBJECT msaa;
- XGL_COLOR_BLEND_STATE_OBJECT color_blend;
- XGL_DEPTH_STENCIL_STATE_OBJECT depth_stencil;
+ XGL_DYNAMIC_VP_STATE_OBJECT viewport;
+ XGL_DYNAMIC_RS_STATE_OBJECT raster;
+ XGL_DYNAMIC_CB_STATE_OBJECT color_blend;
+ XGL_DYNAMIC_DS_STATE_OBJECT depth_stencil;
XGL_CMD_BUFFER cmd;
@@ -144,12 +143,11 @@
xglCmdBindDescriptorSet(demo->cmd, XGL_PIPELINE_BIND_POINT_GRAPHICS,
0, demo->dset, 0);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_VIEWPORT, demo->viewport);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_RASTER, demo->raster);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_MSAA, demo->msaa);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_COLOR_BLEND,
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_VIEWPORT, demo->viewport);
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_RASTER, demo->raster);
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_COLOR_BLEND,
demo->color_blend);
- xglCmdBindStateObject(demo->cmd, XGL_STATE_BIND_DEPTH_STENCIL,
+ xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_DEPTH_STENCIL,
demo->depth_stencil);
@@ -308,8 +306,10 @@
mem_alloc.allocationSize = mem_reqs.size;
mem_alloc.alignment = mem_reqs.alignment;
mem_alloc.heapCount = mem_reqs.heapCount;
- memcpy(mem_alloc.heaps, mem_reqs.heaps,
- sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount);
+ XGL_UINT heapInfo[1];
+ mem_alloc.pHeaps = (const XGL_UINT *)&heapInfo;
+ memcpy(&heapInfo, mem_reqs.pHeaps,
+ sizeof(mem_reqs.pHeaps[0]) * mem_reqs.heapCount);
/* allocate memory */
err = xglAllocMemory(demo->device, &mem_alloc,
@@ -412,8 +412,10 @@
mem_alloc.allocationSize = mem_reqs.size;
mem_alloc.alignment = mem_reqs.alignment;
mem_alloc.heapCount = mem_reqs.heapCount;
- memcpy(mem_alloc.heaps, mem_reqs.heaps,
- sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount);
+ XGL_UINT heapInfo[0];
+ mem_alloc.pHeaps = (const XGL_UINT *)&heapInfo;
+ memcpy(&heapInfo, mem_reqs.pHeaps,
+ sizeof(mem_reqs.pHeaps[0]) * mem_reqs.heapCount);
/* allocate memory */
err = xglAllocMemory(demo->device, &mem_alloc,
@@ -483,7 +485,7 @@
.alignment = 0,
.flags = 0,
.heapCount = 0,
- .heaps[0] = 0,
+ .pHeaps = 0,
.memPriority = XGL_MEMORY_PRIORITY_NORMAL,
};
XGL_MEMORY_REQUIREMENTS mem_reqs;
@@ -503,8 +505,9 @@
mem_alloc.allocationSize = mem_reqs.size;
mem_alloc.alignment = mem_reqs.alignment;
mem_alloc.heapCount = mem_reqs.heapCount;
- memcpy(mem_alloc.heaps, mem_reqs.heaps,
- sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount);
+ mem_alloc.pHeaps = mem_reqs.pHeaps;
+ memcpy((XGL_UINT *)mem_alloc.pHeaps, mem_reqs.pHeaps,
+ sizeof(mem_reqs.pHeaps[0]) * mem_reqs.heapCount);
err = xglAllocMemory(demo->device, &mem_alloc, &demo->vertices.mem);
assert(!err);
@@ -645,10 +648,12 @@
XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO vi;
XGL_PIPELINE_IA_STATE_CREATE_INFO ia;
XGL_PIPELINE_RS_STATE_CREATE_INFO rs;
- XGL_PIPELINE_CB_STATE cb;
- XGL_PIPELINE_DB_STATE_CREATE_INFO db;
+ XGL_PIPELINE_CB_STATE_CREATE_INFO cb;
+ XGL_PIPELINE_DS_STATE_CREATE_INFO ds;
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO vs;
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO fs;
+ XGL_PIPELINE_VP_STATE_CREATE_INFO vp;
+ XGL_PIPELINE_MS_STATE_CREATE_INFO ms;
XGL_DESCRIPTOR_SLOT_INFO fs_slots[DEMO_TEXTURE_COUNT * 2];
XGL_RESULT err;
XGL_UINT i;
@@ -664,15 +669,38 @@
memset(&rs, 0, sizeof(rs));
rs.sType = XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO;
+ rs.fillMode = XGL_FILL_SOLID;
+ rs.cullMode = XGL_CULL_NONE;
+ rs.frontFace = XGL_FRONT_FACE_CCW;
memset(&cb, 0, sizeof(cb));
cb.sType = XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO;
- cb.attachment[0].format = demo->format;
- cb.attachment[0].channelWriteMask = 0xf;
+ XGL_PIPELINE_CB_ATTACHMENT_STATE att_state[1];
+ memset(att_state, 0, sizeof(att_state));
+ att_state[0].format = demo->format;
+ att_state[0].channelWriteMask = 0xf;
+ att_state[0].blendEnable = XGL_FALSE;
+ cb.attachmentCount = 1;
+ cb.pAttachments = att_state;
- memset(&db, 0, sizeof(db));
- db.sType = XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO;
- db.format = demo->depth.format;
+
+ memset(&vp, 0, sizeof(vp));
+ vp.sType = XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO;
+ vp.scissorEnable = XGL_FALSE;
+
+
+ memset(&ds, 0, sizeof(ds));
+ ds.sType = XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO;
+ ds.format = demo->depth.format;
+ ds.depthTestEnable = XGL_TRUE;
+ ds.depthWriteEnable = XGL_TRUE;
+ ds.depthFunc = XGL_COMPARE_LESS_EQUAL;
+ ds.depthBoundsEnable = XGL_FALSE;
+ ds.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
+ ds.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
+ ds.back.stencilFunc = XGL_COMPARE_ALWAYS;
+ ds.stencilTestEnable = XGL_FALSE;
+ ds.front = ds.back;
memset(&fs_slots, 0, sizeof(fs_slots));
for (i = 0; i < DEMO_TEXTURE_COUNT; i++) {
@@ -686,21 +714,33 @@
vs.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vs.shader.stage = XGL_SHADER_STAGE_VERTEX;
vs.shader.shader = demo_prepare_vs(demo);
+ vs.shader.linkConstBufferCount = 0;
+ vs.shader.descriptorSetMappingCount = 0;
memset(&fs, 0, sizeof(fs));
fs.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fs.shader.stage = XGL_SHADER_STAGE_FRAGMENT;
fs.shader.shader = demo_prepare_fs(demo);
- fs.shader.descriptorSetMapping[0].descriptorCount =
- DEMO_TEXTURE_COUNT * 2;
- fs.shader.descriptorSetMapping[0].pDescriptorInfo = fs_slots;
+ XGL_DESCRIPTOR_SET_MAPPING ds_mapping;
+ ds_mapping.descriptorCount = DEMO_TEXTURE_COUNT * 2;
+ ds_mapping.pDescriptorInfo = fs_slots;
+ fs.shader.descriptorSetMappingCount = 1;
+ fs.shader.pDescriptorSetMapping = &ds_mapping;
+
+ memset(&ms, 0, sizeof(ms));
+ ms.sType = XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO;
+ ms.sampleMask = 1;
+ ms.multisampleEnable = XGL_FALSE;
+ ms.samples = 1;
pipeline.pNext = (const XGL_VOID *) &vi;
vi.pNext = (XGL_VOID *) &ia;
ia.pNext = (const XGL_VOID *) &rs;
rs.pNext = (const XGL_VOID *) &cb;
- cb.pNext = (const XGL_VOID *) &db;
- db.pNext = (const XGL_VOID *) &vs;
+ cb.pNext = (const XGL_VOID *) &ms;
+ ms.pNext = (const XGL_VOID *) &vp;
+ vp.pNext = (const XGL_VOID *) &ds;
+ ds.pNext = (const XGL_VOID *) &vs;
vs.pNext = (const XGL_VOID *) &fs;
err = xglCreateGraphicsPipeline(demo->device, &pipeline, &demo->pipeline);
@@ -712,56 +752,47 @@
static void demo_prepare_dynamic_states(struct demo *demo)
{
- XGL_VIEWPORT_STATE_CREATE_INFO viewport;
- XGL_RASTER_STATE_CREATE_INFO raster;
- XGL_MSAA_STATE_CREATE_INFO msaa;
- XGL_COLOR_BLEND_STATE_CREATE_INFO color_blend;
- XGL_DEPTH_STENCIL_STATE_CREATE_INFO depth_stencil;
+ XGL_DYNAMIC_VP_STATE_CREATE_INFO viewport_create;
+ XGL_DYNAMIC_RS_STATE_CREATE_INFO raster;
+ XGL_DYNAMIC_CB_STATE_CREATE_INFO color_blend;
+ XGL_DYNAMIC_DS_STATE_CREATE_INFO depth_stencil;
XGL_RESULT err;
+ memset(&viewport_create, 0, sizeof(viewport_create));
+ viewport_create.sType = XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO;
+ viewport_create.viewportCount = 1;
+ XGL_VIEWPORT viewport;
memset(&viewport, 0, sizeof(viewport));
- viewport.viewportCount = 1;
- viewport.scissorEnable = XGL_FALSE;
- viewport.viewports[0].width = (XGL_FLOAT) demo->width;
- viewport.viewports[0].height = (XGL_FLOAT) demo->height;
- viewport.viewports[0].minDepth = (XGL_FLOAT) 0.0f;
- viewport.viewports[0].maxDepth = (XGL_FLOAT) 1.0f;
+ viewport.width = (XGL_FLOAT) demo->width;
+ viewport.height = (XGL_FLOAT) demo->height;
+ viewport.minDepth = (XGL_FLOAT) 0.0f;
+ viewport.maxDepth = (XGL_FLOAT) 1.0f;
+ viewport_create.pViewports = &viewport;
memset(&raster, 0, sizeof(raster));
- raster.sType = XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO;
- raster.fillMode = XGL_FILL_SOLID;
- raster.cullMode = XGL_CULL_NONE;
- raster.frontFace = XGL_FRONT_FACE_CCW;
-
- memset(&msaa, 0, sizeof(msaa));
- msaa.sType = XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO;
- msaa.samples = 1;
- msaa.sampleMask = 0x1;
+ raster.sType = XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO;
memset(&color_blend, 0, sizeof(color_blend));
- color_blend.sType = XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO;
+ color_blend.sType = XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO;
memset(&depth_stencil, 0, sizeof(depth_stencil));
- depth_stencil.sType = XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO;
- depth_stencil.depthTestEnable = XGL_TRUE;
- depth_stencil.depthWriteEnable = XGL_TRUE;
- depth_stencil.depthFunc = XGL_COMPARE_LESS_EQUAL;
- depth_stencil.depthBoundsEnable = XGL_FALSE;
+ depth_stencil.sType = XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO;
+ depth_stencil.stencilBackRef = 0;
+ depth_stencil.stencilFrontRef = 0;
+ depth_stencil.stencilReadMask = 0xff;
+ depth_stencil.stencilWriteMask = 0xff;
- err = xglCreateViewportState(demo->device, &viewport, &demo->viewport);
+ err = xglCreateDynamicViewportState(demo->device, &viewport_create, &demo->viewport);
assert(!err);
- err = xglCreateRasterState(demo->device, &raster, &demo->raster);
+ err = xglCreateDynamicRasterState(demo->device, &raster, &demo->raster);
assert(!err);
- err = xglCreateMsaaState(demo->device, &msaa, &demo->msaa);
- assert(!err);
-
- err = xglCreateColorBlendState(demo->device,
+ err = xglCreateDynamicColorBlendState(demo->device,
&color_blend, &demo->color_blend);
assert(!err);
- err = xglCreateDepthStencilState(demo->device,
+ err = xglCreateDynamicDepthStencilState(demo->device,
&depth_stencil, &demo->depth_stencil);
assert(!err);
}
@@ -963,7 +994,6 @@
xglDestroyObject(demo->viewport);
xglDestroyObject(demo->raster);
- xglDestroyObject(demo->msaa);
xglDestroyObject(demo->color_blend);
xglDestroyObject(demo->depth_stencil);
diff --git a/icd/intel/buf.c b/icd/intel/buf.c
index f783eec..e257f1b 100644
--- a/icd/intel/buf.c
+++ b/icd/intel/buf.c
@@ -46,6 +46,7 @@
case XGL_INFO_TYPE_MEMORY_REQUIREMENTS:
{
XGL_MEMORY_REQUIREMENTS *mem_req = data;
+ static XGL_UINT heapInfo[1];
*size = sizeof(XGL_MEMORY_REQUIREMENTS);
if (data == NULL)
@@ -65,7 +66,7 @@
mem_req->alignment = 4096;
mem_req->heapCount = 1;
- mem_req->heaps[0] = 0;
+ mem_req->pHeaps = heapInfo;
}
break;
diff --git a/icd/intel/cmd.h b/icd/intel/cmd.h
index 238fc1e..2298187 100644
--- a/icd/intel/cmd.h
+++ b/icd/intel/cmd.h
@@ -162,11 +162,10 @@
} pipeline;
struct {
- const struct intel_viewport_state *viewport;
- const struct intel_raster_state *raster;
- const struct intel_msaa_state *msaa;
- const struct intel_blend_state *blend;
- const struct intel_ds_state *ds;
+ const struct intel_dynamic_vp *viewport;
+ const struct intel_dynamic_rs *raster;
+ const struct intel_dynamic_cb *blend;
+ const struct intel_dynamic_ds *ds;
} state;
struct {
@@ -192,6 +191,7 @@
XGL_INDEX_TYPE type;
} index;
+
struct intel_render_pass *render_pass;
XGL_UINT draw_count;
diff --git a/icd/intel/cmd_meta.c b/icd/intel/cmd_meta.c
index b234a5e..7c0c7bc 100644
--- a/icd/intel/cmd_meta.c
+++ b/icd/intel/cmd_meta.c
@@ -335,35 +335,8 @@
XGL_UINT32 stencil_ref,
struct intel_cmd_meta *meta)
{
- XGL_DEPTH_STENCIL_STATE_CREATE_INFO info;
- struct intel_ds_state *state;
- XGL_RESULT ret;
-
- memset(&info, 0, sizeof(info));
- info.sType = XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO;
-
- if (aspect == XGL_IMAGE_ASPECT_DEPTH) {
- info.depthWriteEnable = XGL_TRUE;
- }
- else if (aspect == XGL_IMAGE_ASPECT_STENCIL) {
- info.stencilTestEnable = XGL_TRUE;
- info.stencilReadMask = 0xff;
- info.stencilWriteMask = 0xff;
- info.front.stencilFailOp = XGL_STENCIL_OP_KEEP;
- info.front.stencilPassOp = XGL_STENCIL_OP_REPLACE;
- info.front.stencilDepthFailOp = XGL_STENCIL_OP_KEEP;
- info.front.stencilFunc = XGL_COMPARE_ALWAYS;
- info.front.stencilRef = stencil_ref;
- info.back = info.front;
- }
-
- ret = intel_ds_state_create(cmd->dev, &info, &state);
- if (ret != XGL_SUCCESS) {
- cmd->result = ret;
- return;
- }
-
- meta->ds.state = state;
+ meta->ds.stencil_ref = stencil_ref;
+ meta->ds.aspect = aspect;
}
static enum intel_dev_meta_shader get_shader_id(const struct intel_dev *dev,
@@ -890,7 +863,6 @@
cmd_draw_meta(cmd, meta);
intel_ds_view_destroy(meta->ds.view);
- intel_ds_state_destroy(meta->ds.state);
}
meta->dst.layer++;
diff --git a/icd/intel/cmd_pipeline.c b/icd/intel/cmd_pipeline.c
index 0762f2f..d986d90 100644
--- a/icd/intel/cmd_pipeline.c
+++ b/icd/intel/cmd_pipeline.c
@@ -375,9 +375,7 @@
uint32_t body[6])
{
const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
- const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
- const struct intel_raster_state *raster = cmd->bind.state.raster;
- const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
+ const struct intel_dynamic_rs *raster = cmd->bind.state.raster;
uint32_t dw1, dw2, dw3;
int point_width;
@@ -388,7 +386,7 @@
GEN7_SF_DW1_DEPTH_OFFSET_WIREFRAME |
GEN7_SF_DW1_DEPTH_OFFSET_POINT |
GEN7_SF_DW1_VIEWPORT_ENABLE |
- raster->cmd_sf_fill;
+ pipeline->cmd_sf_fill;
if (cmd_gen(cmd) >= INTEL_GEN(7)) {
int format;
@@ -410,9 +408,9 @@
dw1 |= format << GEN7_SF_DW1_DEPTH_FORMAT__SHIFT;
}
- dw2 = raster->cmd_sf_cull;
+ dw2 = pipeline->cmd_sf_cull;
- if (msaa->sample_count > 1) {
+ if (pipeline->sample_count > 1) {
dw2 |= 128 << GEN7_SF_DW2_LINE_WIDTH__SHIFT |
GEN7_SF_DW2_MSRASTMODE_ON_PATTERN;
} else {
@@ -420,11 +418,11 @@
GEN7_SF_DW2_MSRASTMODE_OFF_PIXEL;
}
- if (viewport->scissor_enable)
+ if (pipeline->scissor_enable)
dw2 |= GEN7_SF_DW2_SCISSOR_ENABLE;
/* in U8.3 */
- point_width = (int) (pipeline->pointSize * 8.0f + 0.5f);
+ point_width = (int) (raster->rs_info.pointSize * 8.0f + 0.5f);
point_width = U_CLAMP(point_width, 1, 2047);
dw3 = pipeline->provoking_vertex_tri << GEN7_SF_DW3_TRI_PROVOKE__SHIFT |
@@ -437,9 +435,9 @@
body[0] = dw1;
body[1] = dw2;
body[2] = dw3;
- body[3] = raster->cmd_depth_offset_const;
- body[4] = raster->cmd_depth_offset_scale;
- body[5] = raster->cmd_depth_offset_clamp;
+ body[3] = u_fui((float) raster->rs_info.depthBias * 2.0f);
+ body[4] = u_fui(raster->rs_info.slopeScaledDepthBias);
+ body[5] = u_fui(raster->rs_info.depthBiasClamp);
}
static void gen7_fill_3DSTATE_SBE_body(const struct intel_cmd *cmd,
@@ -500,8 +498,7 @@
const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
const struct intel_pipeline_shader *vs = &pipeline->vs;
const struct intel_pipeline_shader *fs = &pipeline->fs;
- const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
- const struct intel_raster_state *raster = cmd->bind.state.raster;
+ const struct intel_dynamic_vp *viewport = cmd->bind.state.viewport;
uint32_t dw1, dw2, dw3, *dw;
CMD_ASSERT(cmd, 6, 7.5);
@@ -510,7 +507,7 @@
if (cmd_gen(cmd) >= INTEL_GEN(7)) {
dw1 |= GEN7_CLIP_DW1_SUBPIXEL_8BITS |
GEN7_CLIP_DW1_EARLY_CULL_ENABLE |
- raster->cmd_clip_cull;
+ pipeline->cmd_clip_cull;
}
dw2 = GEN6_CLIP_DW2_CLIP_ENABLE |
@@ -569,7 +566,6 @@
{
const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
const struct intel_pipeline_shader *fs = &pipeline->fs;
- const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
const uint8_t cmd_len = 9;
XGL_UINT pos;
uint32_t dw0, dw2, dw4, dw5, dw6, *dw;
@@ -610,7 +606,7 @@
fs->barycentric_interps << GEN6_WM_DW6_BARYCENTRIC_INTERP__SHIFT |
GEN6_WM_DW6_POINT_RASTRULE_UPPER_RIGHT;
- if (msaa->sample_count > 1) {
+ if (pipeline->sample_count > 1) {
dw6 |= GEN6_WM_DW6_MSRASTMODE_ON_PATTERN |
GEN6_WM_DW6_MSDISPMODE_PERPIXEL;
} else {
@@ -637,7 +633,6 @@
{
const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
const struct intel_pipeline_shader *fs = &pipeline->fs;
- const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
const uint8_t cmd_len = 3;
uint32_t dw0, dw1, dw2, *dw;
@@ -664,7 +659,7 @@
dw2 = 0;
- if (msaa->sample_count > 1) {
+ if (pipeline->sample_count > 1) {
dw1 |= GEN7_WM_DW1_MSRASTMODE_ON_PATTERN;
dw2 |= GEN7_WM_DW2_MSDISPMODE_PERPIXEL;
} else {
@@ -682,7 +677,6 @@
{
const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
const struct intel_pipeline_shader *fs = &pipeline->fs;
- const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
const uint8_t cmd_len = 8;
uint32_t dw0, dw2, dw4, dw5, *dw;
XGL_UINT pos;
@@ -699,7 +693,7 @@
if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
dw4 |= (fs->max_threads - 1) << GEN75_PS_DW4_MAX_THREADS__SHIFT;
- dw4 |= msaa->cmd[msaa->cmd_len - 1] << GEN75_PS_DW4_SAMPLE_MASK__SHIFT;
+ dw4 |= pipeline->cmd_sample_mask << GEN75_PS_DW4_SAMPLE_MASK__SHIFT;
} else {
dw4 |= (fs->max_threads - 1) << GEN7_PS_DW4_MAX_THREADS__SHIFT;
}
@@ -964,82 +958,35 @@
static uint32_t gen6_BLEND_STATE(struct intel_cmd *cmd)
{
const uint8_t cmd_align = GEN6_ALIGNMENT_BLEND_STATE;
- const uint8_t cmd_len = XGL_MAX_COLOR_ATTACHMENTS * 2;
- const XGL_PIPELINE_CB_STATE *cb = &cmd->bind.pipeline.graphics->cb_state;
- const struct intel_blend_state *blend = cmd->bind.state.blend;
- uint32_t dw[XGL_MAX_COLOR_ATTACHMENTS * 2];
- int i;
+ const uint8_t cmd_len = INTEL_MAX_RENDER_TARGETS * 2;
+ const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
CMD_ASSERT(cmd, 6, 7.5);
- STATIC_ASSERT(ARRAY_SIZE(blend->cmd_blend) >= XGL_MAX_COLOR_ATTACHMENTS);
+ STATIC_ASSERT(ARRAY_SIZE(pipeline->cmd_cb) >= INTEL_MAX_RENDER_TARGETS);
- for (i = 0; i < XGL_MAX_COLOR_ATTACHMENTS; i++) {
- const XGL_PIPELINE_CB_ATTACHMENT_STATE *att = &cb->attachment[i];
- uint32_t dw0, dw1;
-
- dw0 = 0;
- dw1 = GEN6_BLEND_DW1_COLORCLAMP_RTFORMAT |
- GEN6_BLEND_DW1_PRE_BLEND_CLAMP |
- GEN6_BLEND_DW1_POST_BLEND_CLAMP;
-
- if (cb->logicOp != XGL_LOGIC_OP_COPY) {
- int logicop;
-
- switch (cb->logicOp) {
- case XGL_LOGIC_OP_CLEAR: logicop = GEN6_LOGICOP_CLEAR; break;
- case XGL_LOGIC_OP_AND: logicop = GEN6_LOGICOP_AND; break;
- case XGL_LOGIC_OP_AND_REVERSE: logicop = GEN6_LOGICOP_AND_REVERSE; break;
- case XGL_LOGIC_OP_AND_INVERTED: logicop = GEN6_LOGICOP_AND_INVERTED; break;
- case XGL_LOGIC_OP_NOOP: logicop = GEN6_LOGICOP_NOOP; break;
- case XGL_LOGIC_OP_XOR: logicop = GEN6_LOGICOP_XOR; break;
- case XGL_LOGIC_OP_OR: logicop = GEN6_LOGICOP_OR; break;
- case XGL_LOGIC_OP_NOR: logicop = GEN6_LOGICOP_NOR; break;
- case XGL_LOGIC_OP_EQUIV: logicop = GEN6_LOGICOP_EQUIV; break;
- case XGL_LOGIC_OP_INVERT: logicop = GEN6_LOGICOP_INVERT; break;
- case XGL_LOGIC_OP_OR_REVERSE: logicop = GEN6_LOGICOP_OR_REVERSE; break;
- case XGL_LOGIC_OP_COPY_INVERTED: logicop = GEN6_LOGICOP_COPY_INVERTED; break;
- case XGL_LOGIC_OP_OR_INVERTED: logicop = GEN6_LOGICOP_OR_INVERTED; break;
- case XGL_LOGIC_OP_NAND: logicop = GEN6_LOGICOP_NAND; break;
- case XGL_LOGIC_OP_SET: logicop = GEN6_LOGICOP_SET; break;
- default:
- assert(!"unknown logic op");
- logicop = GEN6_LOGICOP_CLEAR;
- break;
- }
-
- dw1 |= GEN6_BLEND_DW1_LOGICOP_ENABLE |
- logicop << GEN6_BLEND_DW1_LOGICOP_FUNC__SHIFT;
- } else if (att->blendEnable && blend) {
- dw0 |= blend->cmd_blend[i];
- }
-
- if (!(att->channelWriteMask & 0x1))
- dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_R;
- if (!(att->channelWriteMask & 0x2))
- dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_G;
- if (!(att->channelWriteMask & 0x4))
- dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_B;
- if (!(att->channelWriteMask & 0x8))
- dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_A;
-
- dw[2 * i] = dw0;
- dw[2 * i + 1] = dw1;
- }
-
- return cmd_state_write(cmd, INTEL_CMD_ITEM_BLEND, cmd_align, cmd_len, dw);
+ return cmd_state_write(cmd, INTEL_CMD_ITEM_BLEND, cmd_align, cmd_len, pipeline->cmd_cb);
}
static uint32_t gen6_DEPTH_STENCIL_STATE(struct intel_cmd *cmd,
- const struct intel_ds_state *state)
+ const struct intel_dynamic_ds *state)
{
+ const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
const uint8_t cmd_align = GEN6_ALIGNMENT_DEPTH_STENCIL_STATE;
const uint8_t cmd_len = 3;
+ uint32_t dw[3];
+
+ dw[0] = pipeline->cmd_depth_stencil;
+ dw[1] = (state->ds_info.stencilReadMask & 0xff) << 24 |
+ (state->ds_info.stencilWriteMask & 0xff) << 16;
+ dw[2] = pipeline->cmd_depth_test;
CMD_ASSERT(cmd, 6, 7.5);
- STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
+
+ if (state->ds_info.stencilWriteMask && pipeline->stencilTestEnable)
+ dw[0] |= 1 << 18;
return cmd_state_write(cmd, INTEL_CMD_ITEM_DEPTH_STENCIL,
- cmd_align, cmd_len, state->cmd);
+ cmd_align, cmd_len, dw);
}
static uint32_t gen6_COLOR_CALC_STATE(struct intel_cmd *cmd,
@@ -1297,8 +1244,8 @@
static void gen6_cc_states(struct intel_cmd *cmd)
{
- const struct intel_blend_state *blend = cmd->bind.state.blend;
- const struct intel_ds_state *ds = cmd->bind.state.ds;
+ const struct intel_dynamic_cb *blend = cmd->bind.state.blend;
+ const struct intel_dynamic_ds *ds = cmd->bind.state.ds;
uint32_t blend_offset, ds_offset, cc_offset;
uint32_t stencil_ref;
uint32_t blend_color[4];
@@ -1308,13 +1255,14 @@
blend_offset = gen6_BLEND_STATE(cmd);
if (blend)
- memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
+ memcpy(blend_color, blend->cb_info.blendConst, sizeof(blend_color));
else
memset(blend_color, 0, sizeof(blend_color));
if (ds) {
ds_offset = gen6_DEPTH_STENCIL_STATE(cmd, ds);
- stencil_ref = ds->cmd_stencil_ref;
+ stencil_ref = (ds->ds_info.stencilFrontRef && 0xff) << 24 |
+ (ds->ds_info.stencilBackRef && 0xff) << 16;
} else {
ds_offset = 0;
stencil_ref = 0;
@@ -1327,14 +1275,15 @@
static void gen6_viewport_states(struct intel_cmd *cmd)
{
- const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
+ const struct intel_dynamic_vp *viewport = cmd->bind.state.viewport;
uint32_t sf_offset, clip_offset, cc_offset, scissor_offset;
if (!viewport)
return;
- assert(viewport->cmd_len == (8 + 4 + 2 + 2 * viewport->scissor_enable) *
- viewport->viewport_count);
+ assert(viewport->cmd_len == (8 + 4 + 2) *
+ viewport->viewport_count + (viewport->has_scissor_rects) ?
+ (viewport->viewport_count * 2) : 0);
sf_offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SF_VIEWPORT,
GEN6_ALIGNMENT_SF_VIEWPORT, 8 * viewport->viewport_count,
@@ -1348,7 +1297,7 @@
GEN6_ALIGNMENT_SF_VIEWPORT, 2 * viewport->viewport_count,
&viewport->cmd[viewport->cmd_cc_pos]);
- if (viewport->scissor_enable) {
+ if (viewport->has_scissor_rects) {
scissor_offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SCISSOR_RECT,
GEN6_ALIGNMENT_SCISSOR_RECT, 2 * viewport->viewport_count,
&viewport->cmd[viewport->cmd_scissor_rect_pos]);
@@ -1364,8 +1313,8 @@
static void gen7_cc_states(struct intel_cmd *cmd)
{
- const struct intel_blend_state *blend = cmd->bind.state.blend;
- const struct intel_ds_state *ds = cmd->bind.state.ds;
+ const struct intel_dynamic_cb *blend = cmd->bind.state.blend;
+ const struct intel_dynamic_ds *ds = cmd->bind.state.ds;
uint32_t stencil_ref;
uint32_t blend_color[4];
uint32_t offset;
@@ -1380,13 +1329,14 @@
GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS, offset);
if (blend)
- memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
+ memcpy(blend_color, blend->cb_info.blendConst, sizeof(blend_color));
else
memset(blend_color, 0, sizeof(blend_color));
if (ds) {
offset = gen6_DEPTH_STENCIL_STATE(cmd, ds);
- stencil_ref = ds->cmd_stencil_ref;
+ stencil_ref = (ds->ds_info.stencilFrontRef && 0xff) << 24 |
+ (ds->ds_info.stencilBackRef && 0xff) << 16;
gen7_3dstate_pointer(cmd,
GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS,
offset);
@@ -1403,13 +1353,14 @@
static void gen7_viewport_states(struct intel_cmd *cmd)
{
- const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
+ const struct intel_dynamic_vp *viewport = cmd->bind.state.viewport;
+ const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
uint32_t offset;
if (!viewport)
return;
- assert(viewport->cmd_len == (16 + 2 + 2 * viewport->scissor_enable) *
+ assert(viewport->cmd_len == (16 + 2 + 2 * pipeline->scissor_enable) *
viewport->viewport_count);
offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SF_VIEWPORT,
@@ -1426,7 +1377,7 @@
GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
offset);
- if (viewport->scissor_enable) {
+ if (pipeline->scissor_enable) {
offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SCISSOR_RECT,
GEN6_ALIGNMENT_SCISSOR_RECT, 2 * viewport->viewport_count,
&viewport->cmd[viewport->cmd_scissor_rect_pos]);
@@ -2017,7 +1968,6 @@
static void emit_bounded_states(struct intel_cmd *cmd)
{
- const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
emit_graphics_pipeline(cmd);
@@ -2056,13 +2006,49 @@
cmd_wa_gen6_pre_depth_stall_write(cmd);
cmd_wa_gen6_pre_multisample_depth_flush(cmd);
- /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
- cmd_batch_write(cmd, msaa->cmd_len, msaa->cmd);
-
gen6_3DSTATE_VERTEX_BUFFERS(cmd);
gen6_3DSTATE_VS(cmd);
}
+static uint32_t gen6_meta_DEPTH_STENCIL_STATE(struct intel_cmd *cmd,
+ const struct intel_cmd_meta *meta)
+{
+ const uint8_t cmd_align = GEN6_ALIGNMENT_DEPTH_STENCIL_STATE;
+ const uint8_t cmd_len = 3;
+ uint32_t dw[3];
+ uint32_t cmd_depth_stencil;
+ uint32_t cmd_depth_test;
+
+ CMD_ASSERT(cmd, 6, 7.5);
+
+ cmd_depth_stencil = 0;
+ cmd_depth_test = 0;
+ if (meta->ds.aspect == XGL_IMAGE_ASPECT_DEPTH) {
+ cmd_depth_test |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE |
+ GEN6_COMPAREFUNCTION_ALWAYS << 27;
+ }
+ else if (meta->ds.aspect == XGL_IMAGE_ASPECT_STENCIL) {
+ cmd_depth_stencil = 1 << 31 |
+ (GEN6_COMPAREFUNCTION_ALWAYS) << 28 |
+ (GEN6_STENCILOP_KEEP) << 25 |
+ (GEN6_STENCILOP_KEEP) << 22 |
+ (GEN6_STENCILOP_REPLACE) << 19 |
+ 1 << 15 |
+ (GEN6_COMPAREFUNCTION_ALWAYS) << 12 |
+ (GEN6_STENCILOP_KEEP) << 9 |
+ (GEN6_STENCILOP_KEEP) << 6 |
+ (GEN6_STENCILOP_REPLACE) << 3;
+ }
+
+ cmd_depth_test |= GEN6_COMPAREFUNCTION_ALWAYS << 27;
+ dw[0] = cmd_depth_stencil | 1 << 18;
+ dw[1] = (0xff) << 24 | (0xff) << 16;
+ dw[2] = cmd_depth_test;
+
+ return cmd_state_write(cmd, INTEL_CMD_ITEM_DEPTH_STENCIL,
+ cmd_align, cmd_len, dw);
+}
+
static void gen6_meta_dynamic_states(struct intel_cmd *cmd)
{
const struct intel_cmd_meta *meta = cmd->bind.meta;
@@ -2084,15 +2070,17 @@
}
if (meta->mode != INTEL_CMD_META_VS_POINTS) {
- if (meta->ds.state) {
+ if (meta->ds.aspect != XGL_IMAGE_ASPECT_COLOR) {
const uint32_t blend_color[4] = { 0, 0, 0, 0 };
+ uint32_t stencil_ref = (meta->ds.stencil_ref && 0xff) << 24 |
+ (meta->ds.stencil_ref && 0xff) << 16;
/* DEPTH_STENCIL_STATE */
- ds_offset = gen6_DEPTH_STENCIL_STATE(cmd, meta->ds.state);
+ ds_offset = gen6_meta_DEPTH_STENCIL_STATE(cmd, meta);
/* COLOR_CALC_STATE */
cc_offset = gen6_COLOR_CALC_STATE(cmd,
- meta->ds.state->cmd_stencil_ref, blend_color);
+ stencil_ref, blend_color);
/* CC_VIEWPORT */
cc_vp_offset = cmd_state_pointer(cmd, INTEL_CMD_ITEM_CC_VIEWPORT,
@@ -2974,35 +2962,29 @@
}
static void cmd_bind_viewport_state(struct intel_cmd *cmd,
- const struct intel_viewport_state *state)
+ const struct intel_dynamic_vp *state)
{
cmd->bind.state.viewport = state;
}
static void cmd_bind_raster_state(struct intel_cmd *cmd,
- const struct intel_raster_state *state)
+ const struct intel_dynamic_rs *state)
{
cmd->bind.state.raster = state;
}
static void cmd_bind_ds_state(struct intel_cmd *cmd,
- const struct intel_ds_state *state)
+ const struct intel_dynamic_ds *state)
{
cmd->bind.state.ds = state;
}
static void cmd_bind_blend_state(struct intel_cmd *cmd,
- const struct intel_blend_state *state)
+ const struct intel_dynamic_cb *state)
{
cmd->bind.state.blend = state;
}
-static void cmd_bind_msaa_state(struct intel_cmd *cmd,
- const struct intel_msaa_state *state)
-{
- cmd->bind.state.msaa = state;
-}
-
static void cmd_draw(struct intel_cmd *cmd,
XGL_UINT vertex_start,
XGL_UINT vertex_count,
@@ -3147,33 +3129,29 @@
}
}
-ICD_EXPORT XGL_VOID XGLAPI xglCmdBindStateObject(
+ICD_EXPORT XGL_VOID XGLAPI xglCmdBindDynamicStateObject(
XGL_CMD_BUFFER cmdBuffer,
XGL_STATE_BIND_POINT stateBindPoint,
- XGL_STATE_OBJECT state)
+ XGL_DYNAMIC_STATE_OBJECT state)
{
struct intel_cmd *cmd = intel_cmd(cmdBuffer);
switch (stateBindPoint) {
case XGL_STATE_BIND_VIEWPORT:
cmd_bind_viewport_state(cmd,
- intel_viewport_state((XGL_VIEWPORT_STATE_OBJECT) state));
+ intel_dynamic_vp((XGL_DYNAMIC_VP_STATE_OBJECT) state));
break;
case XGL_STATE_BIND_RASTER:
cmd_bind_raster_state(cmd,
- intel_raster_state((XGL_RASTER_STATE_OBJECT) state));
+ intel_dynamic_rs((XGL_DYNAMIC_RS_STATE_OBJECT) state));
break;
case XGL_STATE_BIND_DEPTH_STENCIL:
cmd_bind_ds_state(cmd,
- intel_ds_state((XGL_DEPTH_STENCIL_STATE_OBJECT) state));
+ intel_dynamic_ds((XGL_DYNAMIC_DS_STATE_OBJECT) state));
break;
case XGL_STATE_BIND_COLOR_BLEND:
cmd_bind_blend_state(cmd,
- intel_blend_state((XGL_COLOR_BLEND_STATE_OBJECT) state));
- break;
- case XGL_STATE_BIND_MSAA:
- cmd_bind_msaa_state(cmd,
- intel_msaa_state((XGL_MSAA_STATE_OBJECT) state));
+ intel_dynamic_cb((XGL_DYNAMIC_CB_STATE_OBJECT) state));
break;
default:
cmd->result = XGL_ERROR_INVALID_VALUE;
diff --git a/icd/intel/cmd_priv.h b/icd/intel/cmd_priv.h
index e29eec9..4950cd7 100644
--- a/icd/intel/cmd_priv.h
+++ b/icd/intel/cmd_priv.h
@@ -117,7 +117,8 @@
struct {
struct intel_ds_view *view;
- struct intel_ds_state *state;
+ uint32_t stencil_ref;
+ XGL_IMAGE_ASPECT aspect;
} ds;
uint32_t clear_val[4];
diff --git a/icd/intel/compiler/pipeline/pipeline_compiler_interface.cpp b/icd/intel/compiler/pipeline/pipeline_compiler_interface.cpp
index 67a076e..da2e91a 100644
--- a/icd/intel/compiler/pipeline/pipeline_compiler_interface.cpp
+++ b/icd/intel/compiler/pipeline/pipeline_compiler_interface.cpp
@@ -722,8 +722,16 @@
BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)));
}
+ XGL_DESCRIPTOR_SET_MAPPING null_map;
+ XGL_DESCRIPTOR_SET_MAPPING *pMapping = info->pDescriptorSetMapping;
+ null_map.descriptorCount = 0;
+
+ if (! info->descriptorSetMappingCount) {
+ pMapping = &null_map;
+ }
+
pipe_shader->rmap = rmap_create(gpu,
- &info->descriptorSetMapping[0],
+ pMapping,
&info->dynamicBufferViewMapping,
rt_count, pipe_shader->ubo_start);
diff --git a/icd/intel/event.c b/icd/intel/event.c
index b1d4859..7470540 100644
--- a/icd/intel/event.c
+++ b/icd/intel/event.c
@@ -94,6 +94,7 @@
XGL_SIZE *size, XGL_VOID *data)
{
XGL_RESULT ret = XGL_SUCCESS;
+ static XGL_UINT eventHeaps[1] = {0}; /* always heap 0 */
switch (type) {
case XGL_INFO_TYPE_MEMORY_REQUIREMENTS:
@@ -107,7 +108,7 @@
mem_req->size = 4;
mem_req->alignment = 64;
mem_req->heapCount = 1;
- mem_req->heaps[0] = 0;
+ mem_req->pHeaps = eventHeaps;
}
break;
diff --git a/icd/intel/img.c b/icd/intel/img.c
index b9f1cf3..cf06871 100644
--- a/icd/intel/img.c
+++ b/icd/intel/img.c
@@ -51,6 +51,7 @@
static XGL_RESULT img_get_info(struct intel_base *base, int type,
XGL_SIZE *size, XGL_VOID *data)
{
+ static XGL_UINT imageHeaps[1] = {0}; /* always heap 0 */
struct intel_img *img = intel_img_from_base(base);
XGL_RESULT ret = XGL_SUCCESS;
@@ -65,8 +66,7 @@
mem_req->size = img->total_size;
mem_req->alignment = 4096;
mem_req->heapCount = 1;
- mem_req->heaps[0] = 0;
-
+ mem_req->pHeaps = imageHeaps;
}
break;
default:
diff --git a/icd/intel/intel.h b/icd/intel/intel.h
index 19f2f60..809708c 100644
--- a/icd/intel/intel.h
+++ b/icd/intel/intel.h
@@ -52,6 +52,8 @@
#define INTEL_MAX_VERTEX_BINDING_COUNT 33
#define INTEL_MAX_VERTEX_ELEMENT_COUNT (INTEL_MAX_VERTEX_BINDING_COUNT + 1)
+#define INTEL_MAX_RENDER_TARGETS 8
+
enum intel_debug_flags {
INTEL_DEBUG_BATCH = 1 << 0,
diff --git a/icd/intel/mem.c b/icd/intel/mem.c
index d8c2f8a..47f312d 100644
--- a/icd/intel/mem.c
+++ b/icd/intel/mem.c
@@ -36,7 +36,7 @@
if ((info->alignment != 0) && (4096 % info->alignment))
return XGL_ERROR_INVALID_ALIGNMENT;
- if (info->heapCount != 1 || info->heaps[0] != 0)
+ if (info->heapCount != 1 || info->pHeaps[0] != 0)
return XGL_ERROR_INVALID_POINTER;
mem = (struct intel_mem *) intel_base_create(dev, sizeof(*mem),
diff --git a/icd/intel/obj.c b/icd/intel/obj.c
index d589992..ac2c437 100644
--- a/icd/intel/obj.c
+++ b/icd/intel/obj.c
@@ -135,24 +135,20 @@
shallow_copy = sizeof(XGL_DESCRIPTOR_SET_CREATE_INFO);
break;
case XGL_DBG_OBJECT_VIEWPORT_STATE:
- /* no struct header! */
- shallow_copy = sizeof(XGL_VIEWPORT_STATE_CREATE_INFO);
+ assert(info.header->struct_type == XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO);
+ shallow_copy = sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO);
break;
case XGL_DBG_OBJECT_RASTER_STATE:
- assert(info.header->struct_type == XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO);
- shallow_copy = sizeof(XGL_RASTER_STATE_CREATE_INFO);
- break;
- case XGL_DBG_OBJECT_MSAA_STATE:
- assert(info.header->struct_type == XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO);
- shallow_copy = sizeof(XGL_MSAA_STATE_CREATE_INFO);
+ assert(info.header->struct_type == XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO);
+ shallow_copy = sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO);
break;
case XGL_DBG_OBJECT_COLOR_BLEND_STATE:
- assert(info.header->struct_type == XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO);
- shallow_copy = sizeof(XGL_COLOR_BLEND_STATE_CREATE_INFO);
+ assert(info.header->struct_type == XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO);
+ shallow_copy = sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO);
break;
case XGL_DBG_OBJECT_DEPTH_STENCIL_STATE:
- assert(info.header->struct_type == XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO);
- shallow_copy = sizeof(XGL_DEPTH_STENCIL_STATE_CREATE_INFO);
+ assert(info.header->struct_type == XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO);
+ shallow_copy = sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO);
break;
case XGL_DBG_OBJECT_CMD_BUFFER:
assert(info.header->struct_type == XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO);
@@ -183,10 +179,6 @@
}
if (shallow_copy) {
- /* XGL_VIEWPORT_STATE_CREATE_INFO has no header */
- if (dbg->type != XGL_DBG_OBJECT_VIEWPORT_STATE)
- assert(!info.header->next);
-
dbg->create_info = icd_alloc(shallow_copy, 0, XGL_SYSTEM_ALLOC_DEBUG);
if (!dbg->create_info)
return false;
diff --git a/icd/intel/pipeline.c b/icd/intel/pipeline.c
index cc04221..067be2f 100644
--- a/icd/intel/pipeline.c
+++ b/icd/intel/pipeline.c
@@ -33,14 +33,92 @@
#include "shader.h"
#include "pipeline.h"
+static int translate_blend_func(XGL_BLEND_FUNC func)
+{
+ switch (func) {
+ case XGL_BLEND_FUNC_ADD: return GEN6_BLENDFUNCTION_ADD;
+ case XGL_BLEND_FUNC_SUBTRACT: return GEN6_BLENDFUNCTION_SUBTRACT;
+ case XGL_BLEND_FUNC_REVERSE_SUBTRACT: return GEN6_BLENDFUNCTION_REVERSE_SUBTRACT;
+ case XGL_BLEND_FUNC_MIN: return GEN6_BLENDFUNCTION_MIN;
+ case XGL_BLEND_FUNC_MAX: return GEN6_BLENDFUNCTION_MAX;
+ default:
+ assert(!"unknown blend func");
+ return GEN6_BLENDFUNCTION_ADD;
+ };
+}
+
+static int translate_blend(XGL_BLEND blend)
+{
+ switch (blend) {
+ case XGL_BLEND_ZERO: return GEN6_BLENDFACTOR_ZERO;
+ case XGL_BLEND_ONE: return GEN6_BLENDFACTOR_ONE;
+ case XGL_BLEND_SRC_COLOR: return GEN6_BLENDFACTOR_SRC_COLOR;
+ case XGL_BLEND_ONE_MINUS_SRC_COLOR: return GEN6_BLENDFACTOR_INV_SRC_COLOR;
+ case XGL_BLEND_DEST_COLOR: return GEN6_BLENDFACTOR_DST_COLOR;
+ case XGL_BLEND_ONE_MINUS_DEST_COLOR: return GEN6_BLENDFACTOR_INV_DST_COLOR;
+ case XGL_BLEND_SRC_ALPHA: return GEN6_BLENDFACTOR_SRC_ALPHA;
+ case XGL_BLEND_ONE_MINUS_SRC_ALPHA: return GEN6_BLENDFACTOR_INV_SRC_ALPHA;
+ case XGL_BLEND_DEST_ALPHA: return GEN6_BLENDFACTOR_DST_ALPHA;
+ case XGL_BLEND_ONE_MINUS_DEST_ALPHA: return GEN6_BLENDFACTOR_INV_DST_ALPHA;
+ case XGL_BLEND_CONSTANT_COLOR: return GEN6_BLENDFACTOR_CONST_COLOR;
+ case XGL_BLEND_ONE_MINUS_CONSTANT_COLOR: return GEN6_BLENDFACTOR_INV_CONST_COLOR;
+ case XGL_BLEND_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_CONST_ALPHA;
+ case XGL_BLEND_ONE_MINUS_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_INV_CONST_ALPHA;
+ case XGL_BLEND_SRC_ALPHA_SATURATE: return GEN6_BLENDFACTOR_SRC_ALPHA_SATURATE;
+ case XGL_BLEND_SRC1_COLOR: return GEN6_BLENDFACTOR_SRC1_COLOR;
+ case XGL_BLEND_ONE_MINUS_SRC1_COLOR: return GEN6_BLENDFACTOR_INV_SRC1_COLOR;
+ case XGL_BLEND_SRC1_ALPHA: return GEN6_BLENDFACTOR_SRC1_ALPHA;
+ case XGL_BLEND_ONE_MINUS_SRC1_ALPHA: return GEN6_BLENDFACTOR_INV_SRC1_ALPHA;
+ default:
+ assert(!"unknown blend factor");
+ return GEN6_BLENDFACTOR_ONE;
+ };
+}
+
+static int translate_compare_func(XGL_COMPARE_FUNC func)
+{
+ switch (func) {
+ case XGL_COMPARE_NEVER: return GEN6_COMPAREFUNCTION_NEVER;
+ case XGL_COMPARE_LESS: return GEN6_COMPAREFUNCTION_LESS;
+ case XGL_COMPARE_EQUAL: return GEN6_COMPAREFUNCTION_EQUAL;
+ case XGL_COMPARE_LESS_EQUAL: return GEN6_COMPAREFUNCTION_LEQUAL;
+ case XGL_COMPARE_GREATER: return GEN6_COMPAREFUNCTION_GREATER;
+ case XGL_COMPARE_NOT_EQUAL: return GEN6_COMPAREFUNCTION_NOTEQUAL;
+ case XGL_COMPARE_GREATER_EQUAL: return GEN6_COMPAREFUNCTION_GEQUAL;
+ case XGL_COMPARE_ALWAYS: return GEN6_COMPAREFUNCTION_ALWAYS;
+ default:
+ assert(!"unknown compare_func");
+ return GEN6_COMPAREFUNCTION_NEVER;
+ }
+}
+
+static int translate_stencil_op(XGL_STENCIL_OP op)
+{
+ switch (op) {
+ case XGL_STENCIL_OP_KEEP: return GEN6_STENCILOP_KEEP;
+ case XGL_STENCIL_OP_ZERO: return GEN6_STENCILOP_ZERO;
+ case XGL_STENCIL_OP_REPLACE: return GEN6_STENCILOP_REPLACE;
+ case XGL_STENCIL_OP_INC_CLAMP: return GEN6_STENCILOP_INCRSAT;
+ case XGL_STENCIL_OP_DEC_CLAMP: return GEN6_STENCILOP_DECRSAT;
+ case XGL_STENCIL_OP_INVERT: return GEN6_STENCILOP_INVERT;
+ case XGL_STENCIL_OP_INC_WRAP: return GEN6_STENCILOP_INCR;
+ case XGL_STENCIL_OP_DEC_WRAP: return GEN6_STENCILOP_DECR;
+ default:
+ assert(!"unknown stencil op");
+ return GEN6_STENCILOP_KEEP;
+ }
+}
+
struct intel_pipeline_create_info {
XGL_GRAPHICS_PIPELINE_CREATE_INFO graphics;
XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO vi;
XGL_PIPELINE_IA_STATE_CREATE_INFO ia;
- XGL_PIPELINE_DB_STATE_CREATE_INFO db;
- XGL_PIPELINE_CB_STATE cb;
+ XGL_PIPELINE_DS_STATE_CREATE_INFO db;
+ XGL_PIPELINE_CB_STATE_CREATE_INFO cb;
XGL_PIPELINE_RS_STATE_CREATE_INFO rs;
XGL_PIPELINE_TESS_STATE_CREATE_INFO tess;
+ XGL_PIPELINE_MS_STATE_CREATE_INFO ms;
+ XGL_PIPELINE_VP_STATE_CREATE_INFO vp;
XGL_PIPELINE_SHADER vs;
XGL_PIPELINE_SHADER tcs;
XGL_PIPELINE_SHADER tes;
@@ -148,16 +226,6 @@
pipeline->topology = info->ia.topology;
pipeline->disable_vs_cache = info->ia.disableVertexReuse;
- if (info->ia.provokingVertex == XGL_PROVOKING_VERTEX_FIRST) {
- pipeline->provoking_vertex_tri = 0;
- pipeline->provoking_vertex_trifan = 1;
- pipeline->provoking_vertex_line = 0;
- } else {
- pipeline->provoking_vertex_tri = 2;
- pipeline->provoking_vertex_trifan = 2;
- pipeline->provoking_vertex_line = 1;
- }
-
switch (info->ia.topology) {
case XGL_TOPOLOGY_POINT_LIST:
pipeline->prim_type = GEN6_3DPRIM_POINTLIST;
@@ -233,7 +301,62 @@
{
pipeline->depthClipEnable = rs_state->depthClipEnable;
pipeline->rasterizerDiscardEnable = rs_state->rasterizerDiscardEnable;
- pipeline->pointSize = rs_state->pointSize;
+
+ if (rs_state->provokingVertex == XGL_PROVOKING_VERTEX_FIRST) {
+ pipeline->provoking_vertex_tri = 0;
+ pipeline->provoking_vertex_trifan = 1;
+ pipeline->provoking_vertex_line = 0;
+ } else {
+ pipeline->provoking_vertex_tri = 2;
+ pipeline->provoking_vertex_trifan = 2;
+ pipeline->provoking_vertex_line = 1;
+ }
+
+ switch (rs_state->fillMode) {
+ case XGL_FILL_POINTS:
+ pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_POINT |
+ GEN7_SF_DW1_BACKFACE_POINT;
+ break;
+ case XGL_FILL_WIREFRAME:
+ pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_WIREFRAME |
+ GEN7_SF_DW1_BACKFACE_WIREFRAME;
+ break;
+ case XGL_FILL_SOLID:
+ default:
+ pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_SOLID |
+ GEN7_SF_DW1_BACKFACE_SOLID;
+ break;
+ }
+
+ if (rs_state->frontFace == XGL_FRONT_FACE_CCW) {
+ pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTWINDING_CCW;
+ pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_FRONTWINDING_CCW;
+ }
+
+ switch (rs_state->cullMode) {
+ case XGL_CULL_NONE:
+ default:
+ pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_NONE;
+ pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_NONE;
+ break;
+ case XGL_CULL_FRONT:
+ pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_FRONT;
+ pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_FRONT;
+ break;
+ case XGL_CULL_BACK:
+ pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BACK;
+ pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BACK;
+ break;
+ case XGL_CULL_FRONT_AND_BACK:
+ pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BOTH;
+ pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BOTH;
+ break;
+ }
+
+ /* only GEN7+ needs cull mode in 3DSTATE_CLIP */
+ if (intel_gpu_gen(pipeline->dev->gpu) == INTEL_GEN(6))
+ pipeline->cmd_clip_cull = 0;
+
return XGL_SUCCESS;
}
@@ -271,6 +394,7 @@
static XGL_RESULT pipeline_get_info(struct intel_base *base, int type,
XGL_SIZE *size, XGL_VOID *data)
{
+ static XGL_UINT pipelineHeaps[1] = {0}; /* always heap 0 */
struct intel_pipeline *pipeline = intel_pipeline_from_base(base);
XGL_RESULT ret = XGL_SUCCESS;
@@ -284,7 +408,7 @@
mem_req->size = pipeline->scratch_size;
mem_req->alignment = 1024;
mem_req->heapCount = 1;
- mem_req->heaps[0] = 0;
+ mem_req->pHeaps = pipelineHeaps;
}
}
break;
@@ -840,6 +964,229 @@
dw[5] = 0;
}
+static void pipeline_build_depth_stencil(struct intel_pipeline *pipeline,
+ const struct intel_pipeline_create_info *info)
+{
+ pipeline->cmd_depth_stencil = 0;
+
+ if (info->db.stencilTestEnable) {
+ pipeline->cmd_depth_stencil = 1 << 31 |
+ translate_compare_func(info->db.front.stencilFunc) << 28 |
+ translate_stencil_op(info->db.front.stencilFailOp) << 25 |
+ translate_stencil_op(info->db.front.stencilDepthFailOp) << 22 |
+ translate_stencil_op(info->db.front.stencilPassOp) << 19 |
+ 1 << 15 |
+ translate_compare_func(info->db.back.stencilFunc) << 12 |
+ translate_stencil_op(info->db.back.stencilFailOp) << 9 |
+ translate_stencil_op(info->db.back.stencilDepthFailOp) << 6 |
+ translate_stencil_op(info->db.back.stencilPassOp) << 3;
+ }
+
+ pipeline->stencilTestEnable = info->db.stencilTestEnable;
+
+ /*
+ * From the Sandy Bridge PRM, volume 2 part 1, page 360:
+ *
+ * "Enabling the Depth Test function without defining a Depth Buffer is
+ * UNDEFINED."
+ *
+ * From the Sandy Bridge PRM, volume 2 part 1, page 375:
+ *
+ * "A Depth Buffer must be defined before enabling writes to it, or
+ * operation is UNDEFINED."
+ *
+ * TODO We do not check these yet.
+ */
+ if (info->db.depthTestEnable) {
+ pipeline->cmd_depth_test = GEN6_ZS_DW2_DEPTH_TEST_ENABLE |
+ translate_compare_func(info->db.depthFunc) << 27;
+ } else {
+ pipeline->cmd_depth_test = GEN6_COMPAREFUNCTION_ALWAYS << 27;
+ }
+
+ if (info->db.depthWriteEnable)
+ pipeline->cmd_depth_test |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE;
+}
+
+static void pipeline_init_sample_pattern(struct intel_pipeline *pipeline,
+ uint8_t *samples)
+{
+ struct sample {
+ int x, y;
+ };
+ static const struct sample default_pattern_2x[2] = {
+ { -4, -4 },
+ { 4, 4 },
+ };
+ static const struct sample default_pattern_4x[4] = {
+ { -2, -6 },
+ { 6, -2 },
+ { -6, 2 },
+ { 2, 6 },
+ };
+ static const struct sample default_pattern_8x[8] = {
+ { 1, -3 },
+ { -1, 3 },
+ { 5, 1 },
+ { -3, -5 },
+ { -5, 5 },
+ { -7, -1 },
+ { 3, 7 },
+ { 7, -7 },
+ };
+
+ const struct sample *pattern;
+ int i;
+
+ switch (pipeline->sample_count) {
+ case 2:
+ pattern = default_pattern_2x;
+ break;
+ case 4:
+ pattern = default_pattern_4x;
+ break;
+ case 8:
+ pattern = default_pattern_8x;
+ break;
+ default:
+ memset(samples, 0, pipeline->sample_count);
+ return;
+ break;
+ }
+
+ for (i = 0; i < pipeline->sample_count; i++)
+ samples[i] = (pattern[i].x + 8) << 4 | (pattern[i].y + 8);
+}
+
+static void pipeline_build_msaa(struct intel_pipeline *pipeline,
+ const struct intel_pipeline_create_info *info)
+{
+ uint32_t cmd, cmd_len;
+ uint32_t *dw;
+
+ INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
+
+
+ pipeline->sample_count = (info->ms.samples <= 1)?1:info->ms.samples;
+
+ /* 3DSTATE_MULTISAMPLE */
+ cmd = GEN6_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE);
+ cmd_len = (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) ? 4 : 3;
+ dw = pipeline_cmd_ptr(pipeline, cmd_len + 2);
+ dw[0] = cmd | (cmd_len - 2);
+ if (pipeline->sample_count <= 1)
+ dw[1] = GEN6_MULTISAMPLE_DW1_NUMSAMPLES_1;
+ else if (pipeline->sample_count <= 4 || intel_gpu_gen(pipeline->dev->gpu) == INTEL_GEN(6))
+ dw[1] = GEN6_MULTISAMPLE_DW1_NUMSAMPLES_4;
+ else
+ dw[1] = GEN7_MULTISAMPLE_DW1_NUMSAMPLES_8;
+
+ pipeline_init_sample_pattern(pipeline, (uint8_t *) &dw[2]);
+
+ dw += cmd_len;
+
+ /* 3DSTATE_SAMPLE_MASK */
+ cmd = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK);
+ cmd_len = 2;
+
+ dw[0] = cmd | (cmd_len - 2);
+ dw[1] = info->ms.sampleMask & ((1 << pipeline->sample_count) - 1);
+ pipeline->cmd_sample_mask = dw[1];
+}
+
+static void pipeline_build_cb(struct intel_pipeline *pipeline,
+ const struct intel_pipeline_create_info *info)
+{
+ XGL_UINT i;
+
+ INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
+ STATIC_ASSERT(ARRAY_SIZE(pipeline->cmd_cb) >= INTEL_MAX_RENDER_TARGETS*2);
+ assert(info->cb.attachmentCount <= INTEL_MAX_RENDER_TARGETS);
+
+ uint32_t *dw = pipeline->cmd_cb;
+
+ for (i = 0; i < info->cb.attachmentCount; i++) {
+ const XGL_PIPELINE_CB_ATTACHMENT_STATE *att = &info->cb.pAttachments[i];
+ uint32_t dw0, dw1;
+
+
+ dw0 = 0;
+ dw1 = GEN6_BLEND_DW1_COLORCLAMP_RTFORMAT |
+ GEN6_BLEND_DW1_PRE_BLEND_CLAMP |
+ GEN6_BLEND_DW1_POST_BLEND_CLAMP;
+
+ if (att->blendEnable) {
+ dw0 = 1 << 31 |
+ translate_blend_func(att->blendFuncAlpha) << 26 |
+ translate_blend(att->srcBlendAlpha) << 20 |
+ translate_blend(att->destBlendAlpha) << 15 |
+ translate_blend_func(att->blendFuncColor) << 11 |
+ translate_blend(att->srcBlendColor) << 5 |
+ translate_blend(att->destBlendColor);
+
+ if (att->blendFuncAlpha != att->blendFuncColor ||
+ att->srcBlendAlpha != att->srcBlendColor ||
+ att->destBlendAlpha != att->destBlendColor)
+ dw0 |= 1 << 30;
+ }
+
+ if (info->cb.logicOp != XGL_LOGIC_OP_COPY) {
+ int logicop;
+
+ switch (info->cb.logicOp) {
+ case XGL_LOGIC_OP_CLEAR: logicop = GEN6_LOGICOP_CLEAR; break;
+ case XGL_LOGIC_OP_AND: logicop = GEN6_LOGICOP_AND; break;
+ case XGL_LOGIC_OP_AND_REVERSE: logicop = GEN6_LOGICOP_AND_REVERSE; break;
+ case XGL_LOGIC_OP_AND_INVERTED: logicop = GEN6_LOGICOP_AND_INVERTED; break;
+ case XGL_LOGIC_OP_NOOP: logicop = GEN6_LOGICOP_NOOP; break;
+ case XGL_LOGIC_OP_XOR: logicop = GEN6_LOGICOP_XOR; break;
+ case XGL_LOGIC_OP_OR: logicop = GEN6_LOGICOP_OR; break;
+ case XGL_LOGIC_OP_NOR: logicop = GEN6_LOGICOP_NOR; break;
+ case XGL_LOGIC_OP_EQUIV: logicop = GEN6_LOGICOP_EQUIV; break;
+ case XGL_LOGIC_OP_INVERT: logicop = GEN6_LOGICOP_INVERT; break;
+ case XGL_LOGIC_OP_OR_REVERSE: logicop = GEN6_LOGICOP_OR_REVERSE; break;
+ case XGL_LOGIC_OP_COPY_INVERTED: logicop = GEN6_LOGICOP_COPY_INVERTED; break;
+ case XGL_LOGIC_OP_OR_INVERTED: logicop = GEN6_LOGICOP_OR_INVERTED; break;
+ case XGL_LOGIC_OP_NAND: logicop = GEN6_LOGICOP_NAND; break;
+ case XGL_LOGIC_OP_SET: logicop = GEN6_LOGICOP_SET; break;
+ default:
+ assert(!"unknown logic op");
+ logicop = GEN6_LOGICOP_CLEAR;
+ break;
+ }
+
+ dw1 |= GEN6_BLEND_DW1_LOGICOP_ENABLE |
+ logicop << GEN6_BLEND_DW1_LOGICOP_FUNC__SHIFT;
+ }
+
+ if (!(att->channelWriteMask & 0x1))
+ dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_R;
+ if (!(att->channelWriteMask & 0x2))
+ dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_G;
+ if (!(att->channelWriteMask & 0x4))
+ dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_B;
+ if (!(att->channelWriteMask & 0x8))
+ dw1 |= GEN6_BLEND_DW1_WRITE_DISABLE_A;
+
+ dw[2 * i] = dw0;
+ dw[2 * i + 1] = dw1;
+ }
+
+ for (i=info->cb.attachmentCount; i < INTEL_MAX_RENDER_TARGETS; i++)
+ {
+ dw[2 * i] = 0;
+ dw[2 * i + 1] = GEN6_BLEND_DW1_COLORCLAMP_RTFORMAT |
+ GEN6_BLEND_DW1_PRE_BLEND_CLAMP |
+ GEN6_BLEND_DW1_POST_BLEND_CLAMP |
+ GEN6_BLEND_DW1_WRITE_DISABLE_R |
+ GEN6_BLEND_DW1_WRITE_DISABLE_G |
+ GEN6_BLEND_DW1_WRITE_DISABLE_B |
+ GEN6_BLEND_DW1_WRITE_DISABLE_A;
+ }
+
+}
+
+
static XGL_RESULT pipeline_build_all(struct intel_pipeline *pipeline,
const struct intel_pipeline_create_info *info)
{
@@ -859,6 +1206,7 @@
pipeline_build_vertex_elements(pipeline, info);
pipeline_build_fragment_SBE(pipeline);
+ pipeline_build_msaa(pipeline, info);
if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) {
pipeline_build_urb_alloc_gen7(pipeline, info);
@@ -867,6 +1215,7 @@
pipeline_build_hs(pipeline, info);
pipeline_build_te(pipeline, info);
pipeline_build_ds(pipeline, info);
+ pipeline_build_depth_stencil(pipeline, info);
pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL |
@@ -887,10 +1236,13 @@
if (ret == XGL_SUCCESS) {
pipeline->db_format = info->db.format;
+ pipeline_build_cb(pipeline, info);
pipeline->cb_state = info->cb;
pipeline->tess_state = info->tess;
}
+ pipeline->scissor_enable = info->vp.scissorEnable;
+
return ret;
}
@@ -904,6 +1256,14 @@
{
memset(info, 0, sizeof(*info));
+
+ /*
+ * Do we need to set safe defaults in case the app doesn't provide all of
+ * the necessary create infos?
+ */
+ info->ms.samples = 1;
+ info->ms.sampleMask = 1;
+
while (header) {
const void *src = (const void *) header;
XGL_SIZE size;
@@ -922,7 +1282,7 @@
size = sizeof(info->ia);
dst = &info->ia;
break;
- case XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO:
+ case XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO:
size = sizeof(info->db);
dst = &info->db;
break;
@@ -938,6 +1298,14 @@
size = sizeof(info->tess);
dst = &info->tess;
break;
+ case XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO:
+ size = sizeof(info->ms);
+ dst = &info->ms;
+ break;
+ case XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO:
+ size = sizeof(info->vp);
+ dst = &info->vp;
+ break;
case XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO:
{
const XGL_PIPELINE_SHADER *shader =
@@ -978,7 +1346,6 @@
}
memcpy(dst, src, size);
-
header = header->next;
}
diff --git a/icd/intel/pipeline.h b/icd/intel/pipeline.h
index 25542e8..b14bd3f 100644
--- a/icd/intel/pipeline.h
+++ b/icd/intel/pipeline.h
@@ -144,15 +144,20 @@
*
* - 3DSTATE_URB (3)
* - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT)
+ * - 3DSTATE_MULTISAMPLE (3)
+ * - 3DSTATE_SAMPLE_MASK (2)
*
* On GEN7, there are
*
* - 3DSTATE_URB_x (2*4)
* - 3DSTATE_PUSH_CONSTANT_ALLOC_x (2*5)
* - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT)
+ * - 3DSTATE_SBE (14)
* - 3DSTATE_HS (7)
* - 3DSTATE_TE (4)
* - 3DSTATE_DS (6)
+ * - 3DSTATE_MULTISAMPLE (4)
+ * - 3DSTATE_SAMPLE_MASK (2)
*/
#define INTEL_PSO_CMD_ENTRIES 128
@@ -182,12 +187,12 @@
/* Depth Buffer format */
XGL_FORMAT db_format;
- XGL_PIPELINE_CB_STATE cb_state;
+ XGL_PIPELINE_CB_STATE_CREATE_INFO cb_state;
// XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state;
bool depthClipEnable;
bool rasterizerDiscardEnable;
- float pointSize;
+ bool scissor_enable;
XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state;
@@ -205,6 +210,21 @@
uint32_t cmds[INTEL_PSO_CMD_ENTRIES];
XGL_UINT cmd_len;
XGL_UINT cmd_sbe_body_offset;
+
+ /* The following are only partial HW commands that will need
+ * more processing before sending to the HW
+ */
+ // XGL_PIPELINE_DS_STATE_CREATE_INFO ds_state
+ bool stencilTestEnable;
+ uint32_t cmd_depth_stencil;
+ uint32_t cmd_depth_test;
+
+ uint32_t cmd_sf_fill;
+ uint32_t cmd_clip_cull;
+ uint32_t cmd_sf_cull;
+ uint32_t cmd_cb[2 * INTEL_MAX_RENDER_TARGETS];
+ uint32_t sample_count;
+ uint32_t cmd_sample_mask;
};
static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline)
diff --git a/icd/intel/query.c b/icd/intel/query.c
index 46fbb2d..23d4bdc 100644
--- a/icd/intel/query.c
+++ b/icd/intel/query.c
@@ -39,6 +39,7 @@
static XGL_RESULT query_get_info(struct intel_base *base, int type,
XGL_SIZE *size, XGL_VOID *data)
{
+ static XGL_UINT queryHeaps[1] = {0}; /* always heap 0 */
struct intel_query *query = intel_query_from_base(base);
XGL_RESULT ret = XGL_SUCCESS;
@@ -53,7 +54,7 @@
mem_req->size = query->slot_stride * query->slot_count;
mem_req->alignment = 64;
mem_req->heapCount = 1;
- mem_req->heaps[0] = 0;
+ mem_req->pHeaps = queryHeaps;
}
break;
diff --git a/icd/intel/state.c b/icd/intel/state.c
index c022e26..96ff9e7 100644
--- a/icd/intel/state.c
+++ b/icd/intel/state.c
@@ -30,138 +30,6 @@
#include "dev.h"
#include "state.h"
-static int translate_compare_func(XGL_COMPARE_FUNC func)
-{
- switch (func) {
- case XGL_COMPARE_NEVER: return GEN6_COMPAREFUNCTION_NEVER;
- case XGL_COMPARE_LESS: return GEN6_COMPAREFUNCTION_LESS;
- case XGL_COMPARE_EQUAL: return GEN6_COMPAREFUNCTION_EQUAL;
- case XGL_COMPARE_LESS_EQUAL: return GEN6_COMPAREFUNCTION_LEQUAL;
- case XGL_COMPARE_GREATER: return GEN6_COMPAREFUNCTION_GREATER;
- case XGL_COMPARE_NOT_EQUAL: return GEN6_COMPAREFUNCTION_NOTEQUAL;
- case XGL_COMPARE_GREATER_EQUAL: return GEN6_COMPAREFUNCTION_GEQUAL;
- case XGL_COMPARE_ALWAYS: return GEN6_COMPAREFUNCTION_ALWAYS;
- default:
- assert(!"unknown compare_func");
- return GEN6_COMPAREFUNCTION_NEVER;
- }
-}
-
-static int translate_stencil_op(XGL_STENCIL_OP op)
-{
- switch (op) {
- case XGL_STENCIL_OP_KEEP: return GEN6_STENCILOP_KEEP;
- case XGL_STENCIL_OP_ZERO: return GEN6_STENCILOP_ZERO;
- case XGL_STENCIL_OP_REPLACE: return GEN6_STENCILOP_REPLACE;
- case XGL_STENCIL_OP_INC_CLAMP: return GEN6_STENCILOP_INCRSAT;
- case XGL_STENCIL_OP_DEC_CLAMP: return GEN6_STENCILOP_DECRSAT;
- case XGL_STENCIL_OP_INVERT: return GEN6_STENCILOP_INVERT;
- case XGL_STENCIL_OP_INC_WRAP: return GEN6_STENCILOP_INCR;
- case XGL_STENCIL_OP_DEC_WRAP: return GEN6_STENCILOP_DECR;
- default:
- assert(!"unknown stencil op");
- return GEN6_STENCILOP_KEEP;
- }
-}
-
-static int translate_blend_func(XGL_BLEND_FUNC func)
-{
- switch (func) {
- case XGL_BLEND_FUNC_ADD: return GEN6_BLENDFUNCTION_ADD;
- case XGL_BLEND_FUNC_SUBTRACT: return GEN6_BLENDFUNCTION_SUBTRACT;
- case XGL_BLEND_FUNC_REVERSE_SUBTRACT: return GEN6_BLENDFUNCTION_REVERSE_SUBTRACT;
- case XGL_BLEND_FUNC_MIN: return GEN6_BLENDFUNCTION_MIN;
- case XGL_BLEND_FUNC_MAX: return GEN6_BLENDFUNCTION_MAX;
- default:
- assert(!"unknown blend func");
- return GEN6_BLENDFUNCTION_ADD;
- };
-}
-
-static int translate_blend(XGL_BLEND blend)
-{
- switch (blend) {
- case XGL_BLEND_ZERO: return GEN6_BLENDFACTOR_ZERO;
- case XGL_BLEND_ONE: return GEN6_BLENDFACTOR_ONE;
- case XGL_BLEND_SRC_COLOR: return GEN6_BLENDFACTOR_SRC_COLOR;
- case XGL_BLEND_ONE_MINUS_SRC_COLOR: return GEN6_BLENDFACTOR_INV_SRC_COLOR;
- case XGL_BLEND_DEST_COLOR: return GEN6_BLENDFACTOR_DST_COLOR;
- case XGL_BLEND_ONE_MINUS_DEST_COLOR: return GEN6_BLENDFACTOR_INV_DST_COLOR;
- case XGL_BLEND_SRC_ALPHA: return GEN6_BLENDFACTOR_SRC_ALPHA;
- case XGL_BLEND_ONE_MINUS_SRC_ALPHA: return GEN6_BLENDFACTOR_INV_SRC_ALPHA;
- case XGL_BLEND_DEST_ALPHA: return GEN6_BLENDFACTOR_DST_ALPHA;
- case XGL_BLEND_ONE_MINUS_DEST_ALPHA: return GEN6_BLENDFACTOR_INV_DST_ALPHA;
- case XGL_BLEND_CONSTANT_COLOR: return GEN6_BLENDFACTOR_CONST_COLOR;
- case XGL_BLEND_ONE_MINUS_CONSTANT_COLOR: return GEN6_BLENDFACTOR_INV_CONST_COLOR;
- case XGL_BLEND_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_CONST_ALPHA;
- case XGL_BLEND_ONE_MINUS_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_INV_CONST_ALPHA;
- case XGL_BLEND_SRC_ALPHA_SATURATE: return GEN6_BLENDFACTOR_SRC_ALPHA_SATURATE;
- case XGL_BLEND_SRC1_COLOR: return GEN6_BLENDFACTOR_SRC1_COLOR;
- case XGL_BLEND_ONE_MINUS_SRC1_COLOR: return GEN6_BLENDFACTOR_INV_SRC1_COLOR;
- case XGL_BLEND_SRC1_ALPHA: return GEN6_BLENDFACTOR_SRC1_ALPHA;
- case XGL_BLEND_ONE_MINUS_SRC1_ALPHA: return GEN6_BLENDFACTOR_INV_SRC1_ALPHA;
- default:
- assert(!"unknown blend factor");
- return GEN6_BLENDFACTOR_ONE;
- };
-}
-
-static void
-raster_state_init(struct intel_raster_state *state,
- const struct intel_gpu *gpu,
- const XGL_RASTER_STATE_CREATE_INFO *info)
-{
- switch (info->fillMode) {
- case XGL_FILL_POINTS:
- state->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_POINT |
- GEN7_SF_DW1_BACKFACE_POINT;
- break;
- case XGL_FILL_WIREFRAME:
- state->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_WIREFRAME |
- GEN7_SF_DW1_BACKFACE_WIREFRAME;
- break;
- case XGL_FILL_SOLID:
- default:
- state->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_SOLID |
- GEN7_SF_DW1_BACKFACE_SOLID;
- break;
- }
-
- if (info->frontFace == XGL_FRONT_FACE_CCW) {
- state->cmd_sf_fill |= GEN7_SF_DW1_FRONTWINDING_CCW;
- state->cmd_clip_cull |= GEN7_CLIP_DW1_FRONTWINDING_CCW;
- }
-
- switch (info->cullMode) {
- case XGL_CULL_NONE:
- default:
- state->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_NONE;
- state->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_NONE;
- break;
- case XGL_CULL_FRONT:
- state->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_FRONT;
- state->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_FRONT;
- break;
- case XGL_CULL_BACK:
- state->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BACK;
- state->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BACK;
- break;
- case XGL_CULL_FRONT_AND_BACK:
- state->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BOTH;
- state->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BOTH;
- break;
- }
-
- /* only GEN7+ needs cull mode in 3DSTATE_CLIP */
- if (intel_gpu_gen(gpu) == INTEL_GEN(6))
- state->cmd_clip_cull = 0;
-
- /* XXX scale info->depthBias back into NDC */
- state->cmd_depth_offset_const = u_fui((float) info->depthBias * 2.0f);
- state->cmd_depth_offset_clamp = u_fui(info->depthBiasClamp);
- state->cmd_depth_offset_scale = u_fui(info->slopeScaledDepthBias);
-}
-
static void
viewport_get_guardband(const struct intel_gpu *gpu,
int center_x, int center_y,
@@ -222,14 +90,18 @@
}
static XGL_RESULT
-viewport_state_alloc_cmd(struct intel_viewport_state *state,
+viewport_state_alloc_cmd(struct intel_dynamic_vp *state,
const struct intel_gpu *gpu,
- const XGL_VIEWPORT_STATE_CREATE_INFO *info)
+ const XGL_DYNAMIC_VP_STATE_CREATE_INFO *info)
{
INTEL_GPU_ASSERT(gpu, 6, 7.5);
state->viewport_count = info->viewportCount;
- state->scissor_enable = info->scissorEnable;
+ state->has_scissor_rects = (info->scissorCount > 0);
+
+ assert(info->viewportCount < INTEL_MAX_RENDER_TARGETS);
+ assert(info->scissorCount < INTEL_MAX_RENDER_TARGETS);
+ assert(!state->has_scissor_rects || info->scissorCount == info->viewportCount);
if (intel_gpu_gen(gpu) >= INTEL_GEN(7)) {
state->cmd_len = 16 * info->viewportCount;
@@ -245,7 +117,7 @@
state->cmd_cc_pos = state->cmd_len;
state->cmd_len += 2 * info->viewportCount;
- if (state->scissor_enable) {
+ if (state->has_scissor_rects) {
state->cmd_scissor_rect_pos = state->cmd_len;
state->cmd_len += 2 * info->viewportCount;
}
@@ -259,9 +131,9 @@
}
static XGL_RESULT
-viewport_state_init(struct intel_viewport_state *state,
+viewport_state_init(struct intel_dynamic_vp *state,
const struct intel_gpu *gpu,
- const XGL_VIEWPORT_STATE_CREATE_INFO *info)
+ const XGL_DYNAMIC_VP_STATE_CREATE_INFO *info)
{
const XGL_UINT sf_stride = (intel_gpu_gen(gpu) >= INTEL_GEN(7)) ? 16 : 8;
const XGL_UINT clip_stride = (intel_gpu_gen(gpu) >= INTEL_GEN(7)) ? 16 : 4;
@@ -281,8 +153,7 @@
scissor_rect = state->cmd + state->cmd_scissor_rect_pos;
for (i = 0; i < info->viewportCount; i++) {
- const XGL_VIEWPORT *viewport = &info->viewports[i];
- const XGL_RECT *scissor = &info->scissors[i];
+ const XGL_VIEWPORT *viewport = &info->pViewports[i];
uint32_t *dw = NULL;
float translate[3], scale[3];
int min_gbx, max_gbx, min_gby, max_gby;
@@ -322,246 +193,47 @@
dw[0] = u_fui(viewport->minDepth);
dw[1] = u_fui(viewport->maxDepth);
cc_viewport += 2;
+ }
+ for (i = 0; i < info->scissorCount; i++) {
+ const XGL_RECT *scissor = &info->pScissors[i];
/* SCISSOR_RECT */
- if (state->scissor_enable) {
- int16_t max_x, max_y;
+ int16_t max_x, max_y;
+ uint32_t *dw = NULL;
- max_x = (scissor->offset.x + scissor->extent.width - 1) & 0xffff;
- max_y = (scissor->offset.y + scissor->extent.height - 1) & 0xffff;
+ max_x = (scissor->offset.x + scissor->extent.width - 1) & 0xffff;
+ max_y = (scissor->offset.y + scissor->extent.height - 1) & 0xffff;
- dw = scissor_rect;
- if (scissor->extent.width && scissor->extent.height) {
- dw[0] = (scissor->offset.y & 0xffff) << 16 |
- (scissor->offset.x & 0xffff);
- dw[1] = max_y << 16 | max_x;
- } else {
- dw[0] = 1 << 16 | 1;
- dw[1] = 0;
- }
- scissor_rect += 2;
+ dw = scissor_rect;
+ if (scissor->extent.width && scissor->extent.height) {
+ dw[0] = (scissor->offset.y & 0xffff) << 16 |
+ (scissor->offset.x & 0xffff);
+ dw[1] = max_y << 16 | max_x;
+ } else {
+ dw[0] = 1 << 16 | 1;
+ dw[1] = 0;
}
+ scissor_rect += 2;
}
return XGL_SUCCESS;
}
-static void msaa_state_init_sample_pattern(const struct intel_msaa_state *state)
-{
- struct sample {
- int x, y;
- };
- static const struct sample default_pattern_2x[2] = {
- { -4, -4 },
- { 4, 4 },
- };
- static const struct sample default_pattern_4x[4] = {
- { -2, -6 },
- { 6, -2 },
- { -6, 2 },
- { 2, 6 },
- };
- static const struct sample default_pattern_8x[8] = {
- { 1, -3 },
- { -1, 3 },
- { 5, 1 },
- { -3, -5 },
- { -5, 5 },
- { -7, -1 },
- { 3, 7 },
- { 7, -7 },
- };
- uint8_t *samples = (uint8_t *) &state->cmd[2];
- const struct sample *pattern;
- int i;
-
- switch (state->sample_count) {
- case 2:
- pattern = default_pattern_2x;
- break;
- case 4:
- pattern = default_pattern_4x;
- break;
- case 8:
- pattern = default_pattern_8x;
- break;
- default:
- memset(samples, 0, state->sample_count);
- return;
- break;
- }
-
- for (i = 0; i < state->sample_count; i++)
- samples[i] = (pattern[i].x + 8) << 4 | (pattern[i].y + 8);
-}
-
-static void
-msaa_state_init(struct intel_msaa_state *state,
- const struct intel_gpu *gpu,
- const XGL_MSAA_STATE_CREATE_INFO *info)
-{
- uint32_t cmd, cmd_len;
- uint32_t *dw = state->cmd;
-
- INTEL_GPU_ASSERT(gpu, 6, 7.5);
- STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= 6);
-
- state->sample_count = info->samples;
- if (!state->sample_count)
- state->sample_count = 1;
-
- /* 3DSTATE_MULTISAMPLE */
- cmd = GEN6_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE);
- cmd_len = (intel_gpu_gen(gpu) >= INTEL_GEN(7)) ? 4 : 3;
-
- dw[0] = cmd | (cmd_len - 2);
- if (info->samples <= 1)
- dw[1] = GEN6_MULTISAMPLE_DW1_NUMSAMPLES_1;
- else if (info->samples <= 4 || intel_gpu_gen(gpu) == INTEL_GEN(6))
- dw[1] = GEN6_MULTISAMPLE_DW1_NUMSAMPLES_4;
- else
- dw[1] = GEN7_MULTISAMPLE_DW1_NUMSAMPLES_8;
-
- msaa_state_init_sample_pattern(state);
-
- dw += cmd_len;
-
- state->cmd_len = cmd_len + 2;
-
- /* 3DSTATE_SAMPLE_MASK */
- cmd = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK);
- cmd_len = 2;
-
- dw[0] = cmd | (cmd_len - 2);
- dw[1] = info->sampleMask & ((1 << info->samples) - 1);
-}
-
-static void
-blend_state_init(struct intel_blend_state *state,
- const struct intel_gpu *gpu,
- const XGL_COLOR_BLEND_STATE_CREATE_INFO *info)
-{
- XGL_UINT i;
-
- INTEL_GPU_ASSERT(gpu, 6, 7.5);
-
- for (i = 0; i < ARRAY_SIZE(info->attachment); i++) {
- const XGL_COLOR_ATTACHMENT_BLEND_STATE *att = &info->attachment[i];
- uint32_t *dw = &state->cmd_blend[i];
-
- if (att->blendEnable) {
- dw[0] = 1 << 31 |
- translate_blend_func(att->blendFuncAlpha) << 26 |
- translate_blend(att->srcBlendAlpha) << 20 |
- translate_blend(att->destBlendAlpha) << 15 |
- translate_blend_func(att->blendFuncColor) << 11 |
- translate_blend(att->srcBlendColor) << 5 |
- translate_blend(att->destBlendColor);
-
- if (att->blendFuncAlpha != att->blendFuncColor ||
- att->srcBlendAlpha != att->srcBlendColor ||
- att->destBlendAlpha != att->destBlendColor)
- dw[0] |= 1 << 30;
- }
- }
-
- memcpy(state->cmd_blend_color, info->blendConst, sizeof(info->blendConst));
-}
-
-static XGL_RESULT
-ds_state_init(struct intel_ds_state *state,
- const struct intel_gpu *gpu,
- const XGL_DEPTH_STENCIL_STATE_CREATE_INFO *info)
-{
- uint32_t *dw = state->cmd;
-
- INTEL_GPU_ASSERT(gpu, 6, 7.5);
-
- STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= 3);
-
- if (info->depthBoundsEnable)
- return XGL_ERROR_UNKNOWN;
-
- /*
- * From the Sandy Bridge PRM, volume 2 part 1, page 359:
- *
- * "If the Depth Buffer is either undefined or does not have a surface
- * format of D32_FLOAT_S8X24_UINT or D24_UNORM_S8_UINT and separate
- * stencil buffer is disabled, Stencil Test Enable must be DISABLED"
- *
- * From the Sandy Bridge PRM, volume 2 part 1, page 370:
- *
- * "This field (Stencil Test Enable) cannot be enabled if
- * Surface Format in 3DSTATE_DEPTH_BUFFER is set to D16_UNORM."
- *
- * TODO We do not check these yet.
- */
- if (info->stencilTestEnable) {
- dw[0] = 1 << 31 |
- translate_compare_func(info->front.stencilFunc) << 28 |
- translate_stencil_op(info->front.stencilFailOp) << 25 |
- translate_stencil_op(info->front.stencilDepthFailOp) << 22 |
- translate_stencil_op(info->front.stencilPassOp) << 19 |
- 1 << 15 |
- translate_compare_func(info->back.stencilFunc) << 12 |
- translate_stencil_op(info->back.stencilFailOp) << 9 |
- translate_stencil_op(info->back.stencilDepthFailOp) << 6 |
- translate_stencil_op(info->back.stencilPassOp) << 3;
-
- if (info->stencilWriteMask)
- dw[0] |= 1 << 18;
-
- /* same read and write masks for both front and back faces */
- dw[1] = (info->stencilReadMask & 0xff) << 24 |
- (info->stencilWriteMask & 0xff) << 16 |
- (info->stencilReadMask & 0xff) << 8 |
- (info->stencilWriteMask & 0xff);
-
- state->cmd_stencil_ref = (info->front.stencilRef & 0xff) << 24 |
- (info->back.stencilRef & 0xff) << 16;
- }
-
- /*
- * From the Sandy Bridge PRM, volume 2 part 1, page 360:
- *
- * "Enabling the Depth Test function without defining a Depth Buffer is
- * UNDEFINED."
- *
- * From the Sandy Bridge PRM, volume 2 part 1, page 375:
- *
- * "A Depth Buffer must be defined before enabling writes to it, or
- * operation is UNDEFINED."
- *
- * TODO We do not check these yet.
- */
- if (info->depthTestEnable) {
- dw[2] = GEN6_ZS_DW2_DEPTH_TEST_ENABLE |
- translate_compare_func(info->depthFunc) << 27;
- } else {
- dw[2] = GEN6_COMPAREFUNCTION_ALWAYS << 27;
- }
-
- if (info->depthWriteEnable)
- dw[2] |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE;
-
- return XGL_SUCCESS;
-}
-
static void viewport_state_destroy(struct intel_obj *obj)
{
- struct intel_viewport_state *state = intel_viewport_state_from_obj(obj);
+ struct intel_dynamic_vp *state = intel_viewport_state_from_obj(obj);
intel_viewport_state_destroy(state);
}
XGL_RESULT intel_viewport_state_create(struct intel_dev *dev,
- const XGL_VIEWPORT_STATE_CREATE_INFO *info,
- struct intel_viewport_state **state_ret)
+ const XGL_DYNAMIC_VP_STATE_CREATE_INFO *info,
+ struct intel_dynamic_vp **state_ret)
{
- struct intel_viewport_state *state;
+ struct intel_dynamic_vp *state;
XGL_RESULT ret;
- state = (struct intel_viewport_state *) intel_base_create(dev,
+ state = (struct intel_dynamic_vp *) intel_base_create(dev,
sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_VIEWPORT_STATE,
info, 0);
if (!state)
@@ -580,7 +252,7 @@
return XGL_SUCCESS;
}
-void intel_viewport_state_destroy(struct intel_viewport_state *state)
+void intel_viewport_state_destroy(struct intel_dynamic_vp *state)
{
icd_free(state->cmd);
intel_base_destroy(&state->obj.base);
@@ -588,118 +260,82 @@
static void raster_state_destroy(struct intel_obj *obj)
{
- struct intel_raster_state *state = intel_raster_state_from_obj(obj);
+ struct intel_dynamic_rs *state = intel_raster_state_from_obj(obj);
intel_raster_state_destroy(state);
}
XGL_RESULT intel_raster_state_create(struct intel_dev *dev,
- const XGL_RASTER_STATE_CREATE_INFO *info,
- struct intel_raster_state **state_ret)
+ const XGL_DYNAMIC_RS_STATE_CREATE_INFO *info,
+ struct intel_dynamic_rs **state_ret)
{
- struct intel_raster_state *state;
+ struct intel_dynamic_rs *state;
- state = (struct intel_raster_state *) intel_base_create(dev,
+ state = (struct intel_dynamic_rs *) intel_base_create(dev,
sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_RASTER_STATE,
info, 0);
if (!state)
return XGL_ERROR_OUT_OF_MEMORY;
state->obj.destroy = raster_state_destroy;
-
- raster_state_init(state, dev->gpu, info);
+ state->rs_info = *info;
*state_ret = state;
return XGL_SUCCESS;
}
-void intel_raster_state_destroy(struct intel_raster_state *state)
-{
- intel_base_destroy(&state->obj.base);
-}
-
-static void msaa_state_destroy(struct intel_obj *obj)
-{
- struct intel_msaa_state *state = intel_msaa_state_from_obj(obj);
-
- intel_msaa_state_destroy(state);
-}
-
-XGL_RESULT intel_msaa_state_create(struct intel_dev *dev,
- const XGL_MSAA_STATE_CREATE_INFO *info,
- struct intel_msaa_state **state_ret)
-{
- struct intel_msaa_state *state;
-
- state = (struct intel_msaa_state *) intel_base_create(dev,
- sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_MSAA_STATE,
- info, 0);
- if (!state)
- return XGL_ERROR_OUT_OF_MEMORY;
-
- state->obj.destroy = msaa_state_destroy;
-
- msaa_state_init(state, dev->gpu, info);
-
- *state_ret = state;
-
- return XGL_SUCCESS;
-}
-
-void intel_msaa_state_destroy(struct intel_msaa_state *state)
+void intel_raster_state_destroy(struct intel_dynamic_rs *state)
{
intel_base_destroy(&state->obj.base);
}
static void blend_state_destroy(struct intel_obj *obj)
{
- struct intel_blend_state *state = intel_blend_state_from_obj(obj);
+ struct intel_dynamic_cb *state = intel_blend_state_from_obj(obj);
intel_blend_state_destroy(state);
}
XGL_RESULT intel_blend_state_create(struct intel_dev *dev,
- const XGL_COLOR_BLEND_STATE_CREATE_INFO *info,
- struct intel_blend_state **state_ret)
+ const XGL_DYNAMIC_CB_STATE_CREATE_INFO *info,
+ struct intel_dynamic_cb **state_ret)
{
- struct intel_blend_state *state;
+ struct intel_dynamic_cb *state;
- state = (struct intel_blend_state *) intel_base_create(dev,
+ state = (struct intel_dynamic_cb *) intel_base_create(dev,
sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_COLOR_BLEND_STATE,
info, 0);
if (!state)
return XGL_ERROR_OUT_OF_MEMORY;
state->obj.destroy = blend_state_destroy;
-
- blend_state_init(state, dev->gpu, info);
+ state->cb_info = *info;
*state_ret = state;
return XGL_SUCCESS;
}
-void intel_blend_state_destroy(struct intel_blend_state *state)
+void intel_blend_state_destroy(struct intel_dynamic_cb *state)
{
intel_base_destroy(&state->obj.base);
}
static void ds_state_destroy(struct intel_obj *obj)
{
- struct intel_ds_state *state = intel_ds_state_from_obj(obj);
+ struct intel_dynamic_ds *state = intel_ds_state_from_obj(obj);
intel_ds_state_destroy(state);
}
XGL_RESULT intel_ds_state_create(struct intel_dev *dev,
- const XGL_DEPTH_STENCIL_STATE_CREATE_INFO *info,
- struct intel_ds_state **state_ret)
+ const XGL_DYNAMIC_DS_STATE_CREATE_INFO *info,
+ struct intel_dynamic_ds **state_ret)
{
- struct intel_ds_state *state;
- XGL_RESULT ret;
+ struct intel_dynamic_ds *state;
- state = (struct intel_ds_state *) intel_base_create(dev,
+ state = (struct intel_dynamic_ds *) intel_base_create(dev,
sizeof(*state), dev->base.dbg, XGL_DBG_OBJECT_DEPTH_STENCIL_STATE,
info, 0);
if (!state)
@@ -707,73 +343,73 @@
state->obj.destroy = ds_state_destroy;
- ret = ds_state_init(state, dev->gpu, info);
- if (ret != XGL_SUCCESS) {
- intel_ds_state_destroy(state);
- return ret;
- }
+ /*
+ * From the Sandy Bridge PRM, volume 2 part 1, page 359:
+ *
+ * "If the Depth Buffer is either undefined or does not have a surface
+ * format of D32_FLOAT_S8X24_UINT or D24_UNORM_S8_UINT and separate
+ * stencil buffer is disabled, Stencil Test Enable must be DISABLED"
+ *
+ * From the Sandy Bridge PRM, volume 2 part 1, page 370:
+ *
+ * "This field (Stencil Test Enable) cannot be enabled if
+ * Surface Format in 3DSTATE_DEPTH_BUFFER is set to D16_UNORM."
+ *
+ * TODO We do not check these yet.
+ */
+
+ state->ds_info = *info;
*state_ret = state;
return XGL_SUCCESS;
}
-void intel_ds_state_destroy(struct intel_ds_state *state)
+void intel_ds_state_destroy(struct intel_dynamic_ds *state)
{
intel_base_destroy(&state->obj.base);
}
-ICD_EXPORT XGL_RESULT XGLAPI xglCreateViewportState(
+ICD_EXPORT XGL_RESULT XGLAPI xglCreateDynamicViewportState(
XGL_DEVICE device,
- const XGL_VIEWPORT_STATE_CREATE_INFO* pCreateInfo,
- XGL_VIEWPORT_STATE_OBJECT* pState)
+ const XGL_DYNAMIC_VP_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_VP_STATE_OBJECT* pState)
{
struct intel_dev *dev = intel_dev(device);
return intel_viewport_state_create(dev, pCreateInfo,
- (struct intel_viewport_state **) pState);
+ (struct intel_dynamic_vp **) pState);
}
-ICD_EXPORT XGL_RESULT XGLAPI xglCreateRasterState(
+ICD_EXPORT XGL_RESULT XGLAPI xglCreateDynamicRasterState(
XGL_DEVICE device,
- const XGL_RASTER_STATE_CREATE_INFO* pCreateInfo,
- XGL_RASTER_STATE_OBJECT* pState)
+ const XGL_DYNAMIC_RS_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_RS_STATE_OBJECT* pState)
{
struct intel_dev *dev = intel_dev(device);
return intel_raster_state_create(dev, pCreateInfo,
- (struct intel_raster_state **) pState);
+ (struct intel_dynamic_rs **) pState);
}
-ICD_EXPORT XGL_RESULT XGLAPI xglCreateMsaaState(
+ICD_EXPORT XGL_RESULT XGLAPI xglCreateDynamicColorBlendState(
XGL_DEVICE device,
- const XGL_MSAA_STATE_CREATE_INFO* pCreateInfo,
- XGL_MSAA_STATE_OBJECT* pState)
-{
- struct intel_dev *dev = intel_dev(device);
-
- return intel_msaa_state_create(dev, pCreateInfo,
- (struct intel_msaa_state **) pState);
-}
-
-ICD_EXPORT XGL_RESULT XGLAPI xglCreateColorBlendState(
- XGL_DEVICE device,
- const XGL_COLOR_BLEND_STATE_CREATE_INFO* pCreateInfo,
- XGL_COLOR_BLEND_STATE_OBJECT* pState)
+ const XGL_DYNAMIC_CB_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_CB_STATE_OBJECT* pState)
{
struct intel_dev *dev = intel_dev(device);
return intel_blend_state_create(dev, pCreateInfo,
- (struct intel_blend_state **) pState);
+ (struct intel_dynamic_cb **) pState);
}
-ICD_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilState(
+ICD_EXPORT XGL_RESULT XGLAPI xglCreateDynamicDepthStencilState(
XGL_DEVICE device,
- const XGL_DEPTH_STENCIL_STATE_CREATE_INFO* pCreateInfo,
- XGL_DEPTH_STENCIL_STATE_OBJECT* pState)
+ const XGL_DYNAMIC_DS_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_DS_STATE_OBJECT* pState)
{
struct intel_dev *dev = intel_dev(device);
return intel_ds_state_create(dev, pCreateInfo,
- (struct intel_ds_state **) pState);
+ (struct intel_dynamic_ds **) pState);
}
diff --git a/icd/intel/state.h b/icd/intel/state.h
index 47a11f6..94140c7 100644
--- a/icd/intel/state.h
+++ b/icd/intel/state.h
@@ -33,11 +33,11 @@
/* Should we add intel_state back, as the base class for dynamic states? */
-struct intel_viewport_state {
+struct intel_dynamic_vp {
struct intel_obj obj;
XGL_UINT viewport_count;
- bool scissor_enable;
+ bool has_scissor_rects;
/* SF_CLIP_VIEWPORTs, CC_VIEWPORTs, and SCISSOR_RECTs */
uint32_t *cmd;
XGL_UINT cmd_len;
@@ -46,118 +46,79 @@
XGL_UINT cmd_scissor_rect_pos;
};
-struct intel_raster_state {
+struct intel_dynamic_rs {
struct intel_obj obj;
-
- uint32_t cmd_clip_cull;
- uint32_t cmd_sf_fill;
- uint32_t cmd_sf_cull;
- uint32_t cmd_depth_offset_const;
- uint32_t cmd_depth_offset_scale;
- uint32_t cmd_depth_offset_clamp;
+ XGL_DYNAMIC_RS_STATE_CREATE_INFO rs_info;
};
-struct intel_msaa_state {
+struct intel_dynamic_cb {
struct intel_obj obj;
-
- XGL_UINT sample_count;
-
- /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
- uint32_t cmd[6];
- XGL_UINT cmd_len;
+ XGL_DYNAMIC_CB_STATE_CREATE_INFO cb_info;
};
-struct intel_blend_state {
+struct intel_dynamic_ds {
struct intel_obj obj;
-
- /* a part of BLEND_STATE */
- uint32_t cmd_blend[XGL_MAX_COLOR_ATTACHMENTS];
- /* a part of COLOR_CALC_STATE */
- uint32_t cmd_blend_color[4];
+ XGL_DYNAMIC_DS_STATE_CREATE_INFO ds_info;
};
-struct intel_ds_state {
- struct intel_obj obj;
-
- /* DEPTH_STENCIL_STATE */
- uint32_t cmd[3];
- /* a part of COLOR_CALC_STATE */
- uint32_t cmd_stencil_ref;
-};
-
-static inline struct intel_viewport_state *intel_viewport_state(XGL_VIEWPORT_STATE_OBJECT state)
+static inline struct intel_dynamic_vp *intel_dynamic_vp(XGL_DYNAMIC_VP_STATE_OBJECT state)
{
- return (struct intel_viewport_state *) state;
+ return (struct intel_dynamic_vp *) state;
}
-static inline struct intel_viewport_state *intel_viewport_state_from_obj(struct intel_obj *obj)
+static inline struct intel_dynamic_vp *intel_viewport_state_from_obj(struct intel_obj *obj)
{
- return (struct intel_viewport_state *) obj;
+ return (struct intel_dynamic_vp *) obj;
}
-static inline struct intel_raster_state *intel_raster_state(XGL_RASTER_STATE_OBJECT state)
+static inline struct intel_dynamic_rs *intel_dynamic_rs(XGL_DYNAMIC_RS_STATE_OBJECT state)
{
- return (struct intel_raster_state *) state;
+ return (struct intel_dynamic_rs *) state;
}
-static inline struct intel_raster_state *intel_raster_state_from_obj(struct intel_obj *obj)
+static inline struct intel_dynamic_rs *intel_raster_state_from_obj(struct intel_obj *obj)
{
- return (struct intel_raster_state *) obj;
+ return (struct intel_dynamic_rs *) obj;
}
-static inline struct intel_msaa_state *intel_msaa_state(XGL_VIEWPORT_STATE_OBJECT state)
+static inline struct intel_dynamic_cb *intel_dynamic_cb(XGL_DYNAMIC_CB_STATE_OBJECT state)
{
- return (struct intel_msaa_state *) state;
+ return (struct intel_dynamic_cb *) state;
}
-static inline struct intel_msaa_state *intel_msaa_state_from_obj(struct intel_obj *obj)
+static inline struct intel_dynamic_cb *intel_blend_state_from_obj(struct intel_obj *obj)
{
- return (struct intel_msaa_state *) obj;
+ return (struct intel_dynamic_cb *) obj;
}
-static inline struct intel_blend_state *intel_blend_state(XGL_VIEWPORT_STATE_OBJECT state)
+static inline struct intel_dynamic_ds *intel_dynamic_ds(XGL_DYNAMIC_DS_STATE_OBJECT state)
{
- return (struct intel_blend_state *) state;
+ return (struct intel_dynamic_ds *) state;
}
-static inline struct intel_blend_state *intel_blend_state_from_obj(struct intel_obj *obj)
+static inline struct intel_dynamic_ds *intel_ds_state_from_obj(struct intel_obj *obj)
{
- return (struct intel_blend_state *) obj;
-}
-
-static inline struct intel_ds_state *intel_ds_state(XGL_VIEWPORT_STATE_OBJECT state)
-{
- return (struct intel_ds_state *) state;
-}
-
-static inline struct intel_ds_state *intel_ds_state_from_obj(struct intel_obj *obj)
-{
- return (struct intel_ds_state *) obj;
+ return (struct intel_dynamic_ds *) obj;
}
XGL_RESULT intel_viewport_state_create(struct intel_dev *dev,
- const XGL_VIEWPORT_STATE_CREATE_INFO *info,
- struct intel_viewport_state **state_ret);
-void intel_viewport_state_destroy(struct intel_viewport_state *state);
+ const XGL_DYNAMIC_VP_STATE_CREATE_INFO *info,
+ struct intel_dynamic_vp **state_ret);
+void intel_viewport_state_destroy(struct intel_dynamic_vp *state);
XGL_RESULT intel_raster_state_create(struct intel_dev *dev,
- const XGL_RASTER_STATE_CREATE_INFO *info,
- struct intel_raster_state **state_ret);
-void intel_raster_state_destroy(struct intel_raster_state *state);
-
-XGL_RESULT intel_msaa_state_create(struct intel_dev *dev,
- const XGL_MSAA_STATE_CREATE_INFO *info,
- struct intel_msaa_state **state_ret);
-void intel_msaa_state_destroy(struct intel_msaa_state *state);
+ const XGL_DYNAMIC_RS_STATE_CREATE_INFO *info,
+ struct intel_dynamic_rs **state_ret);
+void intel_raster_state_destroy(struct intel_dynamic_rs *state);
XGL_RESULT intel_blend_state_create(struct intel_dev *dev,
- const XGL_COLOR_BLEND_STATE_CREATE_INFO *info,
- struct intel_blend_state **state_ret);
-void intel_blend_state_destroy(struct intel_blend_state *state);
+ const XGL_DYNAMIC_CB_STATE_CREATE_INFO *info,
+ struct intel_dynamic_cb **state_ret);
+void intel_blend_state_destroy(struct intel_dynamic_cb *state);
XGL_RESULT intel_ds_state_create(struct intel_dev *dev,
- const XGL_DEPTH_STENCIL_STATE_CREATE_INFO *info,
- struct intel_ds_state **state_ret);
-void intel_ds_state_destroy(struct intel_ds_state *state);
+ const XGL_DYNAMIC_DS_STATE_CREATE_INFO *info,
+ struct intel_dynamic_ds **state_ret);
+void intel_ds_state_destroy(struct intel_dynamic_ds *state);
#endif /* STATE_H */
diff --git a/icd/intel/view.c b/icd/intel/view.c
index 9d235f4..c2c5585 100644
--- a/icd/intel/view.c
+++ b/icd/intel/view.c
@@ -1070,8 +1070,6 @@
const bool will_write = (buf->usage |
(XGL_BUFFER_USAGE_SHADER_ACCESS_WRITE_BIT &
XGL_BUFFER_USAGE_SHADER_ACCESS_ATOMIC_BIT));
- XGL_FORMAT format;
- XGL_GPU_SIZE stride;
struct intel_buf_view *view;
view = (struct intel_buf_view *) intel_base_create(dev, sizeof(*view),
diff --git a/icd/intel/wsi_x11.c b/icd/intel/wsi_x11.c
index c94d4f2..8c1afc8 100644
--- a/icd/intel/wsi_x11.c
+++ b/icd/intel/wsi_x11.c
@@ -522,6 +522,8 @@
mem_info.flags = 0;
mem_info.heapCount = 1;
mem_info.memPriority = XGL_MEMORY_PRIORITY_HIGH;
+ static XGL_UINT heapInfo[1];
+ mem_info.pHeaps = (const XGL_UINT *)&heapInfo;
ret = intel_mem_alloc(dev, &mem_info, &mem);
if (ret != XGL_SUCCESS) {
diff --git a/include/xgl.h b/include/xgl.h
index d68047a..5f90b43 100644
--- a/include/xgl.h
+++ b/include/xgl.h
@@ -92,12 +92,11 @@
XGL_DEFINE_SUBCLASS_HANDLE(XGL_PIPELINE_DELTA, XGL_OBJECT)
XGL_DEFINE_SUBCLASS_HANDLE(XGL_SAMPLER, XGL_OBJECT)
XGL_DEFINE_SUBCLASS_HANDLE(XGL_DESCRIPTOR_SET, XGL_OBJECT)
-XGL_DEFINE_SUBCLASS_HANDLE(XGL_STATE_OBJECT, XGL_OBJECT)
-XGL_DEFINE_SUBCLASS_HANDLE(XGL_VIEWPORT_STATE_OBJECT, XGL_STATE_OBJECT)
-XGL_DEFINE_SUBCLASS_HANDLE(XGL_RASTER_STATE_OBJECT, XGL_STATE_OBJECT)
-XGL_DEFINE_SUBCLASS_HANDLE(XGL_MSAA_STATE_OBJECT, XGL_STATE_OBJECT)
-XGL_DEFINE_SUBCLASS_HANDLE(XGL_COLOR_BLEND_STATE_OBJECT, XGL_STATE_OBJECT)
-XGL_DEFINE_SUBCLASS_HANDLE(XGL_DEPTH_STENCIL_STATE_OBJECT, XGL_STATE_OBJECT)
+XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_STATE_OBJECT, XGL_OBJECT)
+XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_VP_STATE_OBJECT, XGL_DYNAMIC_STATE_OBJECT)
+XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_RS_STATE_OBJECT, XGL_DYNAMIC_STATE_OBJECT)
+XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_CB_STATE_OBJECT, XGL_DYNAMIC_STATE_OBJECT)
+XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_DS_STATE_OBJECT, XGL_DYNAMIC_STATE_OBJECT)
XGL_DEFINE_SUBCLASS_HANDLE(XGL_CMD_BUFFER, XGL_OBJECT)
XGL_DEFINE_SUBCLASS_HANDLE(XGL_FENCE, XGL_OBJECT)
XGL_DEFINE_SUBCLASS_HANDLE(XGL_QUEUE_SEMAPHORE, XGL_OBJECT)
@@ -108,10 +107,6 @@
#define XGL_MAX_PHYSICAL_GPUS 16
#define XGL_MAX_PHYSICAL_GPU_NAME 256
-#define XGL_MAX_MEMORY_HEAPS 8
-#define XGL_MAX_DESCRIPTOR_SETS 2
-#define XGL_MAX_VIEWPORTS 16
-#define XGL_MAX_COLOR_ATTACHMENTS 8
#define XGL_LOD_CLAMP_NONE MAX_FLOAT
#define XGL_LAST_MIP_OR_SLICE 0xffffffff
@@ -343,12 +338,11 @@
{
XGL_STATE_BIND_VIEWPORT = 0x00000000,
XGL_STATE_BIND_RASTER = 0x00000001,
- XGL_STATE_BIND_DEPTH_STENCIL = 0x00000002,
- XGL_STATE_BIND_COLOR_BLEND = 0x00000003,
- XGL_STATE_BIND_MSAA = 0x00000004,
+ XGL_STATE_BIND_COLOR_BLEND = 0x00000002,
+ XGL_STATE_BIND_DEPTH_STENCIL = 0x00000003,
XGL_STATE_BIND_POINT_BEGIN_RANGE = XGL_STATE_BIND_VIEWPORT,
- XGL_STATE_BIND_POINT_END_RANGE = XGL_STATE_BIND_MSAA,
+ XGL_STATE_BIND_POINT_END_RANGE = XGL_STATE_BIND_DEPTH_STENCIL,
XGL_NUM_STATE_BIND_POINT = (XGL_STATE_BIND_POINT_END_RANGE - XGL_STATE_BIND_POINT_BEGIN_RANGE + 1),
XGL_MAX_ENUM(_XGL_STATE_BIND_POINT)
} XGL_STATE_BIND_POINT;
@@ -469,6 +463,39 @@
XGL_MAX_ENUM(_XGL_FACE_ORIENTATION)
} XGL_FACE_ORIENTATION;
+typedef enum _XGL_PROVOKING_VERTEX_CONVENTION
+{
+ XGL_PROVOKING_VERTEX_FIRST = 0x00000000,
+ XGL_PROVOKING_VERTEX_LAST = 0x00000001,
+
+ XGL_PROVOKING_VERTEX_BEGIN_RANGE = XGL_PROVOKING_VERTEX_FIRST,
+ XGL_PROVOKING_VERTEX_END_RANGE = XGL_PROVOKING_VERTEX_LAST,
+ XGL_NUM_PROVOKING_VERTEX_CONVENTION = (XGL_PROVOKING_VERTEX_END_RANGE - XGL_PROVOKING_VERTEX_BEGIN_RANGE + 1),
+ XGL_MAX_ENUM(_XGL_PROVOKING_VERTEX_CONVENTION)
+} XGL_PROVOKING_VERTEX_CONVENTION;
+
+typedef enum _XGL_COORDINATE_ORIGIN
+{
+ XGL_COORDINATE_ORIGIN_UPPER_LEFT = 0x00000000,
+ XGL_COORDINATE_ORIGIN_LOWER_LEFT = 0x00000001,
+
+ XGL_COORDINATE_ORIGIN_BEGIN_RANGE = XGL_COORDINATE_ORIGIN_UPPER_LEFT,
+ XGL_COORDINATE_ORIGIN_END_RANGE = XGL_COORDINATE_ORIGIN_LOWER_LEFT,
+ XGL_NUM_COORDINATE_ORIGIN = (XGL_COORDINATE_ORIGIN_END_RANGE - XGL_COORDINATE_ORIGIN_END_RANGE + 1),
+ XGL_MAX_ENUM(_XGL_COORDINATE_ORIGIN)
+} XGL_COORDINATE_ORIGIN;
+
+typedef enum _XGL_DEPTH_MODE
+{
+ XGL_DEPTH_MODE_ZERO_TO_ONE = 0x00000000,
+ XGL_DEPTH_MODE_NEGATIVE_ONE_TO_ONE = 0x00000001,
+
+ XGL_DEPTH_MODE_BEGIN_RANGE = XGL_DEPTH_MODE_ZERO_TO_ONE,
+ XGL_DEPTH_MODE_END_RANGE = XGL_DEPTH_MODE_NEGATIVE_ONE_TO_ONE,
+ XGL_NUM_DEPTH_MODE = (XGL_DEPTH_MODE_END_RANGE - XGL_DEPTH_MODE_BEGIN_RANGE + 1),
+ XGL_MAX_ENUM(_XGL_DEPTH_MODE)
+} XGL_DEPTH_MODE;
+
typedef enum _XGL_BLEND
{
XGL_BLEND_ZERO = 0x00000000,
@@ -802,17 +829,6 @@
XGL_MAX_ENUM(_XGL_NUM_FORMAT)
} XGL_NUM_FORMAT;
-typedef enum _XGL_PROVOKING_VERTEX_CONVENTION
-{
- XGL_PROVOKING_VERTEX_FIRST = 0,
- XGL_PROVOKING_VERTEX_LAST = 1,
-
- XGL_PROVOKING_VERTEX_BEGIN_RANGE = XGL_PROVOKING_VERTEX_FIRST,
- XGL_PROVOKING_VERTEX_END_RANGE = XGL_PROVOKING_VERTEX_LAST,
- XGL_NUM_PROVOKING_VERTEX_CONVENTIONS = (XGL_PROVOKING_VERTEX_END_RANGE - XGL_PROVOKING_VERTEX_BEGIN_RANGE + 1),
- XGL_MAX_ENUM(_XGL_PROVOKING_VERTEX_CONVENTION)
-} XGL_PROVOKING_VERTEX_CONVENTION;
-
// IMG CHANGE BEGIN - support for vertex input description
typedef enum _XGL_VERTEX_INPUT_STEP_RATE
{
@@ -870,10 +886,10 @@
XGL_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 13,
XGL_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 14,
XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO = 15,
- XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO = 16,
- XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO = 17,
- XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO = 18,
- XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO = 19,
+ XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO = 16,
+ XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO = 17,
+ XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO = 18,
+ XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO = 19,
XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO = 20,
XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO = 21,
XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO = 22,
@@ -882,12 +898,15 @@
XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 25,
XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 26,
XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 27,
- XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO = 28,
- XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO = 29,
- XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO = 30,
- XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO = 31,
- XGL_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO = 32,
- XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 33,
+ XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO = 28,
+ XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO = 29,
+ XGL_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO = 30,
+ XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO = 31,
+ XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO = 32,
+ XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO = 33,
+ XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO = 34,
+ XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO = 35,
+ XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 36,
XGL_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 37,
XGL_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 38,
XGL_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 39,
@@ -895,9 +914,6 @@
XGL_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO = 41,
XGL_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 42,
XGL_STRUCTURE_TYPE_LAYER_CREATE_INFO = 43,
-// IMG CHANGE BEGIN - support for vertex input description
- XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO = 90,
-// IMG CHANGE END
XGL_MAX_ENUM(_XGL_STRUCTURE_TYPE)
} XGL_STRUCTURE_TYPE;
@@ -1122,6 +1138,10 @@
XGL_UINT maxThreadGroupSize;
XGL_UINT64 timestampFrequency;
XGL_BOOL multiColorAttachmentClears;
+ XGL_UINT maxMemoryHeaps; // at least 8?
+ XGL_UINT maxDescriptorSets; // at least 2?
+ XGL_UINT maxViewports; // at least 16?
+ XGL_UINT maxColorAttachments; // at least 8?
} XGL_PHYSICAL_GPU_PROPERTIES;
typedef struct _XGL_PHYSICAL_GPU_PERFORMANCE
@@ -1229,7 +1249,7 @@
XGL_GPU_SIZE alignment;
XGL_FLAGS flags; // XGL_MEMORY_ALLOC_FLAGS
XGL_UINT heapCount;
- XGL_UINT heaps[XGL_MAX_MEMORY_HEAPS];
+ const XGL_UINT* pHeaps;
XGL_MEMORY_PRIORITY memPriority;
} XGL_MEMORY_ALLOC_INFO;
@@ -1253,7 +1273,7 @@
XGL_GPU_SIZE alignment; // Specified in bytes
XGL_GPU_SIZE granularity; // Granularity on which xglBindObjectMemoryRange can bind sub-ranges of memory specified in bytes (usually the page size)
XGL_UINT heapCount;
- XGL_UINT heaps[XGL_MAX_MEMORY_HEAPS];
+ XGL_UINT* pHeaps;
} XGL_MEMORY_REQUIREMENTS;
typedef struct _XGL_FORMAT_PROPERTIES
@@ -1498,7 +1518,8 @@
{
XGL_PIPELINE_SHADER_STAGE stage;
XGL_SHADER shader;
- XGL_DESCRIPTOR_SET_MAPPING descriptorSetMapping[XGL_MAX_DESCRIPTOR_SETS];
+ XGL_UINT descriptorSetMappingCount;
+ XGL_DESCRIPTOR_SET_MAPPING* pDescriptorSetMapping;
XGL_UINT linkConstBufferCount;
const XGL_LINK_CONST_BUFFER* pLinkConstBufferInfo;
XGL_DYNAMIC_BUFFER_VIEW_SLOT_INFO dynamicBufferViewMapping;
@@ -1565,10 +1586,9 @@
XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO
const XGL_VOID* pNext; // Pointer to next structure
XGL_PRIMITIVE_TOPOLOGY topology;
- XGL_BOOL disableVertexReuse;
- XGL_PROVOKING_VERTEX_CONVENTION provokingVertex;
+ XGL_BOOL disableVertexReuse; //optional
XGL_BOOL primitiveRestartEnable;
- XGL_UINT32 primitiveRestartIndex;
+ XGL_UINT32 primitiveRestartIndex; //optional (GL45)
} XGL_PIPELINE_IA_STATE_CREATE_INFO;
typedef struct _XGL_PIPELINE_TESS_STATE_CREATE_INFO
@@ -1580,19 +1600,51 @@
XGL_FLOAT fixedTessFactor;
} XGL_PIPELINE_TESS_STATE_CREATE_INFO;
+typedef struct _XGL_PIPELINE_VP_STATE_CREATE_INFO
+{
+ XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO
+ const void* pNext; // Pointer to next structure
+ XGL_UINT numViewports;
+ XGL_UINT scissorEnable;
+ XGL_COORDINATE_ORIGIN clipOrigin; // optional (GL45)
+ XGL_DEPTH_MODE depthMode; // optional (GL45)
+} XGL_PIPELINE_VP_STATE_CREATE_INFO;
+
typedef struct _XGL_PIPELINE_RS_STATE_CREATE_INFO
{
XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO
const XGL_VOID* pNext; // Pointer to next structure
XGL_BOOL depthClipEnable;
XGL_BOOL rasterizerDiscardEnable;
- XGL_FLOAT pointSize; // Size of points
+ XGL_BOOL programPointSize; // optional (GL45)
+ XGL_COORDINATE_ORIGIN pointOrigin; // optional (GL45)
+ XGL_PROVOKING_VERTEX_CONVENTION provokingVertex; // optional (GL45)
+ XGL_FILL_MODE fillMode; // optional (GL45)
+ XGL_CULL_MODE cullMode;
+ XGL_FACE_ORIENTATION frontFace;
} XGL_PIPELINE_RS_STATE_CREATE_INFO;
+typedef struct _XGL_PIPELINE_MS_STATE_CREATE_INFO
+{
+ XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO
+ const XGL_VOID* pNext; // Pointer to next structure
+ XGL_UINT samples;
+ XGL_BOOL multisampleEnable; // optional (GL45)
+ XGL_BOOL sampleShadingEnable; // optional (GL45)
+ XGL_FLOAT minSampleShading; // optional (GL45)
+ XGL_SAMPLE_MASK sampleMask;
+} XGL_PIPELINE_MS_STATE_CREATE_INFO;
+
typedef struct _XGL_PIPELINE_CB_ATTACHMENT_STATE
{
XGL_BOOL blendEnable;
XGL_FORMAT format;
+ XGL_BLEND srcBlendColor;
+ XGL_BLEND destBlendColor;
+ XGL_BLEND_FUNC blendFuncColor;
+ XGL_BLEND srcBlendAlpha;
+ XGL_BLEND destBlendAlpha;
+ XGL_BLEND_FUNC blendFuncAlpha;
XGL_UINT8 channelWriteMask;
} XGL_PIPELINE_CB_ATTACHMENT_STATE;
@@ -1601,17 +1653,35 @@
XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO
const XGL_VOID* pNext; // Pointer to next structure
XGL_BOOL alphaToCoverageEnable;
- XGL_BOOL dualSourceBlendEnable;
+ XGL_BOOL dualSourceBlendEnable; // optional (GL45)
+ XGL_BOOL logicOpEnable;
XGL_LOGIC_OP logicOp;
- XGL_PIPELINE_CB_ATTACHMENT_STATE attachment[XGL_MAX_COLOR_ATTACHMENTS];
-} XGL_PIPELINE_CB_STATE;
+ XGL_UINT attachmentCount; // # of pAttachments
+ XGL_PIPELINE_CB_ATTACHMENT_STATE* pAttachments;
+} XGL_PIPELINE_CB_STATE_CREATE_INFO;
-typedef struct _XGL_PIPELINE_DB_STATE_CREATE_INFO
+typedef struct _XGL_STENCIL_OP_STATE
{
- XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO
- const XGL_VOID* pNext; // Pointer to next structure
- XGL_FORMAT format;
-} XGL_PIPELINE_DB_STATE_CREATE_INFO;
+ XGL_STENCIL_OP stencilFailOp;
+ XGL_STENCIL_OP stencilPassOp;
+ XGL_STENCIL_OP stencilDepthFailOp;
+ XGL_COMPARE_FUNC stencilFunc;
+} XGL_STENCIL_OP_STATE;
+
+typedef struct _XGL_PIPELINE_DS_STATE_CREATE_INFO
+{
+ XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO
+ const void* pNext; // Pointer to next structure
+ XGL_FORMAT format;
+ XGL_BOOL depthTestEnable;
+ XGL_BOOL depthWriteEnable;
+ XGL_COMPARE_FUNC depthFunc;
+ XGL_BOOL depthBoundsEnable; // optional (depth_bounds_test)
+ XGL_BOOL stencilTestEnable;
+ XGL_STENCIL_OP_STATE front;
+ XGL_STENCIL_OP_STATE back;
+} XGL_PIPELINE_DS_STATE_CREATE_INFO;
+
typedef struct _XGL_PIPELINE_SHADER_STAGE_CREATE_INFO
{
@@ -1649,7 +1719,7 @@
{
XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO
const XGL_VOID* pNext; // Pointer to next structure
- XGL_UINT slots;
+ XGL_UINT slots;
} XGL_DESCRIPTOR_SET_CREATE_INFO;
typedef struct _XGL_DESCRIPTOR_SET_ATTACH_INFO
@@ -1658,25 +1728,27 @@
XGL_UINT slotOffset;
} XGL_DESCRIPTOR_SET_ATTACH_INFO;
-typedef struct _XGL_VIEWPORT_STATE_CREATE_INFO
+typedef struct _XGL_DYNAMIC_VP_STATE_CREATE_INFO
{
- XGL_UINT viewportCount;
- XGL_BOOL scissorEnable;
- XGL_VIEWPORT viewports[XGL_MAX_VIEWPORTS];
- XGL_RECT scissors[XGL_MAX_VIEWPORTS];
-} XGL_VIEWPORT_STATE_CREATE_INFO;
+ XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO
+ const void* pNext; // Pointer to next structure
+ XGL_UINT viewportCount; // number of entries in pViewports
+ XGL_VIEWPORT* pViewports;
+ XGL_UINT scissorCount; // number of entries in pScissors
+ XGL_RECT* pScissors;
+} XGL_DYNAMIC_VP_STATE_CREATE_INFO;
-typedef struct _XGL_RASTER_STATE_CREATE_INFO
+typedef struct _XGL_DYNAMIC_RS_STATE_CREATE_INFO
{
- XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO
+ XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO
const XGL_VOID* pNext; // Pointer to next structure
- XGL_FILL_MODE fillMode;
- XGL_CULL_MODE cullMode;
- XGL_FACE_ORIENTATION frontFace;
- XGL_INT depthBias;
+ XGL_FLOAT depthBias;
XGL_FLOAT depthBiasClamp;
XGL_FLOAT slopeScaledDepthBias;
-} XGL_RASTER_STATE_CREATE_INFO;
+ XGL_FLOAT pointSize; // optional (GL45) - Size of point
+ XGL_FLOAT pointFadeThreshold; // optional (GL45) - Size of point fade threshold
+ XGL_FLOAT lineWidth; // optional (GL45) - Width of lines
+} XGL_DYNAMIC_RS_STATE_CREATE_INFO;
typedef struct _XGL_MSAA_STATE_CREATE_INFO
{
@@ -1686,50 +1758,24 @@
XGL_SAMPLE_MASK sampleMask;
} XGL_MSAA_STATE_CREATE_INFO;
-typedef struct _XGL_COLOR_ATTACHMENT_BLEND_STATE
+typedef struct _XGL_DYNAMIC_CB_STATE_CREATE_INFO
{
- XGL_BOOL blendEnable;
- XGL_BLEND srcBlendColor;
- XGL_BLEND destBlendColor;
- XGL_BLEND_FUNC blendFuncColor;
- XGL_BLEND srcBlendAlpha;
- XGL_BLEND destBlendAlpha;
- XGL_BLEND_FUNC blendFuncAlpha;
-} XGL_COLOR_ATTACHMENT_BLEND_STATE;
-
-typedef struct _XGL_COLOR_BLEND_STATE_CREATE_INFO
-{
- XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO
+ XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO
const XGL_VOID* pNext; // Pointer to next structure
- XGL_COLOR_ATTACHMENT_BLEND_STATE attachment[XGL_MAX_COLOR_ATTACHMENTS];
XGL_FLOAT blendConst[4];
-} XGL_COLOR_BLEND_STATE_CREATE_INFO;
+} XGL_DYNAMIC_CB_STATE_CREATE_INFO;
-typedef struct _XGL_STENCIL_OP_STATE
+typedef struct _XGL_DYNAMIC_DS_STATE_CREATE_INFO
{
- XGL_STENCIL_OP stencilFailOp;
- XGL_STENCIL_OP stencilPassOp;
- XGL_STENCIL_OP stencilDepthFailOp;
- XGL_COMPARE_FUNC stencilFunc;
- XGL_UINT32 stencilRef;
-} XGL_STENCIL_OP_STATE;
-
-typedef struct _XGL_DEPTH_STENCIL_STATE_CREATE_INFO
-{
- XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO
+ XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO
const XGL_VOID* pNext; // Pointer to next structure
- XGL_BOOL depthTestEnable;
- XGL_BOOL depthWriteEnable;
- XGL_COMPARE_FUNC depthFunc;
- XGL_BOOL depthBoundsEnable;
- XGL_FLOAT minDepth;
- XGL_FLOAT maxDepth;
- XGL_BOOL stencilTestEnable;
+ XGL_FLOAT minDepth; // optional (depth_bounds_test)
+ XGL_FLOAT maxDepth; // optional (depth_bounds_test)
XGL_UINT32 stencilReadMask;
XGL_UINT32 stencilWriteMask;
- XGL_STENCIL_OP_STATE front;
- XGL_STENCIL_OP_STATE back;
-} XGL_DEPTH_STENCIL_STATE_CREATE_INFO;
+ XGL_UINT32 stencilFrontRef;
+ XGL_UINT32 stencilBackRef;
+} XGL_DYNAMIC_DS_STATE_CREATE_INFO;
typedef struct _XGL_CMD_BUFFER_CREATE_INFO
{
@@ -1949,18 +1995,17 @@
typedef XGL_VOID (XGLAPI *xglAttachBufferViewDescriptorsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_BUFFER_VIEW_ATTACH_INFO* pBufferViews);
typedef XGL_VOID (XGLAPI *xglAttachNestedDescriptorsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_DESCRIPTOR_SET_ATTACH_INFO* pNestedDescriptorSets);
typedef XGL_VOID (XGLAPI *xglClearDescriptorSetSlotsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount);
-typedef XGL_RESULT (XGLAPI *xglCreateViewportStateType)(XGL_DEVICE device, const XGL_VIEWPORT_STATE_CREATE_INFO* pCreateInfo, XGL_VIEWPORT_STATE_OBJECT* pState);
-typedef XGL_RESULT (XGLAPI *xglCreateRasterStateType)(XGL_DEVICE device, const XGL_RASTER_STATE_CREATE_INFO* pCreateInfo, XGL_RASTER_STATE_OBJECT* pState);
-typedef XGL_RESULT (XGLAPI *xglCreateMsaaStateType)(XGL_DEVICE device, const XGL_MSAA_STATE_CREATE_INFO* pCreateInfo, XGL_MSAA_STATE_OBJECT* pState);
-typedef XGL_RESULT (XGLAPI *xglCreateColorBlendStateType)(XGL_DEVICE device, const XGL_COLOR_BLEND_STATE_CREATE_INFO* pCreateInfo, XGL_COLOR_BLEND_STATE_OBJECT* pState);
-typedef XGL_RESULT (XGLAPI *xglCreateDepthStencilStateType)(XGL_DEVICE device, const XGL_DEPTH_STENCIL_STATE_CREATE_INFO* pCreateInfo, XGL_DEPTH_STENCIL_STATE_OBJECT* pState);
+typedef XGL_RESULT (XGLAPI *xglCreateDynamicViewportStateType)(XGL_DEVICE device, const XGL_DYNAMIC_VP_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_VP_STATE_OBJECT* pState);
+typedef XGL_RESULT (XGLAPI *xglCreateDynamicRasterStateType)(XGL_DEVICE device, const XGL_DYNAMIC_RS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_RS_STATE_OBJECT* pState);
+typedef XGL_RESULT (XGLAPI *xglCreateDynamicColorBlendStateType)(XGL_DEVICE device, const XGL_DYNAMIC_CB_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_CB_STATE_OBJECT* pState);
+typedef XGL_RESULT (XGLAPI *xglCreateDynamicDepthStencilStateType)(XGL_DEVICE device, const XGL_DYNAMIC_DS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_DS_STATE_OBJECT* pState);
typedef XGL_RESULT (XGLAPI *xglCreateCommandBufferType)(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo, XGL_CMD_BUFFER* pCmdBuffer);
typedef XGL_RESULT (XGLAPI *xglBeginCommandBufferType)(XGL_CMD_BUFFER cmdBuffer, const XGL_CMD_BUFFER_BEGIN_INFO* pBeginInfo);
typedef XGL_RESULT (XGLAPI *xglEndCommandBufferType)(XGL_CMD_BUFFER cmdBuffer);
typedef XGL_RESULT (XGLAPI *xglResetCommandBufferType)(XGL_CMD_BUFFER cmdBuffer);
typedef XGL_VOID (XGLAPI *xglCmdBindPipelineType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline);
typedef XGL_VOID (XGLAPI *xglCmdBindPipelineDeltaType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE_DELTA delta);
-typedef XGL_VOID (XGLAPI *xglCmdBindStateObjectType)(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_STATE_OBJECT state);
+typedef XGL_VOID (XGLAPI *xglCmdBindDynamicStateObjectType)(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT state);
typedef XGL_VOID (XGLAPI *xglCmdBindDescriptorSetType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT index, XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT slotOffset);
typedef XGL_VOID (XGLAPI *xglCmdBindDynamicBufferViewType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, const XGL_BUFFER_VIEW_ATTACH_INFO* pBufferView);
typedef XGL_VOID (XGLAPI *xglCmdBindVertexBufferType)(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, XGL_UINT binding);
@@ -2369,30 +2414,25 @@
// State object functions
-XGL_RESULT XGLAPI xglCreateViewportState(
+XGL_RESULT XGLAPI xglCreateDynamicViewportState(
XGL_DEVICE device,
- const XGL_VIEWPORT_STATE_CREATE_INFO* pCreateInfo,
- XGL_VIEWPORT_STATE_OBJECT* pState);
+ const XGL_DYNAMIC_VP_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_VP_STATE_OBJECT* pState);
-XGL_RESULT XGLAPI xglCreateRasterState(
+XGL_RESULT XGLAPI xglCreateDynamicRasterState(
XGL_DEVICE device,
- const XGL_RASTER_STATE_CREATE_INFO* pCreateInfo,
- XGL_RASTER_STATE_OBJECT* pState);
+ const XGL_DYNAMIC_RS_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_RS_STATE_OBJECT* pState);
-XGL_RESULT XGLAPI xglCreateMsaaState(
+XGL_RESULT XGLAPI xglCreateDynamicColorBlendState(
XGL_DEVICE device,
- const XGL_MSAA_STATE_CREATE_INFO* pCreateInfo,
- XGL_MSAA_STATE_OBJECT* pState);
+ const XGL_DYNAMIC_CB_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_CB_STATE_OBJECT* pState);
-XGL_RESULT XGLAPI xglCreateColorBlendState(
+XGL_RESULT XGLAPI xglCreateDynamicDepthStencilState(
XGL_DEVICE device,
- const XGL_COLOR_BLEND_STATE_CREATE_INFO* pCreateInfo,
- XGL_COLOR_BLEND_STATE_OBJECT* pState);
-
-XGL_RESULT XGLAPI xglCreateDepthStencilState(
- XGL_DEVICE device,
- const XGL_DEPTH_STENCIL_STATE_CREATE_INFO* pCreateInfo,
- XGL_DEPTH_STENCIL_STATE_OBJECT* pState);
+ const XGL_DYNAMIC_DS_STATE_CREATE_INFO* pCreateInfo,
+ XGL_DYNAMIC_DS_STATE_OBJECT* pState);
// Command buffer functions
@@ -2423,10 +2463,10 @@
XGL_PIPELINE_BIND_POINT pipelineBindPoint,
XGL_PIPELINE_DELTA delta);
-XGL_VOID XGLAPI xglCmdBindStateObject(
+XGL_VOID XGLAPI xglCmdBindDynamicStateObject(
XGL_CMD_BUFFER cmdBuffer,
XGL_STATE_BIND_POINT stateBindPoint,
- XGL_STATE_OBJECT state);
+ XGL_DYNAMIC_STATE_OBJECT dynamicState);
XGL_VOID XGLAPI xglCmdBindDescriptorSet(
XGL_CMD_BUFFER cmdBuffer,
diff --git a/include/xglLayer.h b/include/xglLayer.h
index 8c473ba..3803168 100644
--- a/include/xglLayer.h
+++ b/include/xglLayer.h
@@ -90,18 +90,17 @@
xglAttachBufferViewDescriptorsType AttachBufferViewDescriptors;
xglAttachNestedDescriptorsType AttachNestedDescriptors;
xglClearDescriptorSetSlotsType ClearDescriptorSetSlots;
- xglCreateViewportStateType CreateViewportState;
- xglCreateRasterStateType CreateRasterState;
- xglCreateMsaaStateType CreateMsaaState;
- xglCreateColorBlendStateType CreateColorBlendState;
- xglCreateDepthStencilStateType CreateDepthStencilState;
+ xglCreateDynamicViewportStateType CreateDynamicViewportState;
+ xglCreateDynamicRasterStateType CreateDynamicRasterState;
+ xglCreateDynamicColorBlendStateType CreateDynamicColorBlendState;
+ xglCreateDynamicDepthStencilStateType CreateDynamicDepthStencilState;
xglCreateCommandBufferType CreateCommandBuffer;
xglBeginCommandBufferType BeginCommandBuffer;
xglEndCommandBufferType EndCommandBuffer;
xglResetCommandBufferType ResetCommandBuffer;
xglCmdBindPipelineType CmdBindPipeline;
xglCmdBindPipelineDeltaType CmdBindPipelineDelta;
- xglCmdBindStateObjectType CmdBindStateObject;
+ xglCmdBindDynamicStateObjectType CmdBindDynamicStateObject;
xglCmdBindDescriptorSetType CmdBindDescriptorSet;
xglCmdBindDynamicBufferViewType CmdBindDynamicBufferView;
xglCmdBindVertexBufferType CmdBindVertexBuffer;
diff --git a/tests/image_tests.cpp b/tests/image_tests.cpp
index 221c60c..aefe657 100644
--- a/tests/image_tests.cpp
+++ b/tests/image_tests.cpp
@@ -201,13 +201,15 @@
// const XGL_MEMORY_ALLOC_INFO* pAllocInfo,
// XGL_GPU_MEMORY* pMem);
XGL_MEMORY_ALLOC_INFO mem_info;
+ XGL_UINT heapInfo[mem_req.heapCount];
memset(&mem_info, 0, sizeof(mem_info));
mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
mem_info.allocationSize = mem_req.size;
mem_info.alignment = mem_req.alignment;
mem_info.heapCount = mem_req.heapCount;
- memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS);
+ mem_info.pHeaps = heapInfo;
+ memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount);
mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
err = xglAllocMemory(device(), &mem_info, &m_image_mem);
diff --git a/tests/init.cpp b/tests/init.cpp
index 75ccd5e..a97283e 100644
--- a/tests/init.cpp
+++ b/tests/init.cpp
@@ -159,12 +159,14 @@
XGL_MEMORY_ALLOC_INFO alloc_info = {};
XGL_GPU_MEMORY gpu_mem;
XGL_UINT8 *pData;
+ XGL_UINT localHeap[1] = {0};
alloc_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
alloc_info.allocationSize = 1024 * 1024; // 1MB
alloc_info.alignment = 0;
alloc_info.heapCount = 1;
- alloc_info.heaps[0] = 0; // TODO: Reference other heaps
+ alloc_info.pHeaps = localHeap;
+
// TODO: Pick heap properties indicated by heap info
alloc_info.flags = XGL_MEMORY_HEAP_CPU_VISIBLE_BIT;
@@ -220,12 +222,14 @@
ASSERT_NE(0, mem_req.size) << "xglGetObjectInfo (Event): Failed - expect events to require memory";
+ XGL_UINT heapInfo[mem_req.heapCount];
memset(&mem_info, 0, sizeof(mem_info));
mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
mem_info.allocationSize = mem_req.size;
mem_info.alignment = mem_req.alignment;
mem_info.heapCount = mem_req.heapCount;
- memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS);
+ mem_info.pHeaps = heapInfo;
+ memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount);
mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
err = xglAllocMemory(device(), &mem_info, &event_mem);
@@ -352,13 +356,16 @@
XGL_MEMORY_ALLOC_INFO mem_info;
XGL_GPU_MEMORY query_mem;
+ XGL_UINT heapInfo[mem_req.heapCount];
+
memset(&mem_info, 0, sizeof(mem_info));
mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
// TODO: Is a simple multiple all that's needed here?
mem_info.allocationSize = mem_req.size * MAX_QUERY_SLOTS;
mem_info.alignment = mem_req.alignment;
mem_info.heapCount = mem_req.heapCount;
- memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS);
+ mem_info.pHeaps = heapInfo;
+ memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount);
mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
// TODO: are the flags right?
@@ -625,12 +632,14 @@
XGL_MEMORY_ALLOC_INFO mem_info;
XGL_GPU_MEMORY image_mem;
+ XGL_UINT heapInfo[mem_req.heapCount];
memset(&mem_info, 0, sizeof(mem_info));
mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
mem_info.allocationSize = mem_req.size;
mem_info.alignment = mem_req.alignment;
mem_info.heapCount = mem_req.heapCount;
- memcpy(mem_info.heaps, mem_req.heaps, sizeof(XGL_UINT)*XGL_MAX_MEMORY_HEAPS);
+ mem_info.pHeaps = heapInfo;
+ memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount);
mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT;
err = xglAllocMemory(device(), &mem_info, &image_mem);
diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp
index 3773263..fb54b69 100644
--- a/tests/render_tests.cpp
+++ b/tests/render_tests.cpp
@@ -266,7 +266,6 @@
cmdBuffer->BindStateObject(XGL_STATE_BIND_VIEWPORT, m_stateViewport);
cmdBuffer->BindStateObject(XGL_STATE_BIND_COLOR_BLEND, m_colorBlend);
cmdBuffer->BindStateObject(XGL_STATE_BIND_DEPTH_STENCIL, m_stateDepthStencil);
- cmdBuffer->BindStateObject(XGL_STATE_BIND_MSAA, m_stateMsaa);
pipelineobj->CreateXGLPipeline(descriptorSet);
cmdBuffer->BindPipeline(pipelineobj->GetPipelineHandle());
descriptorSet->CreateXGLDescriptorSet();
@@ -372,11 +371,13 @@
ASSERT_XGL_SUCCESS(err);
ASSERT_EQ(mem_reqs_size, sizeof(mem_reqs));
+ XGL_UINT heapInfo[mem_reqs.heapCount];
mem_alloc.allocationSize = mem_reqs.size;
mem_alloc.alignment = mem_reqs.alignment;
mem_alloc.heapCount = mem_reqs.heapCount;
- memcpy(mem_alloc.heaps, mem_reqs.heaps,
- sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount);
+ mem_alloc.pHeaps = heapInfo;
+ memcpy(heapInfo, mem_reqs.pHeaps,
+ sizeof(mem_reqs.pHeaps) * mem_reqs.heapCount);
/* allocate memory */
err = xglAllocMemory(device(), &mem_alloc, &m_depthStencilMem);
@@ -386,22 +387,17 @@
err = xglBindObjectMemory(m_depthStencilImage, m_depthStencilMem, 0);
ASSERT_XGL_SUCCESS(err);
- XGL_DEPTH_STENCIL_STATE_CREATE_INFO depthStencil = {};
- depthStencil.sType = XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO;
- depthStencil.depthTestEnable = XGL_TRUE;
- depthStencil.depthWriteEnable = XGL_TRUE;
- depthStencil.depthFunc = XGL_COMPARE_LESS_EQUAL;
- depthStencil.depthBoundsEnable = XGL_FALSE;
+ XGL_DYNAMIC_DS_STATE_CREATE_INFO depthStencil = {};
+ depthStencil.sType = XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO;
+
depthStencil.minDepth = 0.f;
depthStencil.maxDepth = 1.f;
- depthStencil.back.stencilDepthFailOp = XGL_STENCIL_OP_KEEP;
- depthStencil.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
- depthStencil.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
- depthStencil.back.stencilRef = 0x00;
- depthStencil.back.stencilFunc = XGL_COMPARE_ALWAYS;
- depthStencil.front = depthStencil.back;
+ depthStencil.stencilBackRef = 0;
+ depthStencil.stencilFrontRef = 0;
+ depthStencil.stencilReadMask = 0xff;
+ depthStencil.stencilWriteMask = 0xff;
- err = xglCreateDepthStencilState( device(), &depthStencil, &m_stateDepthStencil );
+ err = xglCreateDynamicDepthStencilState( device(), &depthStencil, &m_stateDepthStencil );
ASSERT_XGL_SUCCESS( err );
/* create image view */
@@ -858,7 +854,7 @@
att.blendEnable = XGL_FALSE;
att.format = m_render_target_fmt;
att.channelWriteMask = 0xf;
- pipelineobj.SetColorAttachment(1, &att);
+ pipelineobj.AddColorAttachment(1, &att);
XglCommandBufferObj cmdBuffer(m_device);
@@ -1762,6 +1758,21 @@
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
+ XGL_PIPELINE_DS_STATE_CREATE_INFO ds_state;
+ ds_state.depthTestEnable = XGL_TRUE;
+ ds_state.depthWriteEnable = XGL_TRUE;
+ ds_state.depthFunc = XGL_COMPARE_LESS_EQUAL;
+ ds_state.depthBoundsEnable = XGL_FALSE;
+ ds_state.stencilTestEnable = XGL_FALSE;
+ ds_state.back.stencilDepthFailOp = XGL_STENCIL_OP_KEEP;
+ ds_state.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
+ ds_state.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
+ ds_state.back.stencilFunc = XGL_COMPARE_ALWAYS;
+ ds_state.format.channelFormat = XGL_CH_FMT_R32;
+ ds_state.format.numericFormat = XGL_NUM_FMT_DS;
+ ds_state.front = ds_state.back;
+ pipelineobj.SetDepthStencil(&ds_state);
+
XglDescriptorSetObj descriptorSet(m_device);
descriptorSet.AttachBufferView(&MVPBuffer);
@@ -2617,6 +2628,21 @@
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
pipelineobj.AddVertexDataBuffer(&meshBuffer,0);
+ XGL_PIPELINE_DS_STATE_CREATE_INFO ds_state;
+ ds_state.depthTestEnable = XGL_TRUE;
+ ds_state.depthWriteEnable = XGL_TRUE;
+ ds_state.depthFunc = XGL_COMPARE_LESS_EQUAL;
+ ds_state.depthBoundsEnable = XGL_FALSE;
+ ds_state.stencilTestEnable = XGL_FALSE;
+ ds_state.back.stencilDepthFailOp = XGL_STENCIL_OP_KEEP;
+ ds_state.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
+ ds_state.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
+ ds_state.back.stencilFunc = XGL_COMPARE_ALWAYS;
+ ds_state.format.channelFormat = XGL_CH_FMT_R32;
+ ds_state.format.numericFormat = XGL_NUM_FMT_DS;
+ ds_state.front = ds_state.back;
+ pipelineobj.SetDepthStencil(&ds_state);
+
ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
diff --git a/tests/xglrenderframework.cpp b/tests/xglrenderframework.cpp
index c144ac4..ef1a949 100644
--- a/tests/xglrenderframework.cpp
+++ b/tests/xglrenderframework.cpp
@@ -33,7 +33,6 @@
m_colorBlend( XGL_NULL_HANDLE ),
m_stateViewport( XGL_NULL_HANDLE ),
m_stateDepthStencil( XGL_NULL_HANDLE ),
- m_stateMsaa( XGL_NULL_HANDLE ),
m_width( 256.0 ), // default window width
m_height( 256.0 ) // default window height
{
@@ -42,7 +41,6 @@
m_render_target_fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
m_render_target_fmt.numericFormat = XGL_NUM_FMT_UNORM;
- m_colorBindings[0].view = XGL_NULL_HANDLE;
m_depthStencilBinding.view = XGL_NULL_HANDLE;
}
@@ -67,7 +65,6 @@
void XglRenderFramework::ShutdownFramework()
{
if (m_colorBlend) xglDestroyObject(m_colorBlend);
- if (m_stateMsaa) xglDestroyObject(m_stateMsaa);
if (m_stateDepthStencil) xglDestroyObject(m_stateDepthStencil);
if (m_stateRaster) xglDestroyObject(m_stateRaster);
if (m_cmdBuffer) xglDestroyObject(m_cmdBuffer);
@@ -76,14 +73,6 @@
xglDestroyObject(m_stateViewport);
}
- for (XGL_UINT i = 0; i < m_renderTargetCount; i++) {
- if (m_renderTargets[i]) {
- // TODO: XglImage should be able to destroy itself
-// m_renderTarget->
-// xglDestroyObject(*m_renderTarget);
- }
- }
-
// reset the driver
delete m_device;
xglInitAndEnumerateGpus(&this->app_info, XGL_NULL_HANDLE, 0, &gpu_count, XGL_NULL_HANDLE);
@@ -97,43 +86,26 @@
m_render_target_fmt.numericFormat = XGL_NUM_FMT_UNORM;
// create a raster state (solid, back-face culling)
- XGL_RASTER_STATE_CREATE_INFO raster = {};
- raster.sType = XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO;
- raster.fillMode = XGL_FILL_SOLID;
- raster.cullMode = XGL_CULL_NONE;
- raster.frontFace = XGL_FRONT_FACE_CCW;
- err = xglCreateRasterState( device(), &raster, &m_stateRaster );
+ XGL_DYNAMIC_RS_STATE_CREATE_INFO raster = {};
+ raster.sType = XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO;
+ raster.pointSize = 1.0;
+
+ err = xglCreateDynamicRasterState( device(), &raster, &m_stateRaster );
ASSERT_XGL_SUCCESS(err);
- XGL_COLOR_BLEND_STATE_CREATE_INFO blend = {};
- blend.sType = XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO;
- err = xglCreateColorBlendState(device(), &blend, &m_colorBlend);
+ XGL_DYNAMIC_CB_STATE_CREATE_INFO blend = {};
+ blend.sType = XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO;
+ err = xglCreateDynamicColorBlendState(device(), &blend, &m_colorBlend);
ASSERT_XGL_SUCCESS( err );
- XGL_DEPTH_STENCIL_STATE_CREATE_INFO depthStencil = {};
- depthStencil.sType = XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO;
- depthStencil.depthTestEnable = XGL_FALSE;
- depthStencil.depthWriteEnable = XGL_FALSE;
- depthStencil.depthFunc = XGL_COMPARE_LESS_EQUAL;
- depthStencil.depthBoundsEnable = XGL_FALSE;
+ XGL_DYNAMIC_DS_STATE_CREATE_INFO depthStencil = {};
+ depthStencil.sType = XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO;
depthStencil.minDepth = 0.f;
depthStencil.maxDepth = 1.f;
- depthStencil.back.stencilDepthFailOp = XGL_STENCIL_OP_KEEP;
- depthStencil.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
- depthStencil.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
- depthStencil.back.stencilRef = 0x00;
- depthStencil.back.stencilFunc = XGL_COMPARE_ALWAYS;
- depthStencil.front = depthStencil.back;
+ depthStencil.stencilFrontRef = 0;
+ depthStencil.stencilBackRef = 0;
- err = xglCreateDepthStencilState( device(), &depthStencil, &m_stateDepthStencil );
- ASSERT_XGL_SUCCESS( err );
-
- XGL_MSAA_STATE_CREATE_INFO msaa = {};
- msaa.sType = XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO;
- msaa.sampleMask = 1;
- msaa.samples = 1;
-
- err = xglCreateMsaaState( device(), &msaa, &m_stateMsaa );
+ err = xglCreateDynamicDepthStencilState( device(), &depthStencil, &m_stateDepthStencil );
ASSERT_XGL_SUCCESS( err );
XGL_CMD_BUFFER_CREATE_INFO cmdInfo = {};
@@ -148,17 +120,21 @@
{
XGL_RESULT err;
- XGL_VIEWPORT_STATE_CREATE_INFO viewport = {};
- viewport.viewportCount = 1;
- viewport.scissorEnable = XGL_FALSE;
- viewport.viewports[0].originX = 0;
- viewport.viewports[0].originY = 0;
- viewport.viewports[0].width = 1.f * width;
- viewport.viewports[0].height = 1.f * height;
- viewport.viewports[0].minDepth = 0.f;
- viewport.viewports[0].maxDepth = 1.f;
+ XGL_VIEWPORT viewport;
- err = xglCreateViewportState( device(), &viewport, &m_stateViewport );
+ XGL_DYNAMIC_VP_STATE_CREATE_INFO viewportCreate = {};
+ viewportCreate.sType = XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO;
+ viewportCreate.viewportCount = 1;
+ viewportCreate.scissorCount = 0;
+ viewport.originX = 0;
+ viewport.originY = 0;
+ viewport.width = 1.f * width;
+ viewport.height = 1.f * height;
+ viewport.minDepth = 0.f;
+ viewport.maxDepth = 1.f;
+ viewportCreate.pViewports = &viewport;
+
+ err = xglCreateDynamicViewportState( device(), &viewportCreate, &m_stateViewport );
ASSERT_XGL_SUCCESS( err );
m_width = width;
m_height = height;
@@ -178,9 +154,9 @@
img->init(m_width, m_height, m_render_target_fmt,
XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT |
XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
- m_renderTargets[i] = img;
- m_colorBindings[i].view = m_renderTargets[i]->targetView();
+ m_colorBindings[i].view = img->targetView();
m_colorBindings[i].colorAttachmentState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL;
+ m_renderTargets.push_back(img);
}
// Create Framebuffer and RenderPass with color attachments and any depth/stencil attachment
XGL_ATTACHMENT_LOAD_OP load_op = XGL_ATTACHMENT_LOAD_OP_LOAD;
@@ -722,14 +698,16 @@
stageInfo->sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stageInfo->shader.stage = m_stage;
stageInfo->shader.shader = obj();
- stageInfo->shader.descriptorSetMapping[0].descriptorCount = 0;
+ stageInfo->shader.descriptorSetMappingCount = 1;
+ stageInfo->shader.pDescriptorSetMapping = (XGL_DESCRIPTOR_SET_MAPPING *)malloc(sizeof(XGL_DESCRIPTOR_SET_MAPPING));
+ stageInfo->shader.pDescriptorSetMapping->descriptorCount = 0;
stageInfo->shader.linkConstBufferCount = 0;
stageInfo->shader.pLinkConstBufferInfo = XGL_NULL_HANDLE;
stageInfo->shader.dynamicBufferViewMapping.slotObjectType = XGL_SLOT_UNUSED;
stageInfo->shader.dynamicBufferViewMapping.shaderEntityIndex = 0;
- stageInfo->shader.descriptorSetMapping[0].descriptorCount = descriptorSet->GetTotalSlots();
- if (stageInfo->shader.descriptorSetMapping[0].descriptorCount)
+ stageInfo->shader.pDescriptorSetMapping->descriptorCount = descriptorSet->GetTotalSlots();
+ if (stageInfo->shader.pDescriptorSetMapping->descriptorCount)
{
vector<int> allSlots;
vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> allTypes;
@@ -759,7 +737,7 @@
}
slotInfo = descriptorSet->GetSlotInfo(allSlots, allTypes, allObjs);
- stageInfo->shader.descriptorSetMapping[0].pDescriptorInfo = (const XGL_DESCRIPTOR_SLOT_INFO*) slotInfo;
+ stageInfo->shader.pDescriptorSetMapping[0].pDescriptorInfo = (const XGL_DESCRIPTOR_SLOT_INFO*) slotInfo;
}
return stageInfo;
}
@@ -841,7 +819,6 @@
m_ia_state.pNext = XGL_NULL_HANDLE;
m_ia_state.topology = XGL_TOPOLOGY_TRIANGLE_LIST;
m_ia_state.disableVertexReuse = XGL_FALSE;
- m_ia_state.provokingVertex = XGL_PROVOKING_VERTEX_LAST;
m_ia_state.primitiveRestartEnable = XGL_FALSE;
m_ia_state.primitiveRestartIndex = 0;
@@ -849,7 +826,10 @@
m_rs_state.pNext = &m_ia_state;
m_rs_state.depthClipEnable = XGL_FALSE;
m_rs_state.rasterizerDiscardEnable = XGL_FALSE;
- m_rs_state.pointSize = 1.0;
+ m_rs_state.provokingVertex = XGL_PROVOKING_VERTEX_LAST;
+ m_rs_state.fillMode = XGL_FILL_SOLID;
+ m_rs_state.cullMode = XGL_CULL_NONE;
+ m_rs_state.frontFace = XGL_FRONT_FACE_CCW;
memset(&m_cb_state,0,sizeof(m_cb_state));
m_cb_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO;
@@ -858,16 +838,35 @@
m_cb_state.dualSourceBlendEnable = XGL_FALSE;
m_cb_state.logicOp = XGL_LOGIC_OP_COPY;
- m_cb_state.attachment[0].blendEnable = XGL_FALSE;
- m_cb_state.attachment[0].format.channelFormat = XGL_CH_FMT_R8G8B8A8;
- m_cb_state.attachment[0].format.numericFormat = XGL_NUM_FMT_UNORM;
- m_cb_state.attachment[0].channelWriteMask = 0xF;
+ m_ms_state.pNext = &m_cb_state;
+ m_ms_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO;
+ m_ms_state.multisampleEnable = XGL_FALSE;
+ m_ms_state.sampleMask = 1; // Do we have to specify MSAA even just to disable it?
+ m_ms_state.samples = 1;
+ m_ms_state.minSampleShading = 0;
+ m_ms_state.sampleShadingEnable = 0;
- m_db_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO,
- m_db_state.pNext = &m_cb_state,
- m_db_state.format.channelFormat = XGL_CH_FMT_R32;
- m_db_state.format.numericFormat = XGL_NUM_FMT_DS;
+ m_ds_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO;
+ m_ds_state.pNext = &m_ms_state,
+ m_ds_state.format.channelFormat = XGL_CH_FMT_R32;
+ m_ds_state.format.numericFormat = XGL_NUM_FMT_DS;
+ m_ds_state.depthTestEnable = XGL_FALSE;
+ m_ds_state.depthWriteEnable = XGL_FALSE;
+ m_ds_state.depthBoundsEnable = XGL_FALSE;
+ m_ds_state.depthFunc = XGL_COMPARE_LESS_EQUAL;
+ m_ds_state.back.stencilDepthFailOp = XGL_STENCIL_OP_KEEP;
+ m_ds_state.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
+ m_ds_state.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
+ m_ds_state.back.stencilFunc = XGL_COMPARE_ALWAYS;
+ m_ds_state.stencilTestEnable = XGL_FALSE;
+ m_ds_state.front = m_ds_state.back;
+ XGL_PIPELINE_CB_ATTACHMENT_STATE att = {};
+ att.blendEnable = XGL_FALSE;
+ att.format.channelFormat = XGL_CH_FMT_R8G8B8A8;
+ att.format.numericFormat = XGL_NUM_FMT_UNORM;
+ att.channelWriteMask = 0xf;
+ AddColorAttachment(0, &att);
};
@@ -895,14 +894,30 @@
m_vertexBufferCount++;
}
-void XglPipelineObj::SetColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att)
+void XglPipelineObj::AddColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att)
{
- m_cb_state.attachment[binding] = *att;
+ if (binding+1 > m_colorAttachments.size())
+ {
+ m_colorAttachments.resize(binding+1);
+ }
+ m_colorAttachments[binding] = *att;
+}
+
+void XglPipelineObj::SetDepthStencil(XGL_PIPELINE_DS_STATE_CREATE_INFO *ds_state)
+{
+ m_ds_state.format = ds_state->format;
+ m_ds_state.depthTestEnable = ds_state->depthTestEnable;
+ m_ds_state.depthWriteEnable = ds_state->depthWriteEnable;
+ m_ds_state.depthBoundsEnable = ds_state->depthBoundsEnable;
+ m_ds_state.depthFunc = ds_state->depthFunc;
+ m_ds_state.stencilTestEnable = ds_state->stencilTestEnable;
+ m_ds_state.back = ds_state->back;
+ m_ds_state.front = ds_state->front;
}
void XglPipelineObj::CreateXGLPipeline(XglDescriptorSetObj *descriptorSet)
{
- XGL_VOID* head_ptr = &m_db_state;
+ XGL_VOID* head_ptr = &m_ds_state;
XGL_GRAPHICS_PIPELINE_CREATE_INFO info = {};
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* shaderCreateInfo;
@@ -925,6 +940,9 @@
info.pNext = head_ptr;
info.flags = 0;
+ m_cb_state.attachmentCount = m_colorAttachments.size();
+ m_cb_state.pAttachments = &m_colorAttachments[0];
+
init(*m_device, info);
}
@@ -935,7 +953,7 @@
void XglPipelineObj::BindPipelineCommandBuffer(XGL_CMD_BUFFER m_cmdBuffer, XglDescriptorSetObj *descriptorSet)
{
- XGL_VOID* head_ptr = &m_db_state;
+ XGL_VOID* head_ptr = &m_ds_state;
XGL_GRAPHICS_PIPELINE_CREATE_INFO info = {};
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* shaderCreateInfo;
@@ -1125,9 +1143,9 @@
}
}
-void XglCommandBufferObj::BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_STATE_OBJECT stateObject)
+void XglCommandBufferObj::BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT stateObject)
{
- xglCmdBindStateObject( obj(), stateBindPoint, stateObject);
+ xglCmdBindDynamicStateObject( obj(), stateBindPoint, stateObject);
}
void XglCommandBufferObj::AddRenderTarget(XglImage *renderTarget)
diff --git a/tests/xglrenderframework.h b/tests/xglrenderframework.h
index 421f79d..13f1eb7 100644
--- a/tests/xglrenderframework.h
+++ b/tests/xglrenderframework.h
@@ -64,24 +64,23 @@
protected:
- XGL_APPLICATION_INFO app_info;
- XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS];
- XGL_UINT gpu_count;
- XglDevice *m_device;
- XGL_CMD_BUFFER m_cmdBuffer;
- XGL_RENDER_PASS m_renderPass;
- XGL_MEMORY_REF m_memRefs[5];
- XGL_RASTER_STATE_OBJECT m_stateRaster;
- XGL_COLOR_BLEND_STATE_OBJECT m_colorBlend;
- XGL_VIEWPORT_STATE_OBJECT m_stateViewport;
- XGL_DEPTH_STENCIL_STATE_OBJECT m_stateDepthStencil;
- XGL_MSAA_STATE_OBJECT m_stateMsaa;
- XglImage *m_renderTargets[XGL_MAX_COLOR_ATTACHMENTS];
- XGL_UINT m_renderTargetCount;
- XGL_FLOAT m_width, m_height;
- XGL_FORMAT m_render_target_fmt;
- XGL_COLOR_ATTACHMENT_BIND_INFO m_colorBindings[XGL_MAX_COLOR_ATTACHMENTS];
- XGL_DEPTH_STENCIL_BIND_INFO m_depthStencilBinding;
+ XGL_APPLICATION_INFO app_info;
+ XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS];
+ XGL_UINT gpu_count;
+ XglDevice *m_device;
+ XGL_CMD_BUFFER m_cmdBuffer;
+ XGL_RENDER_PASS m_renderPass;
+ XGL_MEMORY_REF m_memRefs[5];
+ XGL_DYNAMIC_RS_STATE_OBJECT m_stateRaster;
+ XGL_DYNAMIC_CB_STATE_OBJECT m_colorBlend;
+ XGL_DYNAMIC_VP_STATE_OBJECT m_stateViewport;
+ XGL_DYNAMIC_DS_STATE_OBJECT m_stateDepthStencil;
+ vector<XglImage*> m_renderTargets;
+ XGL_UINT m_renderTargetCount;
+ XGL_FLOAT m_width, m_height;
+ XGL_FORMAT m_render_target_fmt;
+ XGL_COLOR_ATTACHMENT_BIND_INFO m_colorBindings[8];
+ XGL_DEPTH_STENCIL_BIND_INFO m_depthStencilBinding;
/*
* SetUp and TearDown are called by the Google Test framework
@@ -126,7 +125,7 @@
void BindDescriptorSet(XGL_DESCRIPTOR_SET descriptorSet);
void BindVertexBuffer(XglConstantBufferObj *vertexBuffer, XGL_UINT offset, XGL_UINT binding);
void BindIndexBuffer(XglIndexBufferObj *indexBuffer, XGL_UINT offset);
- void BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_STATE_OBJECT stateObject);
+ void BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT stateObject);
void Draw(XGL_UINT firstVertex, XGL_UINT vertexCount, XGL_UINT firstInstance, XGL_UINT instanceCount);
void DrawIndexed(XGL_UINT firstIndex, XGL_UINT indexCount, XGL_INT vertexOffset, XGL_UINT firstInstance, XGL_UINT instanceCount);
void QueueCommandBuffer(XGL_MEMORY_REF *memRefs, XGL_UINT32 numMemRefs);
@@ -316,7 +315,8 @@
void AddVertexInputAttribs(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* vi_attrib, int count);
void AddVertexInputBindings(XGL_VERTEX_INPUT_BINDING_DESCRIPTION* vi_binding, int count);
void AddVertexDataBuffer(XglConstantBufferObj* vertexDataBuffer, int binding);
- void SetColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att);
+ void AddColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att);
+ void SetDepthStencil(XGL_PIPELINE_DS_STATE_CREATE_INFO *);
void CreateXGLPipeline(XglDescriptorSetObj *descriptorSet);
XGL_PIPELINE GetPipelineHandle();
@@ -324,12 +324,14 @@
XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO m_vi_state;
XGL_PIPELINE_IA_STATE_CREATE_INFO m_ia_state;
XGL_PIPELINE_RS_STATE_CREATE_INFO m_rs_state;
- XGL_PIPELINE_CB_STATE m_cb_state;
- XGL_PIPELINE_DB_STATE_CREATE_INFO m_db_state;
+ XGL_PIPELINE_CB_STATE_CREATE_INFO m_cb_state;
+ XGL_PIPELINE_DS_STATE_CREATE_INFO m_ds_state;
+ XGL_PIPELINE_MS_STATE_CREATE_INFO m_ms_state;
XglDevice *m_device;
vector<XglShaderObj*> m_shaderObjs;
vector<XglConstantBufferObj*> m_vertexBufferObjs;
vector<int> m_vertexBufferBindings;
+ vector<XGL_PIPELINE_CB_ATTACHMENT_STATE> m_colorAttachments;
int m_vertexBufferCount;
};
diff --git a/tests/xgltestbinding.cpp b/tests/xgltestbinding.cpp
index b738734..3c2b386 100644
--- a/tests/xgltestbinding.cpp
+++ b/tests/xgltestbinding.cpp
@@ -260,21 +260,25 @@
const std::vector<XGL_MEMORY_REQUIREMENTS> mem_reqs = memory_requirements();
for (int i = 0; i < mem_reqs.size(); i++) {
XGL_MEMORY_ALLOC_INFO info = GpuMemory::alloc_info(mem_reqs[i]);
+ std::vector<uint32_t> heap_ids;
// prefer CPU visible heaps
std::vector<uint32_t> non_visible_heaps;
info.heapCount = 0;
for (uint32_t j = 0; j < mem_reqs[i].heapCount; j++) {
- const uint32_t heap = mem_reqs[i].heaps[j];
+ const uint32_t heap = mem_reqs[i].pHeaps[j];
const XGL_MEMORY_HEAP_PROPERTIES &props = dev.heap_properties()[heap];
if (props.flags & XGL_MEMORY_HEAP_CPU_VISIBLE_BIT)
- info.heaps[info.heapCount++] = heap;
+ heap_ids.push_back(heap);
else
non_visible_heaps.push_back(heap);
}
for (std::vector<uint32_t>::const_iterator it = non_visible_heaps.begin(); it != non_visible_heaps.end(); it++)
- info.heaps[info.heapCount++] = *it;
+ heap_ids.push_back(*it);
+
+ info.heapCount = heap_ids.size();
+ info.pHeaps = &heap_ids[0];
primary_mem_ = &internal_mems_[i];
@@ -408,8 +412,6 @@
uint32_t count;
if (!EXPECT(xglGetMemoryHeapCount(obj(), &count) == XGL_SUCCESS && count))
return;
- if (count > XGL_MAX_MEMORY_HEAPS)
- count = XGL_MAX_MEMORY_HEAPS;
heap_props_.reserve(count);
for (uint32_t i = 0; i < count; i++) {
@@ -789,33 +791,27 @@
xglAttachNestedDescriptors(obj(), start_slot, sets.size(), &sets[0]);
}
-void DynamicVpStateObject::init(const Device &dev, const XGL_VIEWPORT_STATE_CREATE_INFO &info)
+void DynamicVpStateObject::init(const Device &dev, const XGL_DYNAMIC_VP_STATE_CREATE_INFO &info)
{
- DERIVED_OBJECT_INIT(xglCreateViewportState, dev.obj(), &info);
+ DERIVED_OBJECT_INIT(xglCreateDynamicViewportState, dev.obj(), &info);
alloc_memory(dev);
}
-void DynamicRsStateObject::init(const Device &dev, const XGL_RASTER_STATE_CREATE_INFO &info)
+void DynamicRsStateObject::init(const Device &dev, const XGL_DYNAMIC_RS_STATE_CREATE_INFO &info)
{
- DERIVED_OBJECT_INIT(xglCreateRasterState, dev.obj(), &info);
+ DERIVED_OBJECT_INIT(xglCreateDynamicRasterState, dev.obj(), &info);
alloc_memory(dev);
}
-void DynamicMsaaStateObject::init(const Device &dev, const XGL_MSAA_STATE_CREATE_INFO &info)
+void DynamicCbStateObject::init(const Device &dev, const XGL_DYNAMIC_CB_STATE_CREATE_INFO &info)
{
- DERIVED_OBJECT_INIT(xglCreateMsaaState, dev.obj(), &info);
+ DERIVED_OBJECT_INIT(xglCreateDynamicColorBlendState, dev.obj(), &info);
alloc_memory(dev);
}
-void DynamicCbStateObject::init(const Device &dev, const XGL_COLOR_BLEND_STATE_CREATE_INFO &info)
+void DynamicDsStateObject::init(const Device &dev, const XGL_DYNAMIC_DS_STATE_CREATE_INFO &info)
{
- DERIVED_OBJECT_INIT(xglCreateColorBlendState, dev.obj(), &info);
- alloc_memory(dev);
-}
-
-void DynamicDsStateObject::init(const Device &dev, const XGL_DEPTH_STENCIL_STATE_CREATE_INFO &info)
-{
- DERIVED_OBJECT_INIT(xglCreateDepthStencilState, dev.obj(), &info);
+ DERIVED_OBJECT_INIT(xglCreateDynamicDepthStencilState, dev.obj(), &info);
alloc_memory(dev);
}
diff --git a/tests/xgltestbinding.h b/tests/xgltestbinding.h
index a06ba16..88f15ae 100644
--- a/tests/xgltestbinding.h
+++ b/tests/xgltestbinding.h
@@ -171,11 +171,11 @@
class DynamicStateObject : public Object {
public:
- const XGL_STATE_OBJECT &obj() const { return reinterpret_cast<const XGL_STATE_OBJECT &>(Object::obj()); }
+ const XGL_DYNAMIC_STATE_OBJECT &obj() const { return reinterpret_cast<const XGL_DYNAMIC_STATE_OBJECT &>(Object::obj()); }
protected:
explicit DynamicStateObject() {}
- explicit DynamicStateObject(XGL_STATE_OBJECT obj) : Object(obj) {}
+ explicit DynamicStateObject(XGL_DYNAMIC_STATE_OBJECT obj) : Object(obj) {}
};
template<typename T, class C>
@@ -542,34 +542,28 @@
XGL_DESCRIPTOR_SET_CREATE_INFO info_;
};
-class DynamicVpStateObject : public DerivedObject<XGL_VIEWPORT_STATE_OBJECT, DynamicStateObject> {
+class DynamicVpStateObject : public DerivedObject<XGL_DYNAMIC_VP_STATE_OBJECT, DynamicStateObject> {
public:
- // xglCreateViewportState()
- void init(const Device &dev, const XGL_VIEWPORT_STATE_CREATE_INFO &info);
+ // xglCreateDynamicViewportState()
+ void init(const Device &dev, const XGL_DYNAMIC_VP_STATE_CREATE_INFO &info);
};
-class DynamicRsStateObject : public DerivedObject<XGL_RASTER_STATE_OBJECT, DynamicStateObject> {
+class DynamicRsStateObject : public DerivedObject<XGL_DYNAMIC_RS_STATE_OBJECT, DynamicStateObject> {
public:
- // xglCreateRasterState()
- void init(const Device &dev, const XGL_RASTER_STATE_CREATE_INFO &info);
+ // xglCreateDynamicRasterState()
+ void init(const Device &dev, const XGL_DYNAMIC_RS_STATE_CREATE_INFO &info);
};
-class DynamicMsaaStateObject : public DerivedObject<XGL_MSAA_STATE_OBJECT, DynamicStateObject> {
+class DynamicCbStateObject : public DerivedObject<XGL_DYNAMIC_CB_STATE_OBJECT, DynamicStateObject> {
public:
- // xglCreateMsaaState()
- void init(const Device &dev, const XGL_MSAA_STATE_CREATE_INFO &info);
+ // xglCreateDynamicColorBlendState()
+ void init(const Device &dev, const XGL_DYNAMIC_CB_STATE_CREATE_INFO &info);
};
-class DynamicCbStateObject : public DerivedObject<XGL_COLOR_BLEND_STATE_OBJECT, DynamicStateObject> {
+class DynamicDsStateObject : public DerivedObject<XGL_DYNAMIC_DS_STATE_OBJECT, DynamicStateObject> {
public:
- // xglCreateColorBlendState()
- void init(const Device &dev, const XGL_COLOR_BLEND_STATE_CREATE_INFO &info);
-};
-
-class DynamicDsStateObject : public DerivedObject<XGL_DEPTH_STENCIL_STATE_OBJECT, DynamicStateObject> {
-public:
- // xglCreateDepthStencilState()
- void init(const Device &dev, const XGL_DEPTH_STENCIL_STATE_CREATE_INFO &info);
+ // xglCreateDynamicDepthStencilState()
+ void init(const Device &dev, const XGL_DYNAMIC_DS_STATE_CREATE_INFO &info);
};
class CmdBuffer : public DerivedObject<XGL_CMD_BUFFER, Object> {
@@ -616,8 +610,7 @@
info.allocationSize = reqs.size;
info.alignment = reqs.alignment;
info.heapCount = reqs.heapCount;
- for (int i = 0; i < reqs.heapCount; i++)
- info.heaps[i] = reqs.heaps[i];
+ info.pHeaps = reqs.pHeaps;
info.memPriority = XGL_MEMORY_PRIORITY_NORMAL;
return info;
}
diff --git a/xgl-layer-generate.py b/xgl-layer-generate.py
index e5656db..85c4a81 100755
--- a/xgl-layer-generate.py
+++ b/xgl-layer-generate.py
@@ -558,11 +558,11 @@
"XGL_IMAGE_VIEW" : "XGL_OBJECT_TYPE_IMAGE_VIEW",
"XGL_COLOR_ATTACHMENT_VIEW" : "XGL_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW",
"XGL_DEPTH_STENCIL_VIEW" : "XGL_OBJECT_TYPE_DEPTH_STENCIL_VIEW",
- "XGL_VIEWPORT_STATE_OBJECT" : "XGL_OBJECT_TYPE_VIEWPORT_STATE",
- "XGL_RASTER_STATE_OBJECT" : "XGL_OBJECT_TYPE_RASTER_STATE",
+ "XGL_DYNAMIC_VP_STATE_OBJECT" : "XGL_OBJECT_TYPE_VIEWPORT_STATE",
+ "XGL_DYNAMIC_RS_STATE_OBJECT" : "XGL_OBJECT_TYPE_RASTER_STATE",
"XGL_MSAA_STATE_OBJECT" : "XGL_OBJECT_TYPE_MSAA_STATE",
- "XGL_COLOR_BLEND_STATE_OBJECT" : "XGL_OBJECT_TYPE_COLOR_BLEND_STATE",
- "XGL_DEPTH_STENCIL_STATE_OBJECT" : "XGL_OBJECT_TYPE_DEPTH_STENCIL_STATE",
+ "XGL_DYNAMIC_CB_STATE_OBJECT" : "XGL_OBJECT_TYPE_COLOR_BLEND_STATE",
+ "XGL_DYNAMIC_DS_STATE_OBJECT" : "XGL_OBJECT_TYPE_DEPTH_STENCIL_STATE",
"XGL_BASE_OBJECT" : "ll_get_obj_type(object)",
"XGL_OBJECT" : "ll_get_obj_type(object)"
}
diff --git a/xgl.py b/xgl.py
index ef59f80..996f84c 100644
--- a/xgl.py
+++ b/xgl.py
@@ -200,12 +200,11 @@
"XGL_PIPELINE_DELTA",
"XGL_SAMPLER",
"XGL_DESCRIPTOR_SET",
- "XGL_STATE_OBJECT",
- "XGL_VIEWPORT_STATE_OBJECT",
- "XGL_RASTER_STATE_OBJECT",
- "XGL_MSAA_STATE_OBJECT",
- "XGL_COLOR_BLEND_STATE_OBJECT",
- "XGL_DEPTH_STENCIL_STATE_OBJECT",
+ "XGL_DYNAMIC_STATE_OBJECT",
+ "XGL_DYNAMIC_VP_STATE_OBJECT",
+ "XGL_DYNAMIC_RS_STATE_OBJECT",
+ "XGL_DYNAMIC_CB_STATE_OBJECT",
+ "XGL_DYNAMIC_DS_STATE_OBJECT",
"XGL_CMD_BUFFER",
"XGL_FENCE",
"XGL_QUEUE_SEMAPHORE",
@@ -542,30 +541,25 @@
Param("XGL_UINT", "startSlot"),
Param("XGL_UINT", "slotCount")]),
- Proto("XGL_RESULT", "CreateViewportState",
+ Proto("XGL_RESULT", "CreateDynamicViewportState",
[Param("XGL_DEVICE", "device"),
- Param("const XGL_VIEWPORT_STATE_CREATE_INFO*", "pCreateInfo"),
- Param("XGL_VIEWPORT_STATE_OBJECT*", "pState")]),
+ Param("const XGL_DYNAMIC_VP_STATE_CREATE_INFO*", "pCreateInfo"),
+ Param("XGL_DYNAMIC_VP_STATE_OBJECT*", "pState")]),
- Proto("XGL_RESULT", "CreateRasterState",
+ Proto("XGL_RESULT", "CreateDynamicRasterState",
[Param("XGL_DEVICE", "device"),
- Param("const XGL_RASTER_STATE_CREATE_INFO*", "pCreateInfo"),
- Param("XGL_RASTER_STATE_OBJECT*", "pState")]),
+ Param("const XGL_DYNAMIC_RS_STATE_CREATE_INFO*", "pCreateInfo"),
+ Param("XGL_DYNAMIC_RS_STATE_OBJECT*", "pState")]),
- Proto("XGL_RESULT", "CreateMsaaState",
+ Proto("XGL_RESULT", "CreateDynamicColorBlendState",
[Param("XGL_DEVICE", "device"),
- Param("const XGL_MSAA_STATE_CREATE_INFO*", "pCreateInfo"),
- Param("XGL_MSAA_STATE_OBJECT*", "pState")]),
+ Param("const XGL_DYNAMIC_CB_STATE_CREATE_INFO*", "pCreateInfo"),
+ Param("XGL_DYNAMIC_CB_STATE_OBJECT*", "pState")]),
- Proto("XGL_RESULT", "CreateColorBlendState",
+ Proto("XGL_RESULT", "CreateDynamicDepthStencilState",
[Param("XGL_DEVICE", "device"),
- Param("const XGL_COLOR_BLEND_STATE_CREATE_INFO*", "pCreateInfo"),
- Param("XGL_COLOR_BLEND_STATE_OBJECT*", "pState")]),
-
- Proto("XGL_RESULT", "CreateDepthStencilState",
- [Param("XGL_DEVICE", "device"),
- Param("const XGL_DEPTH_STENCIL_STATE_CREATE_INFO*", "pCreateInfo"),
- Param("XGL_DEPTH_STENCIL_STATE_OBJECT*", "pState")]),
+ Param("const XGL_DYNAMIC_DS_STATE_CREATE_INFO*", "pCreateInfo"),
+ Param("XGL_DYNAMIC_DS_STATE_OBJECT*", "pState")]),
Proto("XGL_RESULT", "CreateCommandBuffer",
[Param("XGL_DEVICE", "device"),
@@ -592,10 +586,10 @@
Param("XGL_PIPELINE_BIND_POINT", "pipelineBindPoint"),
Param("XGL_PIPELINE_DELTA", "delta")]),
- Proto("XGL_VOID", "CmdBindStateObject",
+ Proto("XGL_VOID", "CmdBindDynamicStateObject",
[Param("XGL_CMD_BUFFER", "cmdBuffer"),
Param("XGL_STATE_BIND_POINT", "stateBindPoint"),
- Param("XGL_STATE_OBJECT", "state")]),
+ Param("XGL_DYNAMIC_STATE_OBJECT", "state")]),
Proto("XGL_VOID", "CmdBindDescriptorSet",
[Param("XGL_CMD_BUFFER", "cmdBuffer"),