forked from MoonsideGames/Refresh
Compare commits
No commits in common. "2087ecbd8757b492e45fb9aacbe0a5e4095da7dd" and "528abfad760c4b04f020c5ca65177e95a2fdd266" have entirely different histories.
2087ecbd87
...
528abfad76
|
@ -446,6 +446,12 @@ typedef struct Refresh_ColorAttachmentBlendState
|
||||||
Refresh_ColorComponentFlags colorWriteMask;
|
Refresh_ColorComponentFlags colorWriteMask;
|
||||||
} Refresh_ColorAttachmentBlendState;
|
} Refresh_ColorAttachmentBlendState;
|
||||||
|
|
||||||
|
typedef struct Refresh_ComputePipelineLayoutCreateInfo
|
||||||
|
{
|
||||||
|
uint32_t bufferBindingCount;
|
||||||
|
uint32_t imageBindingCount;
|
||||||
|
} Refresh_ComputePipelineLayoutCreateInfo;
|
||||||
|
|
||||||
typedef struct Refresh_ShaderModuleCreateInfo
|
typedef struct Refresh_ShaderModuleCreateInfo
|
||||||
{
|
{
|
||||||
size_t codeSize;
|
size_t codeSize;
|
||||||
|
@ -754,11 +760,6 @@ REFRESHAPI Refresh_Buffer* Refresh_CreateBuffer(
|
||||||
/* Setters */
|
/* Setters */
|
||||||
|
|
||||||
/* Uploads image data to a texture object.
|
/* Uploads image data to a texture object.
|
||||||
*
|
|
||||||
* NOTE:
|
|
||||||
* DO NOT expect this to execute in sequence relative to other commands!
|
|
||||||
* Calling SetTextureData in a command buffer that also references the
|
|
||||||
* texture may result in undefined behavior.
|
|
||||||
*
|
*
|
||||||
* textureSlice: The texture slice to be updated.
|
* textureSlice: The texture slice to be updated.
|
||||||
* data: A pointer to the image data.
|
* data: A pointer to the image data.
|
||||||
|
@ -1035,9 +1036,7 @@ REFRESHAPI void Refresh_SetScissor(
|
||||||
Refresh_Rect *scissor
|
Refresh_Rect *scissor
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Binds vertex buffers for use with subsequent draw calls.
|
/* Binds vertex buffers for use with subsequent draw calls. */
|
||||||
* Note that this may only be called after binding a graphics pipeline.
|
|
||||||
*/
|
|
||||||
REFRESHAPI void Refresh_BindVertexBuffers(
|
REFRESHAPI void Refresh_BindVertexBuffers(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
|
|
|
@ -2672,6 +2672,11 @@ static void VULKAN_INTERNAL_BufferMemoryBarrier(
|
||||||
VulkanResourceAccessType prevAccess, nextAccess;
|
VulkanResourceAccessType prevAccess, nextAccess;
|
||||||
const VulkanResourceAccessInfo *prevAccessInfo, *nextAccessInfo;
|
const VulkanResourceAccessInfo *prevAccessInfo, *nextAccessInfo;
|
||||||
|
|
||||||
|
if (buffer->resourceAccessType == nextResourceAccessType)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memoryBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
memoryBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||||
memoryBarrier.pNext = NULL;
|
memoryBarrier.pNext = NULL;
|
||||||
memoryBarrier.srcAccessMask = 0;
|
memoryBarrier.srcAccessMask = 0;
|
||||||
|
@ -2746,6 +2751,11 @@ static void VULKAN_INTERNAL_ImageMemoryBarrier(
|
||||||
VulkanResourceAccessType prevAccess;
|
VulkanResourceAccessType prevAccess;
|
||||||
const VulkanResourceAccessInfo *pPrevAccessInfo, *pNextAccessInfo;
|
const VulkanResourceAccessInfo *pPrevAccessInfo, *pNextAccessInfo;
|
||||||
|
|
||||||
|
if (*resourceAccessType == nextAccess)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
memoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
memoryBarrier.pNext = NULL;
|
memoryBarrier.pNext = NULL;
|
||||||
memoryBarrier.srcAccessMask = 0;
|
memoryBarrier.srcAccessMask = 0;
|
||||||
|
@ -3826,7 +3836,8 @@ static void VULKAN_INTERNAL_BindUniformBuffer(
|
||||||
|
|
||||||
static uint8_t VULKAN_INTERNAL_CreateUniformBuffer(
|
static uint8_t VULKAN_INTERNAL_CreateUniformBuffer(
|
||||||
VulkanRenderer *renderer,
|
VulkanRenderer *renderer,
|
||||||
VulkanUniformBufferPool *bufferPool
|
VulkanUniformBufferPool *bufferPool,
|
||||||
|
VkDeviceSize blockSize
|
||||||
) {
|
) {
|
||||||
VulkanResourceAccessType resourceAccessType;
|
VulkanResourceAccessType resourceAccessType;
|
||||||
VkDescriptorSetLayout descriptorSetLayout;
|
VkDescriptorSetLayout descriptorSetLayout;
|
||||||
|
@ -4032,7 +4043,7 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_AcquireUniformBufferFromPool(
|
||||||
|
|
||||||
if (bufferPool->availableBufferCount == 0)
|
if (bufferPool->availableBufferCount == 0)
|
||||||
{
|
{
|
||||||
if (!VULKAN_INTERNAL_CreateUniformBuffer(renderer, bufferPool))
|
if (!VULKAN_INTERNAL_CreateUniformBuffer(renderer, bufferPool, blockSize))
|
||||||
{
|
{
|
||||||
SDL_UnlockMutex(bufferPool->lock);
|
SDL_UnlockMutex(bufferPool->lock);
|
||||||
Refresh_LogError("Failed to create uniform buffer!");
|
Refresh_LogError("Failed to create uniform buffer!");
|
||||||
|
@ -6844,6 +6855,12 @@ static void VULKAN_SetTextureData(
|
||||||
uint32_t bufferRowLength;
|
uint32_t bufferRowLength;
|
||||||
uint32_t bufferImageHeight;
|
uint32_t bufferImageHeight;
|
||||||
|
|
||||||
|
if (vulkanCommandBuffer->renderPassInProgress)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Cannot perform buffer updates mid-render pass!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
||||||
renderer,
|
renderer,
|
||||||
vulkanCommandBuffer,
|
vulkanCommandBuffer,
|
||||||
|
@ -7337,6 +7354,12 @@ static void VULKAN_SetBufferData(
|
||||||
VkBufferCopy bufferCopy;
|
VkBufferCopy bufferCopy;
|
||||||
VulkanResourceAccessType accessType = vulkanBuffer->resourceAccessType;
|
VulkanResourceAccessType accessType = vulkanBuffer->resourceAccessType;
|
||||||
|
|
||||||
|
if (vulkanCommandBuffer->renderPassInProgress)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Cannot perform buffer updates mid-render pass!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer(
|
||||||
renderer,
|
renderer,
|
||||||
vulkanCommandBuffer,
|
vulkanCommandBuffer,
|
||||||
|
@ -7464,6 +7487,18 @@ static uint32_t VULKAN_PushFragmentShaderUniforms(
|
||||||
VulkanGraphicsPipeline* graphicsPipeline = vulkanCommandBuffer->currentGraphicsPipeline;
|
VulkanGraphicsPipeline* graphicsPipeline = vulkanCommandBuffer->currentGraphicsPipeline;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
|
|
||||||
|
if (graphicsPipeline == NULL)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Cannot push uniforms if a pipeline is not bound!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (graphicsPipeline->fragmentUniformBlockSize == 0)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Bound pipeline's fragment stage does not declare uniforms!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
vulkanCommandBuffer->fragmentUniformBuffer->offset +
|
vulkanCommandBuffer->fragmentUniformBuffer->offset +
|
||||||
graphicsPipeline->fragmentUniformBlockSize >=
|
graphicsPipeline->fragmentUniformBlockSize >=
|
||||||
|
@ -7506,6 +7541,18 @@ static uint32_t VULKAN_PushComputeShaderUniforms(
|
||||||
VulkanComputePipeline* computePipeline = vulkanCommandBuffer->currentComputePipeline;
|
VulkanComputePipeline* computePipeline = vulkanCommandBuffer->currentComputePipeline;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
|
|
||||||
|
if (computePipeline == NULL)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Cannot push uniforms if a pipeline is not bound!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (computePipeline->uniformBlockSize == 0)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Bound compute pipeline does not declare uniforms!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
vulkanCommandBuffer->computeUniformBuffer->offset +
|
vulkanCommandBuffer->computeUniformBuffer->offset +
|
||||||
computePipeline->uniformBlockSize >=
|
computePipeline->uniformBlockSize >=
|
||||||
|
@ -8254,6 +8301,12 @@ static void VULKAN_SetViewport(
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
|
|
||||||
|
if (!vulkanCommandBuffer->renderPassInProgress)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Illegal to set viewport state outside of a render pass!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VULKAN_INTERNAL_SetCurrentViewport(
|
VULKAN_INTERNAL_SetCurrentViewport(
|
||||||
vulkanCommandBuffer,
|
vulkanCommandBuffer,
|
||||||
viewport
|
viewport
|
||||||
|
@ -8285,6 +8338,12 @@ static void VULKAN_SetScissor(
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
|
|
||||||
|
if (!vulkanCommandBuffer->renderPassInProgress)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Illegal to set scissor state outside of a render pass!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VULKAN_INTERNAL_SetCurrentScissor(
|
VULKAN_INTERNAL_SetCurrentScissor(
|
||||||
vulkanCommandBuffer,
|
vulkanCommandBuffer,
|
||||||
scissor
|
scissor
|
||||||
|
@ -8321,6 +8380,12 @@ static void VULKAN_BeginRenderPass(
|
||||||
uint32_t framebufferWidth = UINT32_MAX;
|
uint32_t framebufferWidth = UINT32_MAX;
|
||||||
uint32_t framebufferHeight = UINT32_MAX;
|
uint32_t framebufferHeight = UINT32_MAX;
|
||||||
|
|
||||||
|
if (colorAttachmentCount == 0 && depthStencilAttachmentInfo == NULL)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Render pass must have at least one render target!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* The framebuffer cannot be larger than the smallest attachment. */
|
/* The framebuffer cannot be larger than the smallest attachment. */
|
||||||
|
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
|
@ -8631,6 +8696,12 @@ static void VULKAN_BindGraphicsPipeline(
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanGraphicsPipeline* pipeline = (VulkanGraphicsPipeline*) graphicsPipeline;
|
VulkanGraphicsPipeline* pipeline = (VulkanGraphicsPipeline*) graphicsPipeline;
|
||||||
|
|
||||||
|
if (!vulkanCommandBuffer->renderPassInProgress)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Illegal to bind a graphics pipeline outside of a render pass!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( vulkanCommandBuffer->vertexUniformBuffer != renderer->dummyVertexUniformBuffer &&
|
if ( vulkanCommandBuffer->vertexUniformBuffer != renderer->dummyVertexUniformBuffer &&
|
||||||
vulkanCommandBuffer->vertexUniformBuffer != NULL
|
vulkanCommandBuffer->vertexUniformBuffer != NULL
|
||||||
) {
|
) {
|
||||||
|
@ -9355,6 +9426,13 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture(
|
||||||
VulkanPresentData *presentData;
|
VulkanPresentData *presentData;
|
||||||
|
|
||||||
windowData = VULKAN_INTERNAL_FetchWindowData(windowHandle);
|
windowData = VULKAN_INTERNAL_FetchWindowData(windowHandle);
|
||||||
|
|
||||||
|
if (windowData == NULL)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Cannot acquire swapchain texture, window has not been claimed!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
swapchainData = windowData->swapchainData;
|
swapchainData = windowData->swapchainData;
|
||||||
|
|
||||||
/* Window is claimed but swapchain is invalid! */
|
/* Window is claimed but swapchain is invalid! */
|
||||||
|
|
Loading…
Reference in New Issue