2018-10-15 23:37:09 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include "kernel/vc4_packet.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetViewport
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
void rpi_vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports)
|
2018-10-15 23:37:09 +02:00
|
|
|
{
|
2018-10-21 14:33:02 +02:00
|
|
|
assert(commandBuffer);
|
|
|
|
assert(firstViewport == 0);
|
|
|
|
assert(viewportCount == 1);
|
|
|
|
assert(pViewports);
|
|
|
|
|
|
|
|
//only 1 viewport is supported
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
cb->viewport = pViewports[0];
|
|
|
|
|
|
|
|
cb->viewportDirty = 1;
|
2018-10-15 23:37:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetScissor
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
void rpi_vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors)
|
2018-10-15 23:37:09 +02:00
|
|
|
{
|
2018-10-21 14:33:02 +02:00
|
|
|
assert(commandBuffer);
|
|
|
|
assert(firstScissor == 0);
|
|
|
|
assert(scissorCount == 1);
|
|
|
|
assert(pScissors);
|
|
|
|
|
|
|
|
//only 1 scissor supported
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
cb->scissor = pScissors[0];
|
|
|
|
|
|
|
|
cb->scissorDirty = 1;
|
2018-10-15 23:37:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdBindVertexBuffers
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
void rpi_vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets)
|
2018-10-15 23:37:09 +02:00
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
|
|
|
|
for(int c = 0; c < bindingCount; ++c)
|
|
|
|
{
|
|
|
|
cb->vertexBuffers[firstBinding + c] = pBuffers[c];
|
|
|
|
cb->vertexBufferOffsets[firstBinding + c] = pOffsets[c];
|
|
|
|
}
|
2018-10-21 14:33:02 +02:00
|
|
|
|
|
|
|
cb->vertexBufferDirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdClearColorImage
|
|
|
|
* Color and depth/stencil images can be cleared outside a render pass instance using vkCmdClearColorImage or vkCmdClearDepthStencilImage, respectively.
|
|
|
|
* These commands are only allowed outside of a render pass instance.
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdClearColorImage(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkImage image,
|
|
|
|
VkImageLayout imageLayout,
|
|
|
|
const VkClearColorValue* pColor,
|
|
|
|
uint32_t rangeCount,
|
|
|
|
const VkImageSubresourceRange* pRanges)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
assert(image);
|
|
|
|
assert(pColor);
|
|
|
|
|
|
|
|
//TODO this should only flag an image for clearing. This can only be called outside a renderpass
|
|
|
|
//actual clearing would only happen:
|
|
|
|
// -if image is rendered to (insert clear before first draw call)
|
|
|
|
// -if the image is bound for sampling (submit a CL with a clear)
|
|
|
|
// -if a command buffer is submitted without any rendering (insert clear)
|
|
|
|
// -etc.
|
|
|
|
//we shouldn't clear an image if noone uses it
|
|
|
|
|
|
|
|
//TODO ranges support
|
|
|
|
|
|
|
|
assert(imageLayout == VK_IMAGE_LAYOUT_GENERAL ||
|
|
|
|
imageLayout == VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR ||
|
|
|
|
imageLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
|
|
|
|
|
|
|
assert(commandBuffer->state == CMDBUF_STATE_RECORDING);
|
|
|
|
assert(_queueFamilyProperties[commandBuffer->cp->queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT || _queueFamilyProperties[commandBuffer->cp->queueFamilyIndex].queueFlags & VK_QUEUE_COMPUTE_BIT);
|
|
|
|
|
|
|
|
_image* i = image;
|
|
|
|
|
|
|
|
assert(i->usageBits & VK_IMAGE_USAGE_TRANSFER_DST_BIT);
|
|
|
|
|
2019-09-02 23:37:42 +02:00
|
|
|
{ //Simplest case: just submit a job to clear the image
|
|
|
|
clFit(commandBuffer, &commandBuffer->binCl, sizeof(CLMarker));
|
2020-03-01 20:11:31 +01:00
|
|
|
clInsertNewCLMarker(&commandBuffer->binCl, &commandBuffer->handlesCl, &commandBuffer->shaderRecCl, commandBuffer->shaderRecCount, &commandBuffer->uniformsCl);
|
|
|
|
commandBuffer->binCl.currMarker->writeImage = i;
|
2019-09-01 20:14:47 +02:00
|
|
|
|
2019-09-02 23:37:42 +02:00
|
|
|
//insert reloc for render target
|
|
|
|
clFit(commandBuffer, &commandBuffer->handlesCl, 4);
|
|
|
|
clGetHandleIndex(&commandBuffer->handlesCl, commandBuffer->binCl.currMarker->handlesBuf, commandBuffer->binCl.currMarker->handlesSize, i->boundMem->bo);
|
2019-09-01 20:14:47 +02:00
|
|
|
|
|
|
|
clFit(commandBuffer, &commandBuffer->binCl, V3D21_TILE_BINNING_MODE_CONFIGURATION_length);
|
|
|
|
clInsertTileBinningModeConfiguration(&commandBuffer->binCl,
|
|
|
|
0, //double buffer in non ms mode
|
|
|
|
0, //tile allocation block size
|
|
|
|
0, //tile allocation initial block size
|
|
|
|
0, //auto initialize tile state data array
|
|
|
|
getFormatBpp(i->format) == 64, //64 bit color mode
|
|
|
|
i->samples > 1, //msaa
|
|
|
|
i->width, i->height,
|
|
|
|
0, //tile state data array address
|
|
|
|
0, //tile allocation memory size
|
|
|
|
0); //tile allocation memory address
|
|
|
|
|
|
|
|
//START_TILE_BINNING resets the statechange counters in the hardware,
|
|
|
|
//which are what is used when a primitive is binned to a tile to
|
|
|
|
//figure out what new state packets need to be written to that tile's
|
|
|
|
//command list.
|
|
|
|
clFit(commandBuffer, &commandBuffer->binCl, V3D21_START_TILE_BINNING_length);
|
|
|
|
clInsertStartTileBinning(&commandBuffer->binCl);
|
|
|
|
|
2019-09-02 23:37:42 +02:00
|
|
|
//Increment the semaphore indicating that binning is done and
|
|
|
|
//unblocking the render thread. Note that this doesn't act
|
|
|
|
//until the FLUSH completes.
|
|
|
|
//The FLUSH caps all of our bin lists with a
|
|
|
|
//VC4_PACKET_RETURN.
|
2019-09-01 20:14:47 +02:00
|
|
|
clFit(commandBuffer, &commandBuffer->binCl, V3D21_INCREMENT_SEMAPHORE_length);
|
|
|
|
clInsertIncrementSemaphore(&commandBuffer->binCl);
|
|
|
|
clFit(commandBuffer, &commandBuffer->binCl, V3D21_FLUSH_length);
|
|
|
|
clInsertFlush(&commandBuffer->binCl);
|
2019-09-02 23:37:42 +02:00
|
|
|
|
2020-02-25 22:18:14 +01:00
|
|
|
commandBuffer->binCl.currMarker->clearColor[0] = commandBuffer->binCl.currMarker->clearColor[1] = packVec4IntoABGR8(pColor->float32);
|
2019-09-02 23:37:42 +02:00
|
|
|
commandBuffer->binCl.currMarker->flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR;
|
2020-03-11 21:42:46 +01:00
|
|
|
|
|
|
|
commandBuffer->binCl.currMarker->width = i->width;
|
|
|
|
commandBuffer->binCl.currMarker->height = i->height;
|
2019-09-01 20:14:47 +02:00
|
|
|
}
|
2018-10-21 14:33:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdClearDepthStencilImage
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdClearDepthStencilImage(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkImage image,
|
|
|
|
VkImageLayout imageLayout,
|
|
|
|
const VkClearDepthStencilValue* pDepthStencil,
|
|
|
|
uint32_t rangeCount,
|
|
|
|
const VkImageSubresourceRange* pRanges)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
assert(image);
|
|
|
|
assert(pDepthStencil);
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdClearAttachments
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdClearAttachments(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
uint32_t attachmentCount,
|
|
|
|
const VkClearAttachment* pAttachments,
|
|
|
|
uint32_t rectCount,
|
|
|
|
const VkClearRect* pRects)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
assert(pAttachments);
|
|
|
|
assert(pRects);
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdFillBuffer
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdFillBuffer(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkBuffer dstBuffer,
|
|
|
|
VkDeviceSize dstOffset,
|
|
|
|
VkDeviceSize size,
|
|
|
|
uint32_t data)
|
|
|
|
{
|
|
|
|
//TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdUpdateBuffer
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdUpdateBuffer(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkBuffer dstBuffer,
|
|
|
|
VkDeviceSize dstOffset,
|
|
|
|
VkDeviceSize dataSize,
|
|
|
|
const void* pData)
|
|
|
|
{
|
|
|
|
//TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdBindIndexBuffer
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdBindIndexBuffer(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkBuffer buffer,
|
|
|
|
VkDeviceSize offset,
|
|
|
|
VkIndexType indexType)
|
|
|
|
{
|
2019-09-23 20:40:36 +02:00
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
if(indexType == VK_INDEX_TYPE_UINT32)
|
|
|
|
{
|
|
|
|
UNSUPPORTED(VK_INDEX_TYPE_UINT32);
|
|
|
|
}
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
|
|
|
|
cb->indexBuffer = buffer;
|
|
|
|
cb->indexBufferOffset = offset;
|
|
|
|
|
|
|
|
cb->indexBufferDirty = 1;
|
2018-10-21 14:33:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetLineWidth
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetLineWidth(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
float lineWidth)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
cb->lineWidth = lineWidth;
|
|
|
|
|
|
|
|
cb->lineWidthDirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetDepthBias
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetDepthBias(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
float depthBiasConstantFactor,
|
|
|
|
float depthBiasClamp,
|
|
|
|
float depthBiasSlopeFactor)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
cb->depthBiasConstantFactor = depthBiasConstantFactor;
|
|
|
|
cb->depthBiasClamp = depthBiasClamp;
|
|
|
|
cb->depthBiasSlopeFactor = depthBiasSlopeFactor;
|
|
|
|
|
|
|
|
cb->depthBiasDirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetBlendConstants
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetBlendConstants(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
const float blendConstants[4])
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
memcpy(cb->blendConstants, blendConstants, 4 * sizeof(float));
|
|
|
|
|
|
|
|
cb->blendConstantsDirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetDepthBounds
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetDepthBounds(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
float minDepthBounds,
|
|
|
|
float maxDepthBounds)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
cb->minDepthBounds = minDepthBounds;
|
|
|
|
cb->maxDepthBounds = maxDepthBounds;
|
|
|
|
|
|
|
|
cb->depthBoundsDirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetStencilCompareMask
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetStencilCompareMask(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkStencilFaceFlags faceMask,
|
|
|
|
uint32_t compareMask)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
|
|
|
|
if(faceMask & VK_STENCIL_FACE_FRONT_BIT)
|
|
|
|
{
|
|
|
|
cb->stencilCompareMask[0] = compareMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(faceMask & VK_STENCIL_FACE_BACK_BIT)
|
|
|
|
{
|
|
|
|
cb->stencilCompareMask[1] = compareMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
cb->stencilCompareMaskDirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetStencilWriteMask
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetStencilWriteMask(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkStencilFaceFlags faceMask,
|
|
|
|
uint32_t writeMask)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
|
|
|
|
if(faceMask & VK_STENCIL_FACE_FRONT_BIT)
|
|
|
|
{
|
|
|
|
cb->stencilWriteMask[0] = writeMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(faceMask & VK_STENCIL_FACE_BACK_BIT)
|
|
|
|
{
|
|
|
|
cb->stencilWriteMask[1] = writeMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
cb->stencilWriteMaskDirty = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#vkCmdSetStencilReference
|
|
|
|
*/
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdSetStencilReference(
|
2018-10-21 14:33:02 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkStencilFaceFlags faceMask,
|
|
|
|
uint32_t reference)
|
|
|
|
{
|
|
|
|
assert(commandBuffer);
|
|
|
|
|
|
|
|
_commandBuffer* cb = commandBuffer;
|
|
|
|
|
|
|
|
if(faceMask & VK_STENCIL_FACE_FRONT_BIT)
|
|
|
|
{
|
|
|
|
cb->stencilReference[0] = reference;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(faceMask & VK_STENCIL_FACE_BACK_BIT)
|
|
|
|
{
|
|
|
|
cb->stencilReference[1] = reference;
|
|
|
|
}
|
|
|
|
|
|
|
|
cb->stencilReferenceDirty = 1;
|
2018-10-15 23:37:09 +02:00
|
|
|
}
|