}
static void cmd_memory_barriers(struct intel_cmd *cmd,
- uint32_t flush_flags,
+ uint32_t flush_flags,
uint32_t memory_barrier_count,
- const void* memory_barriers)
+ const void** memory_barriers)
{
uint32_t i;
- XGL_MEMORY_BARRIER *memory_barrier;
- XGL_BUFFER_MEMORY_BARRIER *buffer_memory_barrier;
- XGL_IMAGE_MEMORY_BARRIER *image_memory_barrier;
XGL_FLAGS input_mask = 0;
XGL_FLAGS output_mask = 0;
for (i = 0; i < memory_barrier_count; i++) {
- memory_barrier = &((XGL_MEMORY_BARRIER *) memory_barriers)[i];
- switch(memory_barrier->sType)
+
+ const union {
+ XGL_STRUCTURE_TYPE type;
+
+ XGL_MEMORY_BARRIER mem;
+ XGL_BUFFER_MEMORY_BARRIER buf;
+ XGL_IMAGE_MEMORY_BARRIER img;
+ } *u = memory_barriers[i];
+
+ switch(u->type)
{
case XGL_STRUCTURE_TYPE_MEMORY_BARRIER:
- output_mask |= memory_barrier->outputMask;
- input_mask |= memory_barrier->inputMask;
+ output_mask |= u->mem.outputMask;
+ input_mask |= u->mem.inputMask;
break;
case XGL_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER:
- buffer_memory_barrier = (XGL_BUFFER_MEMORY_BARRIER *) memory_barrier;
- output_mask |= buffer_memory_barrier->outputMask;
- input_mask |= buffer_memory_barrier->inputMask;
+ output_mask |= u->buf.outputMask;
+ input_mask |= u->buf.inputMask;
break;
case XGL_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER:
- image_memory_barrier = (XGL_IMAGE_MEMORY_BARRIER *) memory_barrier;
- output_mask |= image_memory_barrier->outputMask;
- input_mask |= image_memory_barrier->inputMask;
+ output_mask |= u->img.outputMask;
+ input_mask |= u->img.inputMask;
{
- struct intel_img *img = intel_img(image_memory_barrier->image);
+ struct intel_img *img = intel_img(u->img.image);
flush_flags |= cmd_get_flush_flags(cmd,
- img_get_layout_caches(img, image_memory_barrier->oldLayout),
- img_get_layout_caches(img, image_memory_barrier->newLayout),
+ img_get_layout_caches(img, u->img.oldLayout),
+ img_get_layout_caches(img, u->img.newLayout),
icd_format_is_ds(img->layout.format));
}
break;
// is this necessary?
XGL_BUFFER_MEMORY_BARRIER memory_barrier = bufs[0].buffer_memory_barrier(
XGL_MEMORY_OUTPUT_COPY_BIT, XGL_MEMORY_INPUT_COPY_BIT, 0, 4);
+ XGL_BUFFER_MEMORY_BARRIER *pmemory_barrier = &memory_barrier;
XGL_SET_EVENT set_events[] = { XGL_SET_EVENT_TRANSFER_COMPLETE };
XGL_PIPELINE_BARRIER pipeline_barrier = {};
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = 1;
- pipeline_barrier.pMemBarriers = &memory_barrier;
+ pipeline_barrier.pMemBarriers = (const void **)&pmemory_barrier;
xglCmdPipelineBarrier(cmd_.obj(), &pipeline_barrier);
XGL_BUFFER_COPY region = {};
memory_barrier = bufs[1].buffer_memory_barrier(
XGL_MEMORY_OUTPUT_COPY_BIT, XGL_MEMORY_INPUT_COPY_BIT, 0, 4);
+ pmemory_barrier = &memory_barrier;
pipeline_barrier.sType = XGL_STRUCTURE_TYPE_PIPELINE_BARRIER;
pipeline_barrier.eventCount = 1;
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = 1;
- pipeline_barrier.pMemBarriers = &memory_barrier;
+ pipeline_barrier.pMemBarriers = (const void **)&pmemory_barrier;
xglCmdPipelineBarrier(cmd_.obj(), &pipeline_barrier);
xglCmdCopyBuffer(cmd_.obj(), bufs[1].obj(), bufs[2].obj(), 1, ®ion);
memory_barrier = bufs[1].buffer_memory_barrier(
XGL_MEMORY_OUTPUT_COPY_BIT, XGL_MEMORY_INPUT_CPU_READ_BIT, 0, 4);
+ pmemory_barrier = &memory_barrier;
XGL_EVENT_WAIT_INFO wait_info = {};
wait_info.sType = XGL_STRUCTURE_TYPE_EVENT_WAIT_INFO;
wait_info.eventCount = 1;
wait_info.pEvents = &event;
wait_info.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
wait_info.memBarrierCount = 1;
- wait_info.pMemBarriers = &memory_barrier;
+ wait_info.pMemBarriers = (const void **)&pmemory_barrier;
xglCmdWaitEvents(cmd_.obj(), &wait_info);
cmd_.end();
XGL_MEMORY_INPUT_COPY_BIT;
std::vector<XGL_IMAGE_MEMORY_BARRIER> to_clear;
+ std::vector<XGL_IMAGE_MEMORY_BARRIER *> p_to_clear;
std::vector<XGL_IMAGE_MEMORY_BARRIER> to_xfer;
+ std::vector<XGL_IMAGE_MEMORY_BARRIER *> p_to_xfer;
for (std::vector<XGL_IMAGE_SUBRESOURCE_RANGE>::const_iterator it = ranges.begin();
it != ranges.end(); it++) {
XGL_IMAGE_LAYOUT_GENERAL,
XGL_IMAGE_LAYOUT_CLEAR_OPTIMAL,
*it));
+ p_to_clear.push_back(&to_clear.back());
to_xfer.push_back(img.image_memory_barrier(all_cache_outputs, all_cache_inputs,
XGL_IMAGE_LAYOUT_CLEAR_OPTIMAL,
XGL_IMAGE_LAYOUT_TRANSFER_SOURCE_OPTIMAL, *it));
+ p_to_xfer.push_back(&to_xfer.back());
}
cmd_.begin();
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = to_clear.size();
- pipeline_barrier.pMemBarriers = &to_clear[0];
+ pipeline_barrier.pMemBarriers = (const void **)&p_to_clear[0];
xglCmdPipelineBarrier(cmd_.obj(), &pipeline_barrier);
if (test_raw_) {
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = to_xfer.size();
- pipeline_barrier.pMemBarriers = &to_xfer[0];
+ pipeline_barrier.pMemBarriers = (const void **)&p_to_xfer[0];
xglCmdPipelineBarrier(cmd_.obj(), &pipeline_barrier);
cmd_.end();
XGL_MEMORY_INPUT_COPY_BIT;
std::vector<XGL_IMAGE_MEMORY_BARRIER> to_clear;
+ std::vector<XGL_IMAGE_MEMORY_BARRIER *> p_to_clear;
std::vector<XGL_IMAGE_MEMORY_BARRIER> to_xfer;
+ std::vector<XGL_IMAGE_MEMORY_BARRIER *> p_to_xfer;
for (std::vector<XGL_IMAGE_SUBRESOURCE_RANGE>::const_iterator it = ranges.begin();
it != ranges.end(); it++) {
XGL_IMAGE_LAYOUT_GENERAL,
XGL_IMAGE_LAYOUT_CLEAR_OPTIMAL,
*it));
+ p_to_clear.push_back(&to_clear.back());
to_xfer.push_back(img.image_memory_barrier(all_cache_outputs, all_cache_inputs,
XGL_IMAGE_LAYOUT_CLEAR_OPTIMAL,
XGL_IMAGE_LAYOUT_TRANSFER_SOURCE_OPTIMAL, *it));
+ p_to_xfer.push_back(&to_xfer.back());
}
cmd_.begin();
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = to_clear.size();
- pipeline_barrier.pMemBarriers = &to_clear[0];
+ pipeline_barrier.pMemBarriers = (const void **)&p_to_clear[0];
xglCmdPipelineBarrier(cmd_.obj(), &pipeline_barrier);
xglCmdClearDepthStencil(cmd_.obj(), img.obj(), depth, stencil, ranges.size(), &ranges[0]);
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = to_xfer.size();
- pipeline_barrier.pMemBarriers = &to_xfer[0];
+ pipeline_barrier.pMemBarriers = (const void **)&p_to_xfer[0];
xglCmdPipelineBarrier(cmd_.obj(), &pipeline_barrier);
cmd_.end();
XGL_BUFFER_MEMORY_BARRIER memory_barrier =
buffer_memory_barrier(outputMask, inputMask, 0, m_numVertices * m_stride);
+ XGL_BUFFER_MEMORY_BARRIER *pmemory_barrier = &memory_barrier;
XGL_SET_EVENT set_events[] = { XGL_SET_EVENT_GPU_COMMANDS_COMPLETE };
XGL_PIPELINE_BARRIER pipeline_barrier = {};
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = 1;
- pipeline_barrier.pMemBarriers = &memory_barrier;
+ pipeline_barrier.pMemBarriers = (const void **)&pmemory_barrier;
// write barrier to the command buffer
m_commandBuffer->PipelineBarrier(&pipeline_barrier);
memory_barrier.inputMask = input_mask;
memory_barrier.newLayout = XGL_IMAGE_LAYOUT_CLEAR_OPTIMAL;
memory_barrier.subresourceRange = srRange;
+ XGL_IMAGE_MEMORY_BARRIER *pmemory_barrier = &memory_barrier;
XGL_SET_EVENT set_events[] = { XGL_SET_EVENT_GPU_COMMANDS_COMPLETE };
XGL_PIPELINE_BARRIER pipeline_barrier = {};
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = 1;
- pipeline_barrier.pMemBarriers = &memory_barrier;
+ pipeline_barrier.pMemBarriers = (const void **)&pmemory_barrier;
// clear the back buffer to dark grey
uint32_t clearColor[4] = {64, 64, 64, 0};
memory_barrier.inputMask = input_mask;
memory_barrier.newLayout = XGL_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
memory_barrier.subresourceRange = srRange;
+ XGL_IMAGE_MEMORY_BARRIER *pmemory_barrier = &memory_barrier;
XGL_SET_EVENT set_events[] = { XGL_SET_EVENT_GPU_COMMANDS_COMPLETE };
XGL_PIPELINE_BARRIER pipeline_barrier = {};
pipeline_barrier.pEvents = set_events;
pipeline_barrier.waitEvent = XGL_WAIT_EVENT_TOP_OF_PIPE;
pipeline_barrier.memBarrierCount = 1;
- pipeline_barrier.pMemBarriers = &memory_barrier;
+ pipeline_barrier.pMemBarriers = (const void **)&pmemory_barrier;
for(i=0; i<m_renderTargetCount; i++)
{