starting on resource rotation
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
695abd4139
commit
5b416ffe82
|
@ -327,11 +327,17 @@ typedef enum Refresh_BorderColor
|
||||||
REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE
|
REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE
|
||||||
} Refresh_BorderColor;
|
} Refresh_BorderColor;
|
||||||
|
|
||||||
typedef enum Refresh_SetDataOptions
|
typedef enum Refresh_TransferOptions
|
||||||
{
|
{
|
||||||
REFRESH_SETDATAOPTIONS_SAFEDISCARD,
|
REFRESH_TRANSFEROPTIONS_SAFEDISCARD,
|
||||||
REFRESH_SETDATAOPTIONS_OVERWRITE
|
REFRESH_TRANSFEROPTIONS_OVERWRITE
|
||||||
} Refresh_SetDataOptions;
|
} Refresh_TransferOptions;
|
||||||
|
|
||||||
|
typedef enum Refresh_CopyOptions
|
||||||
|
{
|
||||||
|
REFRESH_COPYOPTIONS_SAFEDISCARD,
|
||||||
|
REFRESH_COPYOPTIONS_SAFEOVERWRITE
|
||||||
|
} Refresh_CopyOptions;
|
||||||
|
|
||||||
typedef enum Refresh_Backend
|
typedef enum Refresh_Backend
|
||||||
{
|
{
|
||||||
|
@ -1064,16 +1070,16 @@ REFRESHAPI void Refresh_EndComputePass(
|
||||||
* Overwrites the data regardless of whether a copy has been issued.
|
* Overwrites the data regardless of whether a copy has been issued.
|
||||||
* Use this option with great care, as it can cause data races to occur!
|
* Use this option with great care, as it can cause data races to occur!
|
||||||
*/
|
*/
|
||||||
REFRESHAPI void Refresh_SetData(
|
REFRESHAPI void Refresh_SetTransferData(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
void* data,
|
void* data,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_BufferCopy *copyParams,
|
Refresh_BufferCopy *copyParams,
|
||||||
Refresh_SetDataOptions option
|
Refresh_TransferOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Immediately copies data from a TransferBuffer into a pointer. */
|
/* Immediately copies data from a TransferBuffer into a pointer. */
|
||||||
REFRESHAPI void Refresh_GetData(
|
REFRESHAPI void Refresh_GetTransferData(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
void* data,
|
void* data,
|
||||||
|
@ -1093,13 +1099,27 @@ REFRESHAPI void Refresh_BeginCopyPass(
|
||||||
* You MAY assume that the copy has finished for subsequent commands.
|
* You MAY assume that the copy has finished for subsequent commands.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* option:
|
||||||
|
* SAFEDISCARD:
|
||||||
|
* If this TransferBuffer has been used in a copy command that has not completed,
|
||||||
|
* the issued copy commands will still be valid at the cost of increased memory usage.
|
||||||
|
* Otherwise the data will overwrite.
|
||||||
|
* It is not recommended to use this option with large resources.
|
||||||
|
*
|
||||||
|
* OVERWRITE:
|
||||||
|
* Overwrites the data regardless of whether a copy has been issued.
|
||||||
|
* Use this option with great care, as it can cause data races to occur!
|
||||||
|
*/
|
||||||
|
|
||||||
/* Uploads data from a TransferBuffer to a texture. */
|
/* Uploads data from a TransferBuffer to a texture. */
|
||||||
REFRESHAPI void Refresh_UploadToTexture(
|
REFRESHAPI void Refresh_UploadToTexture(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Uploads data from a TransferBuffer to a GpuBuffer. */
|
/* Uploads data from a TransferBuffer to a GpuBuffer. */
|
||||||
|
@ -1108,7 +1128,8 @@ REFRESHAPI void Refresh_UploadToBuffer(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* GPU-to-CPU copies occur on the GPU timeline.
|
/* GPU-to-CPU copies occur on the GPU timeline.
|
||||||
|
@ -1144,7 +1165,8 @@ REFRESHAPI void Refresh_CopyTextureToTexture(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TextureSlice *source,
|
Refresh_TextureSlice *source,
|
||||||
Refresh_TextureSlice *destination
|
Refresh_TextureSlice *destination,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Copies image data from a texture slice into a buffer. */
|
/* Copies image data from a texture slice into a buffer. */
|
||||||
|
@ -1153,7 +1175,8 @@ REFRESHAPI void Refresh_CopyTextureToBuffer(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Copies data from a buffer to a texture slice. */
|
/* Copies data from a buffer to a texture slice. */
|
||||||
|
@ -1162,7 +1185,8 @@ REFRESHAPI void Refresh_CopyBufferToTexture(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Copies data from a buffer to a buffer. */
|
/* Copies data from a buffer to a buffer. */
|
||||||
|
@ -1171,7 +1195,8 @@ REFRESHAPI void Refresh_CopyBufferToBuffer(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_GpuBuffer *source,
|
Refresh_GpuBuffer *source,
|
||||||
Refresh_GpuBuffer *destination,
|
Refresh_GpuBuffer *destination,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Generate mipmaps for the given texture. */
|
/* Generate mipmaps for the given texture. */
|
||||||
|
|
|
@ -732,15 +732,15 @@ void Refresh_EndComputePass(
|
||||||
|
|
||||||
/* TransferBuffer Set/Get */
|
/* TransferBuffer Set/Get */
|
||||||
|
|
||||||
void Refresh_SetData(
|
void Refresh_SetTransferData(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
void* data,
|
void* data,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_BufferCopy *copyParams,
|
Refresh_BufferCopy *copyParams,
|
||||||
Refresh_SetDataOptions option
|
Refresh_TransferOptions option
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->SetData(
|
device->SetTransferData(
|
||||||
device->driverData,
|
device->driverData,
|
||||||
data,
|
data,
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
|
@ -749,14 +749,14 @@ void Refresh_SetData(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Refresh_GetData(
|
void Refresh_GetTransferData(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
void* data,
|
void* data,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->GetData(
|
device->GetTransferData(
|
||||||
device->driverData,
|
device->driverData,
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
data,
|
data,
|
||||||
|
@ -782,7 +782,8 @@ void Refresh_UploadToTexture(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->UploadToTexture(
|
device->UploadToTexture(
|
||||||
|
@ -790,7 +791,8 @@ void Refresh_UploadToTexture(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
textureSlice,
|
textureSlice,
|
||||||
copyParams
|
copyParams,
|
||||||
|
option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,7 +801,8 @@ void Refresh_UploadToBuffer(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->UploadToBuffer(
|
device->UploadToBuffer(
|
||||||
|
@ -807,7 +810,8 @@ void Refresh_UploadToBuffer(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
gpuBuffer,
|
gpuBuffer,
|
||||||
copyParams
|
copyParams,
|
||||||
|
option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,14 +853,16 @@ void Refresh_CopyTextureToTexture(
|
||||||
Refresh_Device *device,
|
Refresh_Device *device,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TextureSlice *sourceTextureSlice,
|
Refresh_TextureSlice *sourceTextureSlice,
|
||||||
Refresh_TextureSlice *destinationTextureSlice
|
Refresh_TextureSlice *destinationTextureSlice,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->CopyTextureToTexture(
|
device->CopyTextureToTexture(
|
||||||
device->driverData,
|
device->driverData,
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
sourceTextureSlice,
|
sourceTextureSlice,
|
||||||
destinationTextureSlice
|
destinationTextureSlice,
|
||||||
|
option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +871,8 @@ void Refresh_CopyTextureToBuffer(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_BufferImageCopy *copyParameters
|
Refresh_BufferImageCopy *copyParameters,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->CopyTextureToBuffer(
|
device->CopyTextureToBuffer(
|
||||||
|
@ -873,7 +880,8 @@ void Refresh_CopyTextureToBuffer(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
textureSlice,
|
textureSlice,
|
||||||
gpuBuffer,
|
gpuBuffer,
|
||||||
copyParameters
|
copyParameters,
|
||||||
|
option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,7 +890,8 @@ void Refresh_CopyBufferToTexture(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->CopyBufferToTexture(
|
device->CopyBufferToTexture(
|
||||||
|
@ -890,7 +899,8 @@ void Refresh_CopyBufferToTexture(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
gpuBuffer,
|
gpuBuffer,
|
||||||
textureSlice,
|
textureSlice,
|
||||||
copyParams
|
copyParams,
|
||||||
|
option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,7 +909,8 @@ void Refresh_CopyBufferToBuffer(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_GpuBuffer *source,
|
Refresh_GpuBuffer *source,
|
||||||
Refresh_GpuBuffer *destination,
|
Refresh_GpuBuffer *destination,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
NULL_RETURN(device);
|
NULL_RETURN(device);
|
||||||
device->CopyBufferToBuffer(
|
device->CopyBufferToBuffer(
|
||||||
|
@ -907,7 +918,8 @@ void Refresh_CopyBufferToBuffer(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
source,
|
source,
|
||||||
destination,
|
destination,
|
||||||
copyParams
|
copyParams,
|
||||||
|
option
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,15 +415,15 @@ struct Refresh_Device
|
||||||
|
|
||||||
/* TransferBuffer Set/Get */
|
/* TransferBuffer Set/Get */
|
||||||
|
|
||||||
void (*SetData)(
|
void (*SetTransferData)(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
void* data,
|
void* data,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_BufferCopy *copyParams,
|
Refresh_BufferCopy *copyParams,
|
||||||
Refresh_SetDataOptions option
|
Refresh_TransferOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
void (*GetData)(
|
void (*GetTransferData)(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
void* data,
|
void* data,
|
||||||
|
@ -442,7 +442,8 @@ struct Refresh_Device
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
void (*UploadToBuffer)(
|
void (*UploadToBuffer)(
|
||||||
|
@ -450,7 +451,8 @@ struct Refresh_Device
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
void (*DownloadFromTexture)(
|
void (*DownloadFromTexture)(
|
||||||
|
@ -473,7 +475,8 @@ struct Refresh_Device
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TextureSlice *source,
|
Refresh_TextureSlice *source,
|
||||||
Refresh_TextureSlice *destination
|
Refresh_TextureSlice *destination,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
void (*CopyTextureToBuffer)(
|
void (*CopyTextureToBuffer)(
|
||||||
|
@ -481,7 +484,8 @@ struct Refresh_Device
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
void (*CopyBufferToTexture)(
|
void (*CopyBufferToTexture)(
|
||||||
|
@ -489,7 +493,8 @@ struct Refresh_Device
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
void (*CopyBufferToBuffer)(
|
void (*CopyBufferToBuffer)(
|
||||||
|
@ -497,7 +502,8 @@ struct Refresh_Device
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_GpuBuffer *source,
|
Refresh_GpuBuffer *source,
|
||||||
Refresh_GpuBuffer *destination,
|
Refresh_GpuBuffer *destination,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
);
|
);
|
||||||
|
|
||||||
void (*GenerateMipmaps)(
|
void (*GenerateMipmaps)(
|
||||||
|
@ -622,8 +628,8 @@ struct Refresh_Device
|
||||||
ASSIGN_DRIVER_FUNC(PushComputeShaderUniforms, name) \
|
ASSIGN_DRIVER_FUNC(PushComputeShaderUniforms, name) \
|
||||||
ASSIGN_DRIVER_FUNC(DispatchCompute, name) \
|
ASSIGN_DRIVER_FUNC(DispatchCompute, name) \
|
||||||
ASSIGN_DRIVER_FUNC(EndComputePass, name) \
|
ASSIGN_DRIVER_FUNC(EndComputePass, name) \
|
||||||
ASSIGN_DRIVER_FUNC(SetData, name) \
|
ASSIGN_DRIVER_FUNC(SetTransferData, name) \
|
||||||
ASSIGN_DRIVER_FUNC(GetData, name) \
|
ASSIGN_DRIVER_FUNC(GetTransferData, name) \
|
||||||
ASSIGN_DRIVER_FUNC(BeginCopyPass, name) \
|
ASSIGN_DRIVER_FUNC(BeginCopyPass, name) \
|
||||||
ASSIGN_DRIVER_FUNC(UploadToTexture, name) \
|
ASSIGN_DRIVER_FUNC(UploadToTexture, name) \
|
||||||
ASSIGN_DRIVER_FUNC(UploadToBuffer, name) \
|
ASSIGN_DRIVER_FUNC(UploadToBuffer, name) \
|
||||||
|
|
|
@ -695,28 +695,10 @@ static const VulkanResourceAccessInfo AccessMap[RESOURCE_ACCESS_TYPES_COUNT] =
|
||||||
/* We use pointer indirection so that defrag can occur without objects
|
/* We use pointer indirection so that defrag can occur without objects
|
||||||
* needing to be aware of the backing buffers changing.
|
* needing to be aware of the backing buffers changing.
|
||||||
*/
|
*/
|
||||||
typedef struct VulkanBufferContainer
|
typedef struct VulkanBufferHandle
|
||||||
{
|
{
|
||||||
VulkanBuffer *vulkanBuffer;
|
VulkanBuffer *vulkanBuffer;
|
||||||
} VulkanBufferContainer;
|
} VulkanBufferHandle;
|
||||||
|
|
||||||
/* TransferBuffers consist of multiple backing buffer containers so that data transfers
|
|
||||||
* can occur safely without the client having to explicitly manage transfer timing.
|
|
||||||
*/
|
|
||||||
typedef struct VulkanTransferBufferContainer /* cast from Refresh_TransferBuffer */
|
|
||||||
{
|
|
||||||
uint32_t sizeInBytes;
|
|
||||||
VulkanBufferContainer *activeBuffer;
|
|
||||||
|
|
||||||
/* These are all the buffers that have been used by this container.
|
|
||||||
* If a buffer is bound and then updated with Discard, a new buffer
|
|
||||||
* will be added to this list.
|
|
||||||
* These can be reused after they are submitted and command processing is complete.
|
|
||||||
*/
|
|
||||||
uint32_t bufferCapacity;
|
|
||||||
uint32_t bufferCount;
|
|
||||||
VulkanBufferContainer **backingBuffers;
|
|
||||||
} VulkanTransferBufferContainer;
|
|
||||||
|
|
||||||
struct VulkanBuffer
|
struct VulkanBuffer
|
||||||
{
|
{
|
||||||
|
@ -729,15 +711,34 @@ struct VulkanBuffer
|
||||||
uint8_t requireHostVisible;
|
uint8_t requireHostVisible;
|
||||||
uint8_t preferDeviceLocal;
|
uint8_t preferDeviceLocal;
|
||||||
uint8_t preferHostLocal;
|
uint8_t preferHostLocal;
|
||||||
uint8_t preserveContentsOnDefrag;
|
|
||||||
|
|
||||||
SDL_atomic_t referenceCount; /* Tracks command buffer usage */
|
SDL_atomic_t referenceCount; /* Tracks command buffer usage */
|
||||||
|
|
||||||
VulkanBufferContainer *container;
|
VulkanBufferHandle *handle;
|
||||||
|
|
||||||
uint8_t markedForDestroy; /* so that defrag doesn't double-free */
|
uint8_t markedForDestroy; /* so that defrag doesn't double-free */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Buffer resources consist of multiple backing buffer handles so that data transfers
|
||||||
|
* can occur without blocking or the client having to manage extra resources.
|
||||||
|
*
|
||||||
|
* Cast from Refresh_GpuBuffer or Refresh_TransferBuffer.
|
||||||
|
*/
|
||||||
|
typedef struct VulkanBufferContainer
|
||||||
|
{
|
||||||
|
VulkanBufferHandle *activeBufferHandle;
|
||||||
|
|
||||||
|
/* These are all the buffer handles that have been used by this container.
|
||||||
|
* If the resource is bound and then updated with SafeDiscard, a new resource
|
||||||
|
* will be added to this list.
|
||||||
|
* These can be reused after they are submitted and command processing is complete.
|
||||||
|
*/
|
||||||
|
uint32_t bufferCapacity;
|
||||||
|
uint32_t bufferCount;
|
||||||
|
VulkanBufferHandle **bufferHandles;
|
||||||
|
|
||||||
|
} VulkanBufferContainer;
|
||||||
|
|
||||||
typedef enum VulkanUniformBufferType
|
typedef enum VulkanUniformBufferType
|
||||||
{
|
{
|
||||||
UNIFORM_BUFFER_VERTEX,
|
UNIFORM_BUFFER_VERTEX,
|
||||||
|
@ -777,10 +778,10 @@ typedef struct VulkanShaderModule
|
||||||
SDL_atomic_t referenceCount;
|
SDL_atomic_t referenceCount;
|
||||||
} VulkanShaderModule;
|
} VulkanShaderModule;
|
||||||
|
|
||||||
typedef struct VulkanTextureContainer /* Cast from Refresh_Texture */
|
typedef struct VulkanTextureHandle
|
||||||
{
|
{
|
||||||
VulkanTexture *vulkanTexture;
|
VulkanTexture *vulkanTexture;
|
||||||
} VulkanTextureContainer;
|
} VulkanTextureHandle;
|
||||||
|
|
||||||
struct VulkanTexture
|
struct VulkanTexture
|
||||||
{
|
{
|
||||||
|
@ -803,15 +804,34 @@ struct VulkanTexture
|
||||||
|
|
||||||
VkImageAspectFlags aspectFlags;
|
VkImageAspectFlags aspectFlags;
|
||||||
|
|
||||||
struct VulkanTexture *msaaTex;
|
struct VulkanTexture *msaaTex; /* doesn't need to be a handle because render targets are dedicated */
|
||||||
|
|
||||||
SDL_atomic_t referenceCount;
|
SDL_atomic_t referenceCount;
|
||||||
|
|
||||||
VulkanTextureContainer *container;
|
VulkanTextureHandle *handle;
|
||||||
|
|
||||||
uint8_t markedForDestroy; /* so that defrag doesn't double-free */
|
uint8_t markedForDestroy; /* so that defrag doesn't double-free */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Texture resources consist of multiple backing texture handles so that data transfers
|
||||||
|
* can occur without blocking or the client having to manage extra resources.
|
||||||
|
*
|
||||||
|
* Cast from Refresh_Texture.
|
||||||
|
*/
|
||||||
|
typedef struct VulkanTextureContainer
|
||||||
|
{
|
||||||
|
VulkanTextureHandle *activeTextureHandle;
|
||||||
|
|
||||||
|
/* These are all the texture handles that have been used by this container.
|
||||||
|
* If the resource is bound and then updated with SafeDiscard, a new resource
|
||||||
|
* will be added to this list.
|
||||||
|
* These can be reused after they are submitted and command processing is complete.
|
||||||
|
*/
|
||||||
|
uint32_t textureCapacity;
|
||||||
|
uint32_t textureCount;
|
||||||
|
VulkanTextureHandle **textureHandles;
|
||||||
|
} VulkanTextureContainer;
|
||||||
|
|
||||||
typedef struct VulkanRenderTarget
|
typedef struct VulkanRenderTarget
|
||||||
{
|
{
|
||||||
VkImageView view;
|
VkImageView view;
|
||||||
|
@ -837,7 +857,7 @@ typedef struct VulkanSwapchainData
|
||||||
|
|
||||||
/* Swapchain images */
|
/* Swapchain images */
|
||||||
VkExtent2D extent;
|
VkExtent2D extent;
|
||||||
VulkanTextureContainer *textureContainers;
|
VulkanTextureHandle *textureContainers;
|
||||||
uint32_t imageCount;
|
uint32_t imageCount;
|
||||||
|
|
||||||
/* Synchronization primitives */
|
/* Synchronization primitives */
|
||||||
|
@ -4195,8 +4215,7 @@ static VulkanBuffer* VULKAN_INTERNAL_CreateBuffer(
|
||||||
uint8_t requireHostVisible,
|
uint8_t requireHostVisible,
|
||||||
uint8_t preferHostLocal,
|
uint8_t preferHostLocal,
|
||||||
uint8_t preferDeviceLocal,
|
uint8_t preferDeviceLocal,
|
||||||
uint8_t dedicatedAllocation,
|
uint8_t dedicatedAllocation
|
||||||
uint8_t preserveContentsOnDefrag
|
|
||||||
) {
|
) {
|
||||||
VulkanBuffer* buffer;
|
VulkanBuffer* buffer;
|
||||||
VkResult vulkanResult;
|
VkResult vulkanResult;
|
||||||
|
@ -4211,7 +4230,6 @@ static VulkanBuffer* VULKAN_INTERNAL_CreateBuffer(
|
||||||
buffer->requireHostVisible = requireHostVisible;
|
buffer->requireHostVisible = requireHostVisible;
|
||||||
buffer->preferHostLocal = preferHostLocal;
|
buffer->preferHostLocal = preferHostLocal;
|
||||||
buffer->preferDeviceLocal = preferDeviceLocal;
|
buffer->preferDeviceLocal = preferDeviceLocal;
|
||||||
buffer->preserveContentsOnDefrag = preserveContentsOnDefrag;
|
|
||||||
buffer->markedForDestroy = 0;
|
buffer->markedForDestroy = 0;
|
||||||
|
|
||||||
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
||||||
|
@ -4253,7 +4271,7 @@ static VulkanBuffer* VULKAN_INTERNAL_CreateBuffer(
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->usedRegion->vulkanBuffer = buffer; /* lol */
|
buffer->usedRegion->vulkanBuffer = buffer; /* lol */
|
||||||
buffer->container = NULL;
|
buffer->handle = NULL;
|
||||||
|
|
||||||
buffer->resourceAccessType = resourceAccessType;
|
buffer->resourceAccessType = resourceAccessType;
|
||||||
|
|
||||||
|
@ -4304,7 +4322,6 @@ static VulkanUniformBufferObject* VULKAN_INTERNAL_CreateUniformBufferObject(
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
1,
|
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4350,18 +4367,16 @@ static VulkanUniformBufferObject* VULKAN_INTERNAL_CreateUniformBufferObject(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Indirection so we can cleanly defrag buffers */
|
/* Indirection so we can cleanly defrag buffers */
|
||||||
static VulkanBufferContainer* VULKAN_INTERNAL_CreateBufferContainer(
|
static VulkanBufferHandle* VULKAN_INTERNAL_CreateBufferHandle(
|
||||||
VulkanRenderer *renderer,
|
VulkanRenderer *renderer,
|
||||||
uint32_t sizeInBytes,
|
uint32_t sizeInBytes,
|
||||||
VulkanResourceAccessType resourceAccessType,
|
VulkanResourceAccessType resourceAccessType,
|
||||||
VkBufferUsageFlags usageFlags,
|
VkBufferUsageFlags usageFlags,
|
||||||
uint8_t requireHostVisible,
|
uint8_t requireHostVisible,
|
||||||
uint8_t preferHostLocal,
|
uint8_t preferHostLocal,
|
||||||
uint8_t preferDeviceLocal,
|
uint8_t preferDeviceLocal
|
||||||
uint8_t dedicatedAllocation,
|
|
||||||
uint8_t preserveContentsOnDefrag
|
|
||||||
) {
|
) {
|
||||||
VulkanBufferContainer* bufferContainer;
|
VulkanBufferHandle* bufferHandle;
|
||||||
VulkanBuffer* buffer;
|
VulkanBuffer* buffer;
|
||||||
|
|
||||||
/* always set transfer bits so we can defrag */
|
/* always set transfer bits so we can defrag */
|
||||||
|
@ -4375,8 +4390,7 @@ static VulkanBufferContainer* VULKAN_INTERNAL_CreateBufferContainer(
|
||||||
requireHostVisible,
|
requireHostVisible,
|
||||||
preferHostLocal,
|
preferHostLocal,
|
||||||
preferDeviceLocal,
|
preferDeviceLocal,
|
||||||
dedicatedAllocation,
|
0
|
||||||
preserveContentsOnDefrag
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
|
@ -4385,11 +4399,53 @@ static VulkanBufferContainer* VULKAN_INTERNAL_CreateBufferContainer(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferContainer = SDL_malloc(sizeof(VulkanBufferContainer));
|
bufferHandle = SDL_malloc(sizeof(VulkanBufferHandle));
|
||||||
bufferContainer->vulkanBuffer = buffer;
|
bufferHandle->vulkanBuffer = buffer;
|
||||||
buffer->container = bufferContainer;
|
buffer->handle = bufferHandle;
|
||||||
|
|
||||||
return (VulkanBufferContainer*) bufferContainer;
|
return bufferHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VulkanBufferContainer* VULKAN_INTERNAL_CreateBufferContainer(
|
||||||
|
VulkanRenderer *renderer,
|
||||||
|
uint32_t sizeInBytes,
|
||||||
|
VulkanResourceAccessType resourceAccessType,
|
||||||
|
VkBufferUsageFlags usageFlags,
|
||||||
|
uint8_t requireHostVisible,
|
||||||
|
uint8_t preferHostLocal,
|
||||||
|
uint8_t preferDeviceLocal
|
||||||
|
) {
|
||||||
|
VulkanBufferContainer *bufferContainer;
|
||||||
|
VulkanBufferHandle *bufferHandle;
|
||||||
|
|
||||||
|
bufferHandle = VULKAN_INTERNAL_CreateBufferHandle(
|
||||||
|
renderer,
|
||||||
|
sizeInBytes,
|
||||||
|
resourceAccessType,
|
||||||
|
usageFlags,
|
||||||
|
requireHostVisible,
|
||||||
|
preferHostLocal,
|
||||||
|
preferDeviceLocal
|
||||||
|
);
|
||||||
|
|
||||||
|
if (bufferHandle == NULL)
|
||||||
|
{
|
||||||
|
Refresh_LogError("Failed to create buffer container!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferContainer = SDL_malloc(sizeof(VulkanBufferContainer));
|
||||||
|
|
||||||
|
bufferContainer->activeBufferHandle = bufferHandle;
|
||||||
|
|
||||||
|
bufferContainer->bufferCapacity = 1;
|
||||||
|
bufferContainer->bufferCount = 1;
|
||||||
|
bufferContainer->bufferHandles = SDL_malloc(
|
||||||
|
bufferContainer->bufferCapacity * sizeof(VulkanBufferHandle*)
|
||||||
|
);
|
||||||
|
bufferContainer->bufferHandles[0] = bufferContainer->activeBufferHandle;
|
||||||
|
|
||||||
|
return bufferContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VULKAN_INTERNAL_DestroyUniformBufferObject(
|
static void VULKAN_INTERNAL_DestroyUniformBufferObject(
|
||||||
|
@ -4861,7 +4917,7 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain(
|
||||||
);
|
);
|
||||||
|
|
||||||
swapchainData->textureContainers = SDL_malloc(
|
swapchainData->textureContainers = SDL_malloc(
|
||||||
sizeof(VulkanTextureContainer) * swapchainData->imageCount
|
sizeof(VulkanTextureHandle) * swapchainData->imageCount
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!swapchainData->textureContainers)
|
if (!swapchainData->textureContainers)
|
||||||
|
@ -4935,6 +4991,7 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain(
|
||||||
swapchainData->textureContainers[i].vulkanTexture->format = swapchainData->swapchainFormat;
|
swapchainData->textureContainers[i].vulkanTexture->format = swapchainData->swapchainFormat;
|
||||||
swapchainData->textureContainers[i].vulkanTexture->is3D = 0;
|
swapchainData->textureContainers[i].vulkanTexture->is3D = 0;
|
||||||
swapchainData->textureContainers[i].vulkanTexture->isCube = 0;
|
swapchainData->textureContainers[i].vulkanTexture->isCube = 0;
|
||||||
|
swapchainData->textureContainers[i].vulkanTexture->depth = 1;
|
||||||
swapchainData->textureContainers[i].vulkanTexture->layerCount = 1;
|
swapchainData->textureContainers[i].vulkanTexture->layerCount = 1;
|
||||||
swapchainData->textureContainers[i].vulkanTexture->levelCount = 1;
|
swapchainData->textureContainers[i].vulkanTexture->levelCount = 1;
|
||||||
swapchainData->textureContainers[i].vulkanTexture->sampleCount = REFRESH_SAMPLECOUNT_1;
|
swapchainData->textureContainers[i].vulkanTexture->sampleCount = REFRESH_SAMPLECOUNT_1;
|
||||||
|
@ -5385,7 +5442,7 @@ static void VULKAN_DrawPrimitivesIndirect(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanBuffer *vulkanBuffer = ((VulkanBufferContainer*) gpuBuffer)->vulkanBuffer;
|
VulkanBuffer *vulkanBuffer = ((VulkanBufferHandle*) gpuBuffer)->vulkanBuffer;
|
||||||
VkDescriptorSet descriptorSets[4];
|
VkDescriptorSet descriptorSets[4];
|
||||||
uint32_t dynamicOffsets[2];
|
uint32_t dynamicOffsets[2];
|
||||||
|
|
||||||
|
@ -5701,7 +5758,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass(
|
||||||
|
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
||||||
|
|
||||||
if (texture->msaaTex != NULL)
|
if (texture->msaaTex != NULL)
|
||||||
{
|
{
|
||||||
|
@ -5824,7 +5881,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
||||||
|
|
||||||
attachmentDescriptions[attachmentDescriptionCount].flags = 0;
|
attachmentDescriptions[attachmentDescriptionCount].flags = 0;
|
||||||
attachmentDescriptions[attachmentDescriptionCount].format = texture->format;
|
attachmentDescriptions[attachmentDescriptionCount].format = texture->format;
|
||||||
|
@ -6719,6 +6776,7 @@ static Refresh_Texture* VULKAN_CreateTexture(
|
||||||
uint8_t isDepthFormat = IsRefreshDepthFormat(textureCreateInfo->format);
|
uint8_t isDepthFormat = IsRefreshDepthFormat(textureCreateInfo->format);
|
||||||
VkFormat format;
|
VkFormat format;
|
||||||
VulkanTextureContainer *container;
|
VulkanTextureContainer *container;
|
||||||
|
VulkanTextureHandle *textureHandle;
|
||||||
VulkanTexture *vulkanTexture;
|
VulkanTexture *vulkanTexture;
|
||||||
|
|
||||||
if (isDepthFormat)
|
if (isDepthFormat)
|
||||||
|
@ -6764,6 +6822,7 @@ static Refresh_Texture* VULKAN_CreateTexture(
|
||||||
imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
|
imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: what if this fails? */
|
||||||
vulkanTexture = VULKAN_INTERNAL_CreateTexture(
|
vulkanTexture = VULKAN_INTERNAL_CreateTexture(
|
||||||
renderer,
|
renderer,
|
||||||
textureCreateInfo->width,
|
textureCreateInfo->width,
|
||||||
|
@ -6784,6 +6843,7 @@ static Refresh_Texture* VULKAN_CreateTexture(
|
||||||
!isDepthFormat &&
|
!isDepthFormat &&
|
||||||
textureCreateInfo->sampleCount > REFRESH_SAMPLECOUNT_1 )
|
textureCreateInfo->sampleCount > REFRESH_SAMPLECOUNT_1 )
|
||||||
{
|
{
|
||||||
|
/* FIXME: what if this fails? */
|
||||||
vulkanTexture->msaaTex = VULKAN_INTERNAL_CreateTexture(
|
vulkanTexture->msaaTex = VULKAN_INTERNAL_CreateTexture(
|
||||||
renderer,
|
renderer,
|
||||||
textureCreateInfo->width,
|
textureCreateInfo->width,
|
||||||
|
@ -6798,9 +6858,18 @@ static Refresh_Texture* VULKAN_CreateTexture(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textureHandle = SDL_malloc(sizeof(VulkanTextureHandle));
|
||||||
|
textureHandle->vulkanTexture = vulkanTexture;
|
||||||
|
vulkanTexture->handle = textureHandle;
|
||||||
|
|
||||||
container = SDL_malloc(sizeof(VulkanTextureContainer));
|
container = SDL_malloc(sizeof(VulkanTextureContainer));
|
||||||
container->vulkanTexture = vulkanTexture;
|
|
||||||
vulkanTexture->container = container;
|
container->activeTextureHandle = textureHandle;
|
||||||
|
container->textureCapacity = 1;
|
||||||
|
container->textureCount =1 ;
|
||||||
|
container->textureHandles = SDL_malloc(
|
||||||
|
container->textureCapacity * sizeof(VulkanTextureHandle*)
|
||||||
|
);
|
||||||
|
|
||||||
return (Refresh_Texture*) container;
|
return (Refresh_Texture*) container;
|
||||||
}
|
}
|
||||||
|
@ -6850,8 +6919,6 @@ static Refresh_GpuBuffer* VULKAN_CreateGpuBuffer(
|
||||||
vulkanUsageFlags,
|
vulkanUsageFlags,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
1,
|
|
||||||
0,
|
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -6860,32 +6927,15 @@ static Refresh_TransferBuffer* VULKAN_CreateTransferBuffer(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
uint32_t sizeInBytes
|
uint32_t sizeInBytes
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
return (Refresh_TransferBuffer*) VULKAN_INTERNAL_CreateBufferContainer(
|
||||||
VkBufferUsageFlags vulkanUsageFlags =
|
(VulkanRenderer*) driverData,
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) SDL_malloc(sizeof(VulkanTransferBufferContainer));
|
|
||||||
|
|
||||||
transferBufferContainer->sizeInBytes = sizeInBytes;
|
|
||||||
transferBufferContainer->activeBuffer = VULKAN_INTERNAL_CreateBufferContainer(
|
|
||||||
renderer,
|
|
||||||
sizeInBytes,
|
sizeInBytes,
|
||||||
RESOURCE_ACCESS_NONE,
|
RESOURCE_ACCESS_NONE,
|
||||||
vulkanUsageFlags,
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
transferBufferContainer->bufferCapacity = 1;
|
|
||||||
transferBufferContainer->bufferCount = 1;
|
|
||||||
transferBufferContainer->backingBuffers = SDL_malloc(
|
|
||||||
transferBufferContainer->bufferCapacity * sizeof(VulkanBufferContainer*)
|
|
||||||
);
|
|
||||||
transferBufferContainer->backingBuffers[0] = transferBufferContainer->activeBuffer;
|
|
||||||
|
|
||||||
return (Refresh_TransferBuffer*) transferBufferContainer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setters */
|
/* Setters */
|
||||||
|
@ -7150,7 +7200,7 @@ static void VULKAN_BindVertexSamplers(
|
||||||
|
|
||||||
for (i = 0; i < samplerCount; i += 1)
|
for (i = 0; i < samplerCount; i += 1)
|
||||||
{
|
{
|
||||||
currentTexture = ((VulkanTextureContainer*) pTextures[i])->vulkanTexture;
|
currentTexture = ((VulkanTextureHandle*) pTextures[i])->vulkanTexture;
|
||||||
currentSampler = (VulkanSampler*) pSamplers[i];
|
currentSampler = (VulkanSampler*) pSamplers[i];
|
||||||
descriptorImageInfos[i].imageView = currentTexture->view;
|
descriptorImageInfos[i].imageView = currentTexture->view;
|
||||||
descriptorImageInfos[i].sampler = currentSampler->sampler;
|
descriptorImageInfos[i].sampler = currentSampler->sampler;
|
||||||
|
@ -7193,7 +7243,7 @@ static void VULKAN_BindFragmentSamplers(
|
||||||
|
|
||||||
for (i = 0; i < samplerCount; i += 1)
|
for (i = 0; i < samplerCount; i += 1)
|
||||||
{
|
{
|
||||||
currentTexture = ((VulkanTextureContainer*) pTextures[i])->vulkanTexture;
|
currentTexture = ((VulkanTextureHandle*) pTextures[i])->vulkanTexture;
|
||||||
currentSampler = (VulkanSampler*) pSamplers[i];
|
currentSampler = (VulkanSampler*) pSamplers[i];
|
||||||
descriptorImageInfos[i].imageView = currentTexture->view;
|
descriptorImageInfos[i].imageView = currentTexture->view;
|
||||||
descriptorImageInfos[i].sampler = currentSampler->sampler;
|
descriptorImageInfos[i].sampler = currentSampler->sampler;
|
||||||
|
@ -7243,7 +7293,7 @@ static void VULKAN_QueueDestroyTexture(
|
||||||
Refresh_Texture *texture
|
Refresh_Texture *texture
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanTextureContainer *vulkanTextureContainer = (VulkanTextureContainer *)texture;
|
VulkanTextureHandle *vulkanTextureContainer = (VulkanTextureHandle *)texture;
|
||||||
VulkanTexture *vulkanTexture = vulkanTextureContainer->vulkanTexture;
|
VulkanTexture *vulkanTexture = vulkanTextureContainer->vulkanTexture;
|
||||||
|
|
||||||
SDL_LockMutex(renderer->disposeLock);
|
SDL_LockMutex(renderer->disposeLock);
|
||||||
|
@ -7310,7 +7360,7 @@ static void VULKAN_QueueDestroyGpuBuffer(
|
||||||
Refresh_GpuBuffer *gpuBuffer
|
Refresh_GpuBuffer *gpuBuffer
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanBufferContainer *vulkanBufferContainer = (VulkanBufferContainer*) gpuBuffer;
|
VulkanBufferHandle *vulkanBufferContainer = (VulkanBufferHandle*) gpuBuffer;
|
||||||
VulkanBuffer *vulkanBuffer = vulkanBufferContainer->vulkanBuffer;
|
VulkanBuffer *vulkanBuffer = vulkanBufferContainer->vulkanBuffer;
|
||||||
|
|
||||||
SDL_LockMutex(renderer->disposeLock);
|
SDL_LockMutex(renderer->disposeLock);
|
||||||
|
@ -7328,19 +7378,19 @@ static void VULKAN_QueueDestroyTransferBuffer(
|
||||||
Refresh_TransferBuffer *transferBuffer
|
Refresh_TransferBuffer *transferBuffer
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer*) transferBuffer;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
SDL_LockMutex(renderer->disposeLock);
|
SDL_LockMutex(renderer->disposeLock);
|
||||||
|
|
||||||
for (i = 0; i < transferBufferContainer->bufferCount; i += 1)
|
for (i = 0; i < transferBufferContainer->bufferCount; i += 1)
|
||||||
{
|
{
|
||||||
VULKAN_INTERNAL_QueueDestroyBuffer(renderer, transferBufferContainer->backingBuffers[i]->vulkanBuffer);
|
VULKAN_INTERNAL_QueueDestroyBuffer(renderer, transferBufferContainer->bufferHandles[i]->vulkanBuffer);
|
||||||
SDL_free(transferBufferContainer->backingBuffers[i]);
|
SDL_free(transferBufferContainer->bufferHandles[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Containers are just client handles, so we can free immediately */
|
/* Containers are just client handles, so we can free immediately */
|
||||||
SDL_free(transferBufferContainer->backingBuffers);
|
SDL_free(transferBufferContainer->bufferHandles);
|
||||||
SDL_free(transferBufferContainer);
|
SDL_free(transferBufferContainer);
|
||||||
|
|
||||||
SDL_UnlockMutex(renderer->disposeLock);
|
SDL_UnlockMutex(renderer->disposeLock);
|
||||||
|
@ -7433,7 +7483,7 @@ static VkRenderPass VULKAN_INTERNAL_FetchRenderPass(
|
||||||
|
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
{
|
{
|
||||||
hash.colorTargetDescriptions[i].format = ((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture->format;
|
hash.colorTargetDescriptions[i].format = ((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture->format;
|
||||||
hash.colorTargetDescriptions[i].clearColor = colorAttachmentInfos[i].clearColor;
|
hash.colorTargetDescriptions[i].clearColor = colorAttachmentInfos[i].clearColor;
|
||||||
hash.colorTargetDescriptions[i].loadOp = colorAttachmentInfos[i].loadOp;
|
hash.colorTargetDescriptions[i].loadOp = colorAttachmentInfos[i].loadOp;
|
||||||
hash.colorTargetDescriptions[i].storeOp = colorAttachmentInfos[i].storeOp;
|
hash.colorTargetDescriptions[i].storeOp = colorAttachmentInfos[i].storeOp;
|
||||||
|
@ -7442,7 +7492,7 @@ static VkRenderPass VULKAN_INTERNAL_FetchRenderPass(
|
||||||
hash.colorAttachmentSampleCount = REFRESH_SAMPLECOUNT_1;
|
hash.colorAttachmentSampleCount = REFRESH_SAMPLECOUNT_1;
|
||||||
if (colorAttachmentCount > 0)
|
if (colorAttachmentCount > 0)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) colorAttachmentInfos[0].texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) colorAttachmentInfos[0].texture)->vulkanTexture;
|
||||||
if (texture->msaaTex != NULL)
|
if (texture->msaaTex != NULL)
|
||||||
{
|
{
|
||||||
hash.colorAttachmentSampleCount = texture->msaaTex->sampleCount;
|
hash.colorAttachmentSampleCount = texture->msaaTex->sampleCount;
|
||||||
|
@ -7461,7 +7511,7 @@ static VkRenderPass VULKAN_INTERNAL_FetchRenderPass(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hash.depthStencilTargetDescription.format = ((VulkanTextureContainer*) depthStencilAttachmentInfo->texture)->vulkanTexture->format;
|
hash.depthStencilTargetDescription.format = ((VulkanTextureHandle*) depthStencilAttachmentInfo->texture)->vulkanTexture->format;
|
||||||
hash.depthStencilTargetDescription.loadOp = depthStencilAttachmentInfo->loadOp;
|
hash.depthStencilTargetDescription.loadOp = depthStencilAttachmentInfo->loadOp;
|
||||||
hash.depthStencilTargetDescription.storeOp = depthStencilAttachmentInfo->storeOp;
|
hash.depthStencilTargetDescription.storeOp = depthStencilAttachmentInfo->storeOp;
|
||||||
hash.depthStencilTargetDescription.stencilLoadOp = depthStencilAttachmentInfo->stencilLoadOp;
|
hash.depthStencilTargetDescription.stencilLoadOp = depthStencilAttachmentInfo->stencilLoadOp;
|
||||||
|
@ -7529,7 +7579,7 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
|
||||||
|
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
||||||
|
|
||||||
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
||||||
renderer,
|
renderer,
|
||||||
|
@ -7565,7 +7615,7 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
||||||
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
||||||
renderer,
|
renderer,
|
||||||
texture,
|
texture,
|
||||||
|
@ -7601,7 +7651,7 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
|
||||||
|
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
||||||
|
|
||||||
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
||||||
renderer,
|
renderer,
|
||||||
|
@ -7635,7 +7685,7 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
|
||||||
|
|
||||||
if (depthStencilAttachmentInfo != NULL)
|
if (depthStencilAttachmentInfo != NULL)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
||||||
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
renderTarget = VULKAN_INTERNAL_FetchRenderTarget(
|
||||||
renderer,
|
renderer,
|
||||||
texture,
|
texture,
|
||||||
|
@ -7783,7 +7833,7 @@ static void VULKAN_BeginRenderPass(
|
||||||
|
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
||||||
w = texture->dimensions.width >> colorAttachmentInfos[i].level;
|
w = texture->dimensions.width >> colorAttachmentInfos[i].level;
|
||||||
h = texture->dimensions.height >> colorAttachmentInfos[i].level;
|
h = texture->dimensions.height >> colorAttachmentInfos[i].level;
|
||||||
|
|
||||||
|
@ -7800,7 +7850,7 @@ static void VULKAN_BeginRenderPass(
|
||||||
|
|
||||||
if (depthStencilAttachmentInfo != NULL)
|
if (depthStencilAttachmentInfo != NULL)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
||||||
w = texture->dimensions.width >> depthStencilAttachmentInfo->level;
|
w = texture->dimensions.width >> depthStencilAttachmentInfo->level;
|
||||||
h = texture->dimensions.height >> depthStencilAttachmentInfo->level;
|
h = texture->dimensions.height >> depthStencilAttachmentInfo->level;
|
||||||
|
|
||||||
|
@ -7841,7 +7891,7 @@ static void VULKAN_BeginRenderPass(
|
||||||
|
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
||||||
|
|
||||||
VULKAN_INTERNAL_ImageMemoryBarrier(
|
VULKAN_INTERNAL_ImageMemoryBarrier(
|
||||||
renderer,
|
renderer,
|
||||||
|
@ -7868,7 +7918,7 @@ static void VULKAN_BeginRenderPass(
|
||||||
|
|
||||||
if (depthStencilAttachmentInfo != NULL)
|
if (depthStencilAttachmentInfo != NULL)
|
||||||
{
|
{
|
||||||
texture = ((VulkanTextureContainer*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
||||||
depthAspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT;
|
depthAspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
|
|
||||||
if (IsStencilFormat(texture->format))
|
if (IsStencilFormat(texture->format))
|
||||||
|
@ -7908,7 +7958,7 @@ static void VULKAN_BeginRenderPass(
|
||||||
clearValues[i].color.float32[2] = colorAttachmentInfos[i].clearColor.z;
|
clearValues[i].color.float32[2] = colorAttachmentInfos[i].clearColor.z;
|
||||||
clearValues[i].color.float32[3] = colorAttachmentInfos[i].clearColor.w;
|
clearValues[i].color.float32[3] = colorAttachmentInfos[i].clearColor.w;
|
||||||
|
|
||||||
texture = ((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
texture = ((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
||||||
if (texture->msaaTex != NULL)
|
if (texture->msaaTex != NULL)
|
||||||
{
|
{
|
||||||
clearValues[i+1].color.float32[0] = colorAttachmentInfos[i].clearColor.x;
|
clearValues[i+1].color.float32[0] = colorAttachmentInfos[i].clearColor.x;
|
||||||
|
@ -7950,13 +8000,13 @@ static void VULKAN_BeginRenderPass(
|
||||||
for (i = 0; i < colorAttachmentCount; i += 1)
|
for (i = 0; i < colorAttachmentCount; i += 1)
|
||||||
{
|
{
|
||||||
vulkanCommandBuffer->renderPassColorTargetTextures[i] =
|
vulkanCommandBuffer->renderPassColorTargetTextures[i] =
|
||||||
((VulkanTextureContainer*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
((VulkanTextureHandle*) colorAttachmentInfos[i].texture)->vulkanTexture;
|
||||||
}
|
}
|
||||||
vulkanCommandBuffer->renderPassColorTargetCount = colorAttachmentCount;
|
vulkanCommandBuffer->renderPassColorTargetCount = colorAttachmentCount;
|
||||||
|
|
||||||
if (depthStencilAttachmentInfo != NULL)
|
if (depthStencilAttachmentInfo != NULL)
|
||||||
{
|
{
|
||||||
vulkanCommandBuffer->renderPassDepthTexture = ((VulkanTextureContainer*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
vulkanCommandBuffer->renderPassDepthTexture = ((VulkanTextureHandle*) depthStencilAttachmentInfo->texture)->vulkanTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set sensible default viewport state */
|
/* Set sensible default viewport state */
|
||||||
|
@ -8124,7 +8174,7 @@ static void VULKAN_BindVertexBuffers(
|
||||||
|
|
||||||
for (i = 0; i < bindingCount; i += 1)
|
for (i = 0; i < bindingCount; i += 1)
|
||||||
{
|
{
|
||||||
currentVulkanBuffer = ((VulkanBufferContainer*) pBuffers[i])->vulkanBuffer;
|
currentVulkanBuffer = ((VulkanBufferHandle*) pBuffers[i])->vulkanBuffer;
|
||||||
buffers[i] = currentVulkanBuffer->buffer;
|
buffers[i] = currentVulkanBuffer->buffer;
|
||||||
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, currentVulkanBuffer);
|
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, currentVulkanBuffer);
|
||||||
}
|
}
|
||||||
|
@ -8149,7 +8199,7 @@ static void VULKAN_BindIndexBuffer(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanBuffer* vulkanBuffer = ((VulkanBufferContainer*) gpuBuffer)->vulkanBuffer;
|
VulkanBuffer* vulkanBuffer = ((VulkanBufferHandle*) gpuBuffer)->vulkanBuffer;
|
||||||
|
|
||||||
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, vulkanBuffer);
|
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, vulkanBuffer);
|
||||||
|
|
||||||
|
@ -8222,7 +8272,7 @@ static void VULKAN_BindComputeBuffers(
|
||||||
|
|
||||||
for (i = 0; i < computePipeline->pipelineLayout->bufferDescriptorSetCache->bindingCount; i += 1)
|
for (i = 0; i < computePipeline->pipelineLayout->bufferDescriptorSetCache->bindingCount; i += 1)
|
||||||
{
|
{
|
||||||
currentVulkanBuffer = ((VulkanBufferContainer*) pBuffers[i])->vulkanBuffer;
|
currentVulkanBuffer = ((VulkanBufferHandle*) pBuffers[i])->vulkanBuffer;
|
||||||
|
|
||||||
descriptorBufferInfos[i].buffer = currentVulkanBuffer->buffer;
|
descriptorBufferInfos[i].buffer = currentVulkanBuffer->buffer;
|
||||||
descriptorBufferInfos[i].offset = 0;
|
descriptorBufferInfos[i].offset = 0;
|
||||||
|
@ -8270,7 +8320,7 @@ static void VULKAN_BindComputeTextures(
|
||||||
|
|
||||||
for (i = 0; i < computePipeline->pipelineLayout->imageDescriptorSetCache->bindingCount; i += 1)
|
for (i = 0; i < computePipeline->pipelineLayout->imageDescriptorSetCache->bindingCount; i += 1)
|
||||||
{
|
{
|
||||||
currentTexture = ((VulkanTextureContainer*) pTextures[i])->vulkanTexture;
|
currentTexture = ((VulkanTextureHandle*) pTextures[i])->vulkanTexture;
|
||||||
descriptorImageInfos[i].imageView = currentTexture->view;
|
descriptorImageInfos[i].imageView = currentTexture->view;
|
||||||
descriptorImageInfos[i].sampler = VK_NULL_HANDLE;
|
descriptorImageInfos[i].sampler = VK_NULL_HANDLE;
|
||||||
descriptorImageInfos[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
descriptorImageInfos[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
|
@ -8406,74 +8456,107 @@ static void VULKAN_EndComputePass(
|
||||||
vulkanCommandBuffer->currentComputePipeline = NULL;
|
vulkanCommandBuffer->currentComputePipeline = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VULKAN_INTERNAL_DiscardActiveTransferBuffer(
|
static void VULKAN_INTERNAL_DiscardActiveBuffer(
|
||||||
VulkanRenderer *renderer,
|
VulkanRenderer *renderer,
|
||||||
VulkanTransferBufferContainer *transferBufferContainer
|
VulkanBufferContainer *bufferContainer
|
||||||
) {
|
) {
|
||||||
VulkanBufferContainer *transferBuffer;
|
VulkanBufferHandle *bufferHandle;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
transferBufferContainer->activeBuffer->vulkanBuffer->preserveContentsOnDefrag = 0;
|
|
||||||
|
|
||||||
/* If a previously-discarded buffer is available, we can use that. */
|
/* If a previously-discarded buffer is available, we can use that. */
|
||||||
for (i = 0; i < transferBufferContainer->bufferCount; i += 1)
|
for (i = 0; i < bufferContainer->bufferCount; i += 1)
|
||||||
{
|
{
|
||||||
transferBuffer = transferBufferContainer->backingBuffers[i];
|
bufferHandle = bufferContainer->bufferHandles[i];
|
||||||
if (SDL_AtomicGet(&transferBuffer->vulkanBuffer->referenceCount) == 0)
|
if (SDL_AtomicGet(&bufferHandle->vulkanBuffer->referenceCount) == 0)
|
||||||
{
|
{
|
||||||
transferBufferContainer->activeBuffer = transferBuffer;
|
bufferContainer->activeBufferHandle = bufferHandle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No buffer is available, generate a new one. */
|
/* No buffer handle is available, generate a new one. */
|
||||||
transferBufferContainer->activeBuffer = VULKAN_INTERNAL_CreateBufferContainer(
|
bufferContainer->activeBufferHandle = VULKAN_INTERNAL_CreateBufferHandle(
|
||||||
renderer,
|
renderer,
|
||||||
transferBufferContainer->sizeInBytes,
|
bufferContainer->activeBufferHandle->vulkanBuffer->size,
|
||||||
RESOURCE_ACCESS_NONE,
|
RESOURCE_ACCESS_NONE,
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
bufferContainer->activeBufferHandle->vulkanBuffer->usage,
|
||||||
1,
|
bufferContainer->activeBufferHandle->vulkanBuffer->requireHostVisible,
|
||||||
1,
|
bufferContainer->activeBufferHandle->vulkanBuffer->preferHostLocal,
|
||||||
0,
|
bufferContainer->activeBufferHandle->vulkanBuffer->preferDeviceLocal
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
EXPAND_ARRAY_IF_NEEDED(
|
EXPAND_ARRAY_IF_NEEDED(
|
||||||
transferBufferContainer->backingBuffers,
|
bufferContainer->bufferHandles,
|
||||||
VulkanBufferContainer*,
|
VulkanBufferHandle*,
|
||||||
transferBufferContainer->bufferCount + 1,
|
bufferContainer->bufferCount + 1,
|
||||||
transferBufferContainer->bufferCapacity,
|
bufferContainer->bufferCapacity,
|
||||||
transferBufferContainer->bufferCapacity * 2
|
bufferContainer->bufferCapacity * 2
|
||||||
);
|
);
|
||||||
|
|
||||||
transferBufferContainer->backingBuffers[
|
bufferContainer->bufferHandles[
|
||||||
transferBufferContainer->bufferCount
|
bufferContainer->bufferCount
|
||||||
] = transferBufferContainer->activeBuffer;
|
] = bufferContainer->activeBufferHandle;
|
||||||
transferBufferContainer->bufferCount += 1;
|
bufferContainer->bufferCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VULKAN_SetData(
|
static void VULKAN_INTERNAL_DiscardActiveTexture(
|
||||||
|
VulkanRenderer *renderer,
|
||||||
|
VulkanTextureContainer *textureContainer
|
||||||
|
) {
|
||||||
|
VulkanTextureHandle *textureHandle;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
/* If a previously-discarded buffer is available, we can use that. */
|
||||||
|
for (i = 0; i < textureContainer->textureCount; i += 1)
|
||||||
|
{
|
||||||
|
textureHandle = textureContainer->textureHandles[i];
|
||||||
|
if (SDL_AtomicGet(&textureHandle->vulkanTexture->referenceCount) == 0)
|
||||||
|
{
|
||||||
|
textureContainer->activeTextureHandle = textureHandle;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No texture handle is available, generate a new one. */
|
||||||
|
textureContainer->activeTextureHandle = VULKAN_INTERNAL_CreateTexture(
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
EXPAND_ARRAY_IF_NEEDED(
|
||||||
|
textureContainer->textureHandles,
|
||||||
|
VulkanTextureHandle*,
|
||||||
|
textureContainer->textureCount + 1,
|
||||||
|
textureContainer->textureCapacity,
|
||||||
|
textureContainer->textureCapacity * 2
|
||||||
|
);
|
||||||
|
|
||||||
|
textureContainer->textureHandles[
|
||||||
|
textureContainer->textureCount
|
||||||
|
] = textureContainer->activeTextureHandle;
|
||||||
|
textureContainer->textureCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void VULKAN_SetTransferData(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
void* data,
|
void* data,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_BufferCopy *copyParams,
|
Refresh_BufferCopy *copyParams,
|
||||||
Refresh_SetDataOptions option
|
Refresh_TransferOptions option
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer*) transferBuffer;
|
||||||
|
|
||||||
if (option == REFRESH_SETDATAOPTIONS_SAFEDISCARD && SDL_AtomicGet(&transferBufferContainer->activeBuffer->vulkanBuffer->referenceCount) > 0)
|
if (option == REFRESH_TRANSFEROPTIONS_SAFEDISCARD && SDL_AtomicGet(&transferBufferContainer->activeBufferHandle->vulkanBuffer->referenceCount) > 0)
|
||||||
{
|
{
|
||||||
VULKAN_INTERNAL_DiscardActiveTransferBuffer(
|
VULKAN_INTERNAL_DiscardActiveBuffer(
|
||||||
renderer,
|
renderer,
|
||||||
transferBufferContainer
|
transferBufferContainer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *bufferPointer =
|
uint8_t *bufferPointer =
|
||||||
transferBufferContainer->activeBuffer->vulkanBuffer->usedRegion->allocation->mapPointer +
|
transferBufferContainer->activeBufferHandle->vulkanBuffer->usedRegion->allocation->mapPointer +
|
||||||
transferBufferContainer->activeBuffer->vulkanBuffer->usedRegion->resourceOffset +
|
transferBufferContainer->activeBufferHandle->vulkanBuffer->usedRegion->resourceOffset +
|
||||||
copyParams->dstOffset;
|
copyParams->dstOffset;
|
||||||
|
|
||||||
SDL_memcpy(
|
SDL_memcpy(
|
||||||
|
@ -8483,15 +8566,15 @@ static void VULKAN_SetData(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VULKAN_GetData(
|
static void VULKAN_GetTransferData(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
void* data,
|
void* data,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer*) transferBuffer;
|
||||||
VulkanBuffer *vulkanBuffer = transferBufferContainer->activeBuffer->vulkanBuffer;
|
VulkanBuffer *vulkanBuffer = transferBufferContainer->activeBufferHandle->vulkanBuffer;
|
||||||
|
|
||||||
uint8_t *bufferPointer =
|
uint8_t *bufferPointer =
|
||||||
vulkanBuffer->usedRegion->allocation->mapPointer +
|
vulkanBuffer->usedRegion->allocation->mapPointer +
|
||||||
|
@ -8503,8 +8586,6 @@ static void VULKAN_GetData(
|
||||||
bufferPointer,
|
bufferPointer,
|
||||||
copyParams->size
|
copyParams->size
|
||||||
);
|
);
|
||||||
|
|
||||||
vulkanBuffer->preserveContentsOnDefrag = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VULKAN_BeginCopyPass(
|
static void VULKAN_BeginCopyPass(
|
||||||
|
@ -8523,33 +8604,42 @@ static void VULKAN_UploadToTexture(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_TextureSlice *textureSlice,
|
Refresh_TextureSlice *textureSlice,
|
||||||
Refresh_BufferImageCopy *copyParams
|
Refresh_BufferImageCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer*) transferBuffer;
|
||||||
VulkanTexture *vulkanTexture = ((VulkanTextureContainer*) textureSlice->texture)->vulkanTexture;
|
VulkanTextureContainer *vulkanTextureContainer = (VulkanTextureContainer*) textureSlice->texture;
|
||||||
VkBufferImageCopy imageCopy;
|
VkBufferImageCopy imageCopy;
|
||||||
|
|
||||||
|
if (option == REFRESH_COPYOPTIONS_SAFEDISCARD && SDL_AtomicGet(&vulkanTextureContainer->activeTextureHandle->vulkanTexture->referenceCount) > 0)
|
||||||
|
{
|
||||||
|
VULKAN_INTERNAL_DiscardActiveTexture(
|
||||||
|
renderer,
|
||||||
|
vulkanTextureContainer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
VULKAN_INTERNAL_BufferMemoryBarrier(
|
VULKAN_INTERNAL_BufferMemoryBarrier(
|
||||||
renderer,
|
renderer,
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
RESOURCE_ACCESS_TRANSFER_READ,
|
RESOURCE_ACCESS_TRANSFER_READ,
|
||||||
transferBufferContainer->activeBuffer->vulkanBuffer
|
transferBufferContainer->activeBufferHandle->vulkanBuffer
|
||||||
);
|
);
|
||||||
|
|
||||||
VULKAN_INTERNAL_ImageMemoryBarrier(
|
VULKAN_INTERNAL_ImageMemoryBarrier(
|
||||||
renderer,
|
renderer,
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
RESOURCE_ACCESS_TRANSFER_WRITE,
|
RESOURCE_ACCESS_TRANSFER_WRITE,
|
||||||
vulkanTexture->aspectFlags,
|
vulkanTextureContainer->activeTextureHandle->vulkanTexture->aspectFlags,
|
||||||
0,
|
0,
|
||||||
vulkanTexture->layerCount,
|
vulkanTextureContainer->activeTextureHandle->vulkanTexture->layerCount,
|
||||||
0,
|
0,
|
||||||
vulkanTexture->levelCount,
|
vulkanTextureContainer->activeTextureHandle->vulkanTexture->levelCount,
|
||||||
0,
|
0,
|
||||||
vulkanTexture->image,
|
vulkanTextureContainer->activeTextureHandle->vulkanTexture->image,
|
||||||
&vulkanTexture->resourceAccessType
|
&vulkanTextureContainer->activeTextureHandle->vulkanTexture->resourceAccessType
|
||||||
);
|
);
|
||||||
|
|
||||||
imageCopy.imageExtent.width = textureSlice->w;
|
imageCopy.imageExtent.width = textureSlice->w;
|
||||||
|
@ -8558,7 +8648,7 @@ static void VULKAN_UploadToTexture(
|
||||||
imageCopy.imageOffset.x = textureSlice->x;
|
imageCopy.imageOffset.x = textureSlice->x;
|
||||||
imageCopy.imageOffset.y = textureSlice->y;
|
imageCopy.imageOffset.y = textureSlice->y;
|
||||||
imageCopy.imageOffset.z = textureSlice->z;
|
imageCopy.imageOffset.z = textureSlice->z;
|
||||||
imageCopy.imageSubresource.aspectMask = vulkanTexture->aspectFlags;
|
imageCopy.imageSubresource.aspectMask = vulkanTextureContainer->activeTextureHandle->vulkanTexture->aspectFlags;
|
||||||
imageCopy.imageSubresource.baseArrayLayer = textureSlice->baseLayer;
|
imageCopy.imageSubresource.baseArrayLayer = textureSlice->baseLayer;
|
||||||
imageCopy.imageSubresource.layerCount = textureSlice->layerCount;
|
imageCopy.imageSubresource.layerCount = textureSlice->layerCount;
|
||||||
imageCopy.imageSubresource.mipLevel = textureSlice->mipLevel;
|
imageCopy.imageSubresource.mipLevel = textureSlice->mipLevel;
|
||||||
|
@ -8568,16 +8658,16 @@ static void VULKAN_UploadToTexture(
|
||||||
|
|
||||||
renderer->vkCmdCopyBufferToImage(
|
renderer->vkCmdCopyBufferToImage(
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
transferBufferContainer->activeBuffer->vulkanBuffer->buffer,
|
transferBufferContainer->activeBufferHandle->vulkanBuffer->buffer,
|
||||||
vulkanTexture->image,
|
vulkanTextureContainer->activeTextureHandle->vulkanTexture->image,
|
||||||
AccessMap[vulkanTexture->resourceAccessType].imageLayout,
|
AccessMap[vulkanTextureContainer->activeTextureHandle->vulkanTexture->resourceAccessType].imageLayout,
|
||||||
1,
|
1,
|
||||||
&imageCopy
|
&imageCopy
|
||||||
);
|
);
|
||||||
|
|
||||||
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, transferBufferContainer->activeBuffer->vulkanBuffer);
|
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, transferBufferContainer->activeBufferHandle->vulkanBuffer);
|
||||||
VULKAN_INTERNAL_TrackTexture(renderer, vulkanCommandBuffer, vulkanTexture);
|
VULKAN_INTERNAL_TrackTexture(renderer, vulkanCommandBuffer, vulkanTextureContainer->activeTextureHandle->vulkanTexture);
|
||||||
VULKAN_INTERNAL_TrackCopiedTexture(renderer, vulkanCommandBuffer, vulkanTexture);
|
VULKAN_INTERNAL_TrackCopiedTexture(renderer, vulkanCommandBuffer, vulkanTextureContainer->activeTextureHandle->vulkanTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VULKAN_UploadToBuffer(
|
static void VULKAN_UploadToBuffer(
|
||||||
|
@ -8585,19 +8675,20 @@ static void VULKAN_UploadToBuffer(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
Refresh_TransferBuffer *transferBuffer,
|
Refresh_TransferBuffer *transferBuffer,
|
||||||
Refresh_GpuBuffer *gpuBuffer,
|
Refresh_GpuBuffer *gpuBuffer,
|
||||||
Refresh_BufferCopy *copyParams
|
Refresh_BufferCopy *copyParams,
|
||||||
|
Refresh_CopyOptions option
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer*) transferBuffer;
|
||||||
VulkanBuffer *vulkanGpuBuffer = ((VulkanBufferContainer*) gpuBuffer)->vulkanBuffer;
|
VulkanBuffer *vulkanGpuBuffer = ((VulkanBufferHandle*) gpuBuffer)->vulkanBuffer;
|
||||||
VkBufferCopy bufferCopy;
|
VkBufferCopy bufferCopy;
|
||||||
|
|
||||||
VULKAN_INTERNAL_BufferMemoryBarrier(
|
VULKAN_INTERNAL_BufferMemoryBarrier(
|
||||||
renderer,
|
renderer,
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
RESOURCE_ACCESS_TRANSFER_READ,
|
RESOURCE_ACCESS_TRANSFER_READ,
|
||||||
transferBufferContainer->activeBuffer->vulkanBuffer
|
transferBufferContainer->activeBufferHandle->vulkanBuffer
|
||||||
);
|
);
|
||||||
|
|
||||||
VULKAN_INTERNAL_BufferMemoryBarrier(
|
VULKAN_INTERNAL_BufferMemoryBarrier(
|
||||||
|
@ -8613,13 +8704,13 @@ static void VULKAN_UploadToBuffer(
|
||||||
|
|
||||||
renderer->vkCmdCopyBuffer(
|
renderer->vkCmdCopyBuffer(
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
transferBufferContainer->activeBuffer->vulkanBuffer->buffer,
|
transferBufferContainer->activeBufferHandle->vulkanBuffer->buffer,
|
||||||
vulkanGpuBuffer->buffer,
|
vulkanGpuBuffer->buffer,
|
||||||
1,
|
1,
|
||||||
&bufferCopy
|
&bufferCopy
|
||||||
);
|
);
|
||||||
|
|
||||||
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, transferBufferContainer->activeBuffer->vulkanBuffer);
|
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, transferBufferContainer->activeBufferHandle->vulkanBuffer);
|
||||||
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, vulkanGpuBuffer);
|
VULKAN_INTERNAL_TrackBuffer(renderer, vulkanCommandBuffer, vulkanGpuBuffer);
|
||||||
VULKAN_INTERNAL_TrackCopiedBuffer(renderer, vulkanCommandBuffer, vulkanGpuBuffer);
|
VULKAN_INTERNAL_TrackCopiedBuffer(renderer, vulkanCommandBuffer, vulkanGpuBuffer);
|
||||||
}
|
}
|
||||||
|
@ -8633,7 +8724,7 @@ static void VULKAN_DownloadFromTexture(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanTexture *vulkanTexture = ((VulkanTextureContainer*) textureSlice->texture)->vulkanTexture;
|
VulkanTexture *vulkanTexture = ((VulkanTextureHandle*) textureSlice->texture)->vulkanTexture;
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
||||||
VkBufferImageCopy imageCopy;
|
VkBufferImageCopy imageCopy;
|
||||||
|
|
||||||
|
@ -8698,7 +8789,7 @@ static void VULKAN_DownloadFromBuffer(
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
VulkanTransferBufferContainer *transferBufferContainer = (VulkanTransferBufferContainer*) transferBuffer;
|
||||||
VulkanBuffer *vulkanGpuBuffer = ((VulkanBufferContainer*) gpuBuffer)->vulkanBuffer;
|
VulkanBuffer *vulkanGpuBuffer = ((VulkanBufferHandle*) gpuBuffer)->vulkanBuffer;
|
||||||
VkBufferCopy bufferCopy;
|
VkBufferCopy bufferCopy;
|
||||||
|
|
||||||
VULKAN_INTERNAL_BufferMemoryBarrier(
|
VULKAN_INTERNAL_BufferMemoryBarrier(
|
||||||
|
@ -8742,8 +8833,8 @@ static void VULKAN_CopyTextureToTexture(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanTexture *srcTexture = ((VulkanTextureContainer*) source->texture)->vulkanTexture;
|
VulkanTexture *srcTexture = ((VulkanTextureHandle*) source->texture)->vulkanTexture;
|
||||||
VulkanTexture *dstTexture = ((VulkanTextureContainer*) destination->texture)->vulkanTexture;
|
VulkanTexture *dstTexture = ((VulkanTextureHandle*) destination->texture)->vulkanTexture;
|
||||||
VkImageCopy imageCopy;
|
VkImageCopy imageCopy;
|
||||||
|
|
||||||
VULKAN_INTERNAL_ImageMemoryBarrier(
|
VULKAN_INTERNAL_ImageMemoryBarrier(
|
||||||
|
@ -8817,8 +8908,8 @@ static void VULKAN_CopyTextureToBuffer(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanTexture *vulkanTexture = ((VulkanTextureContainer*) textureSlice->texture)->vulkanTexture;
|
VulkanTexture *vulkanTexture = ((VulkanTextureHandle*) textureSlice->texture)->vulkanTexture;
|
||||||
VulkanBuffer *vulkanBuffer = ((VulkanBufferContainer*) gpuBuffer)->vulkanBuffer;
|
VulkanBuffer *vulkanBuffer = ((VulkanBufferHandle*) gpuBuffer)->vulkanBuffer;
|
||||||
VkBufferImageCopy imageCopy;
|
VkBufferImageCopy imageCopy;
|
||||||
|
|
||||||
VULKAN_INTERNAL_ImageMemoryBarrier(
|
VULKAN_INTERNAL_ImageMemoryBarrier(
|
||||||
|
@ -8880,8 +8971,8 @@ static void VULKAN_CopyBufferToTexture(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanBuffer *vulkanBuffer = ((VulkanBufferContainer*) gpuBuffer)->vulkanBuffer;
|
VulkanBuffer *vulkanBuffer = ((VulkanBufferHandle*) gpuBuffer)->vulkanBuffer;
|
||||||
VulkanTexture *vulkanTexture = ((VulkanTextureContainer*) textureSlice->texture)->vulkanTexture;
|
VulkanTexture *vulkanTexture = ((VulkanTextureHandle*) textureSlice->texture)->vulkanTexture;
|
||||||
VkBufferImageCopy imageCopy;
|
VkBufferImageCopy imageCopy;
|
||||||
|
|
||||||
VULKAN_INTERNAL_BufferMemoryBarrier(
|
VULKAN_INTERNAL_BufferMemoryBarrier(
|
||||||
|
@ -8943,8 +9034,8 @@ static void VULKAN_CopyBufferToBuffer(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanBuffer *vulkanSrcBuffer = ((VulkanBufferContainer*) source)->vulkanBuffer;
|
VulkanBuffer *vulkanSrcBuffer = ((VulkanBufferHandle*) source)->vulkanBuffer;
|
||||||
VulkanBuffer *vulkanDstBuffer = ((VulkanBufferContainer*) destination)->vulkanBuffer;
|
VulkanBuffer *vulkanDstBuffer = ((VulkanBufferHandle*) destination)->vulkanBuffer;
|
||||||
VkBufferCopy bufferCopy;
|
VkBufferCopy bufferCopy;
|
||||||
|
|
||||||
VULKAN_INTERNAL_BufferMemoryBarrier(
|
VULKAN_INTERNAL_BufferMemoryBarrier(
|
||||||
|
@ -8986,7 +9077,7 @@ static void VULKAN_GenerateMipmaps(
|
||||||
) {
|
) {
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanTexture *vulkanTexture = ((VulkanTextureContainer*) texture)->vulkanTexture;
|
VulkanTexture *vulkanTexture = ((VulkanTextureHandle*) texture)->vulkanTexture;
|
||||||
VulkanResourceAccessType *levelAccessType;
|
VulkanResourceAccessType *levelAccessType;
|
||||||
VkImageBlit blit;
|
VkImageBlit blit;
|
||||||
uint32_t level;
|
uint32_t level;
|
||||||
|
@ -9544,7 +9635,7 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture(
|
||||||
WindowData *windowData;
|
WindowData *windowData;
|
||||||
VulkanSwapchainData *swapchainData;
|
VulkanSwapchainData *swapchainData;
|
||||||
VkResult acquireResult = VK_SUCCESS;
|
VkResult acquireResult = VK_SUCCESS;
|
||||||
VulkanTextureContainer *swapchainTextureContainer = NULL;
|
VulkanTextureHandle *swapchainTextureContainer = NULL;
|
||||||
VulkanPresentData *presentData;
|
VulkanPresentData *presentData;
|
||||||
|
|
||||||
windowData = VULKAN_INTERNAL_FetchWindowData(windowHandle);
|
windowData = VULKAN_INTERNAL_FetchWindowData(windowHandle);
|
||||||
|
@ -10348,11 +10439,11 @@ static uint8_t VULKAN_INTERNAL_DefragmentMemory(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-point original container to new buffer */
|
/* re-point original container to new buffer */
|
||||||
if (currentRegion->vulkanBuffer->container != NULL)
|
if (currentRegion->vulkanBuffer->handle != NULL)
|
||||||
{
|
{
|
||||||
newBuffer->container = currentRegion->vulkanBuffer->container;
|
newBuffer->handle = currentRegion->vulkanBuffer->handle;
|
||||||
newBuffer->container->vulkanBuffer = newBuffer;
|
newBuffer->handle->vulkanBuffer = newBuffer;
|
||||||
currentRegion->vulkanBuffer->container = NULL;
|
currentRegion->vulkanBuffer->handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VULKAN_INTERNAL_QueueDestroyBuffer(renderer, currentRegion->vulkanBuffer);
|
VULKAN_INTERNAL_QueueDestroyBuffer(renderer, currentRegion->vulkanBuffer);
|
||||||
|
@ -10464,9 +10555,9 @@ static uint8_t VULKAN_INTERNAL_DefragmentMemory(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-point original container to new texture */
|
/* re-point original container to new texture */
|
||||||
newTexture->container = currentRegion->vulkanTexture->container;
|
newTexture->handle = currentRegion->vulkanTexture->handle;
|
||||||
newTexture->container->vulkanTexture = newTexture;
|
newTexture->handle->vulkanTexture = newTexture;
|
||||||
currentRegion->vulkanTexture->container = NULL;
|
currentRegion->vulkanTexture->handle = NULL;
|
||||||
|
|
||||||
VULKAN_INTERNAL_QueueDestroyTexture(renderer, currentRegion->vulkanTexture);
|
VULKAN_INTERNAL_QueueDestroyTexture(renderer, currentRegion->vulkanTexture);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue