Compare commits

...

26 Commits

Author SHA1 Message Date
cosmonaut 9d1059ed0e fix stencil state
continuous-integration/drone/push Build is passing Details
2024-03-02 23:11:07 -08:00
cosmonaut 7b0ed4278d correct stencil API change
continuous-integration/drone/push Build is failing Details
2024-03-02 23:00:44 -08:00
cosmonaut 02c0d85885 Resource containers, new bindings API, WriteOptions (#51)
continuous-integration/drone/push Build is passing Details
Reviewed-on: #51
2024-03-02 09:09:49 +00:00
cosmonaut 695abd4139 alter vulkan defrag strategy
continuous-integration/drone/push Build is passing Details
2024-02-27 00:16:06 -08:00
cosmonaut 2361cec274 actually assign len in Refresh_Image_Info
continuous-integration/drone/push Build is passing Details
2024-02-25 01:44:19 -08:00
cosmonaut 899f961461 prefer host-local instead of require host-local
continuous-integration/drone/push Build is passing Details
2024-02-24 23:07:22 -08:00
cosmonaut 9d36ddaac1 Refresh2 Vulkan Implementation (#50)
continuous-integration/drone/push Build is passing Details
Reviewed-on: #50
2024-02-23 23:46:02 +00:00
cosmonaut 4e1705d1bd specify buffer type in param name
continuous-integration/drone/push Build is failing Details
2024-02-23 09:50:48 -08:00
cosmonaut 2f57a05c85 rename CpuBuffer to TransferBuffer
continuous-integration/drone/push Build is failing Details
2024-02-23 09:42:31 -08:00
cosmonaut 2798067d54 add Refresh_Image_Info
continuous-integration/drone/push Build is failing Details
2024-02-23 00:03:17 -08:00
cosmonaut d34310a7df fix Refresh_CreateCpuBuffer in Refresh.c
continuous-integration/drone/push Build is failing Details
2024-02-22 10:34:48 -08:00
cosmonaut 73d927791a rename DISCARD to SAFEDISCARD
continuous-integration/drone/push Build is failing Details
2024-02-22 10:32:24 -08:00
cosmonaut 72ff9407c4 update CreateCpuBuffer in Refresh_Driver
continuous-integration/drone/push Build is failing Details
2024-02-21 10:59:31 -08:00
cosmonaut 52b99ea49a fix tabbing
continuous-integration/drone/push Build is failing Details
2024-02-17 20:23:09 -08:00
cosmonaut 94f181787b CpuBuffer Set/Get API
continuous-integration/drone/push Build is failing Details
2024-02-17 20:21:52 -08:00
cosmonaut c44a095bca CreateCpuBuffer writes a data pointer
continuous-integration/drone/push Build is failing Details
2024-02-16 18:53:52 -08:00
cosmonaut fdb29ade82 remove map/unmap calls
continuous-integration/drone/push Build is failing Details
2024-02-16 18:44:16 -08:00
cosmonaut 61386a27ba update Refresh_Driver.h and Refresh.c
continuous-integration/drone/push Build is failing Details
2024-02-16 17:54:58 -08:00
cosmonaut ce4d294a31 rework Push_Uniforms and Draw calls
continuous-integration/drone/push Build is failing Details
2024-02-16 17:51:18 -08:00
cosmonaut c779718967 buffer bindings should actually use uint64_t
continuous-integration/drone/push Build is failing Details
2024-02-15 20:05:18 -08:00
cosmonaut 218587bb6a rearrange copy params order
continuous-integration/drone/push Build is failing Details
2024-02-15 17:27:40 -08:00
cosmonaut 80914e9c38 add command buffer to Pass functions
continuous-integration/drone/push Build is failing Details
2024-02-15 16:48:26 -08:00
cosmonaut 342a7f9ef6 update ASSIGN_DRIVER_FUNC calls
continuous-integration/drone/push Build is failing Details
2024-02-15 16:34:52 -08:00
cosmonaut 5b82609565 some comment clarifications
continuous-integration/drone/push Build is failing Details
2024-02-13 12:25:53 -08:00
cosmonaut 10c0b5ae37 a few more API revisions
continuous-integration/drone/push Build is failing Details
2024-02-12 11:00:06 -08:00
cosmonaut 6f31f17be1 proposed API revision
continuous-integration/drone/push Build is failing Details
2024-02-12 00:04:02 -08:00
7 changed files with 3693 additions and 3757 deletions

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,20 @@ REFRESHAPI uint8_t* Refresh_Image_Load(
int32_t *len
);
/* Get image dimensions without fully decoding the image.
*
* w: Filled with the width of the image.
* h: Filled with the height of the image.
* len: Filled with the length of pixel data in bytes.
*/
REFRESHAPI uint8_t Refresh_Image_Info(
uint8_t *bufferPtr,
int32_t bufferLength,
int32_t *w,
int32_t *h,
int32_t *len
);
/* Frees memory returned by Refresh_Image_Load. Do NOT free the memory yourself!
*
* mem: A pointer previously returned by Refresh_Image_LoadPNG.

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TargetName>refreshc</TargetName>
<PublishAot>true</PublishAot>
</PropertyGroup>

View File

@ -196,110 +196,7 @@ void Refresh_DestroyDevice(Refresh_Device *device)
device->DestroyDevice(device);
}
void Refresh_DrawIndexedPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
) {
NULL_RETURN(device);
device->DrawIndexedPrimitives(
device->driverData,
commandBuffer,
baseVertex,
startIndex,
primitiveCount,
vertexParamOffset,
fragmentParamOffset
);
}
void Refresh_DrawInstancedPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
) {
NULL_RETURN(device);
device->DrawInstancedPrimitives(
device->driverData,
commandBuffer,
baseVertex,
startIndex,
primitiveCount,
instanceCount,
vertexParamOffset,
fragmentParamOffset
);
}
void Refresh_DrawPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t vertexStart,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
) {
NULL_RETURN(device);
device->DrawPrimitives(
device->driverData,
commandBuffer,
vertexStart,
primitiveCount,
vertexParamOffset,
fragmentParamOffset
);
}
void Refresh_DrawPrimitivesIndirect(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint32_t offsetInBytes,
uint32_t drawCount,
uint32_t stride,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
) {
NULL_RETURN(device);
device->DrawPrimitivesIndirect(
device->driverData,
commandBuffer,
buffer,
offsetInBytes,
drawCount,
stride,
vertexParamOffset,
fragmentParamOffset
);
}
void Refresh_DispatchCompute(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t groupCountX,
uint32_t groupCountY,
uint32_t groupCountZ,
uint32_t computeParamOffset
) {
NULL_RETURN(device);
device->DispatchCompute(
device->driverData,
commandBuffer,
groupCountX,
groupCountY,
groupCountZ,
computeParamOffset
);
}
/* State Creation */
Refresh_ComputePipeline* Refresh_CreateComputePipeline(
Refresh_Device *device,
@ -398,215 +295,31 @@ Refresh_Texture* Refresh_CreateTexture(
);
}
Refresh_Buffer* Refresh_CreateBuffer(
Refresh_GpuBuffer* Refresh_CreateGpuBuffer(
Refresh_Device *device,
Refresh_BufferUsageFlags usageFlags,
uint32_t sizeInBytes
) {
NULL_RETURN_NULL(device);
return device->CreateBuffer(
return device->CreateGpuBuffer(
device->driverData,
usageFlags,
sizeInBytes
);
}
void Refresh_SetTextureData(
Refresh_TransferBuffer* Refresh_CreateTransferBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
void *data,
uint32_t dataLengthInBytes
uint32_t sizeInBytes
) {
NULL_RETURN(device);
device->SetTextureData(
NULL_RETURN_NULL(device);
return device->CreateTransferBuffer(
device->driverData,
commandBuffer,
textureSlice,
data,
dataLengthInBytes
sizeInBytes
);
}
void Refresh_SetTextureDataYUV(
Refresh_Device *device,
Refresh_CommandBuffer* commandBuffer,
Refresh_Texture *y,
Refresh_Texture *u,
Refresh_Texture *v,
uint32_t yWidth,
uint32_t yHeight,
uint32_t uvWidth,
uint32_t uvHeight,
void *yDataPtr,
void *uDataPtr,
void *vDataPtr,
uint32_t yDataLength,
uint32_t uvDataLength,
uint32_t yStride,
uint32_t uvStride
) {
NULL_RETURN(device);
device->SetTextureDataYUV(
device->driverData,
commandBuffer,
y,
u,
v,
yWidth,
yHeight,
uvWidth,
uvHeight,
yDataPtr,
uDataPtr,
vDataPtr,
yDataLength,
uvDataLength,
yStride,
uvStride
);
}
void Refresh_CopyTextureToTexture(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *sourceTextureSlice,
Refresh_TextureSlice *destinationTextureSlice,
Refresh_Filter filter
) {
NULL_RETURN(device);
device->CopyTextureToTexture(
device->driverData,
commandBuffer,
sourceTextureSlice,
destinationTextureSlice,
filter
);
}
void Refresh_CopyTextureToBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
Refresh_Buffer *buffer
) {
NULL_RETURN(device);
device->CopyTextureToBuffer(
device->driverData,
commandBuffer,
textureSlice,
buffer
);
}
void Refresh_SetBufferData(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint32_t offsetInBytes,
void* data,
uint32_t dataLength
) {
NULL_RETURN(device);
device->SetBufferData(
device->driverData,
commandBuffer,
buffer,
offsetInBytes,
data,
dataLength
);
}
uint32_t Refresh_PushVertexShaderUniforms(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
if (device == NULL) { return 0; }
return device->PushVertexShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
}
uint32_t Refresh_PushFragmentShaderUniforms(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
if (device == NULL) { return 0; }
return device->PushFragmentShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
}
uint32_t Refresh_PushComputeShaderUniforms(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
if (device == NULL) { return 0; }
return device->PushComputeShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
}
void Refresh_BindVertexSamplers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
) {
NULL_RETURN(device);
device->BindVertexSamplers(
device->driverData,
commandBuffer,
pTextures,
pSamplers
);
}
void Refresh_BindFragmentSamplers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
) {
NULL_RETURN(device);
device->BindFragmentSamplers(
device->driverData,
commandBuffer,
pTextures,
pSamplers
);
}
void Refresh_GetBufferData(
Refresh_Device *device,
Refresh_Buffer *buffer,
void *data,
uint32_t dataLengthInBytes
) {
NULL_RETURN(device);
device->GetBufferData(
device->driverData,
buffer,
data,
dataLengthInBytes
);
}
/* Disposal */
void Refresh_QueueDestroyTexture(
Refresh_Device *device,
@ -630,14 +343,25 @@ void Refresh_QueueDestroySampler(
);
}
void Refresh_QueueDestroyBuffer(
void Refresh_QueueDestroyGpuBuffer(
Refresh_Device *device,
Refresh_Buffer *buffer
Refresh_GpuBuffer *gpuBuffer
) {
NULL_RETURN(device);
device->QueueDestroyBuffer(
device->QueueDestroyGpuBuffer(
device->driverData,
buffer
gpuBuffer
);
}
void Refresh_QueueDestroyTransferBuffer(
Refresh_Device *device,
Refresh_TransferBuffer *transferBuffer
) {
NULL_RETURN(device);
device->QueueDestroyTransferBuffer(
device->driverData,
transferBuffer
);
}
@ -674,6 +398,8 @@ void Refresh_QueueDestroyGraphicsPipeline(
);
}
/* Render Pass */
void Refresh_BeginRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
@ -691,14 +417,16 @@ void Refresh_BeginRenderPass(
);
}
void Refresh_EndRenderPass(
void Refresh_BindGraphicsPipeline(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline
) {
NULL_RETURN(device);
device->EndRenderPass(
device->BindGraphicsPipeline(
device->driverData,
commandBuffer
commandBuffer,
graphicsPipeline
);
}
@ -728,26 +456,12 @@ void Refresh_SetScissor(
);
}
void Refresh_BindGraphicsPipeline(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline
) {
NULL_RETURN(device);
device->BindGraphicsPipeline(
device->driverData,
commandBuffer,
graphicsPipeline
);
}
void Refresh_BindVertexBuffers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t firstBinding,
uint32_t bindingCount,
Refresh_Buffer **pBuffers,
uint64_t *pOffsets
Refresh_BufferBinding *pBindings
) {
NULL_RETURN(device);
device->BindVertexBuffers(
@ -755,28 +469,175 @@ void Refresh_BindVertexBuffers(
commandBuffer,
firstBinding,
bindingCount,
pBuffers,
pOffsets
pBindings
);
}
void Refresh_BindIndexBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint64_t offset,
Refresh_BufferBinding *pBinding,
Refresh_IndexElementSize indexElementSize
) {
NULL_RETURN(device);
device->BindIndexBuffer(
device->driverData,
commandBuffer,
buffer,
offset,
pBinding,
indexElementSize
);
}
void Refresh_BindVertexSamplers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSamplerBinding *pBindings
) {
NULL_RETURN(device);
device->BindVertexSamplers(
device->driverData,
commandBuffer,
pBindings
);
}
void Refresh_BindFragmentSamplers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSamplerBinding *pBindings
) {
NULL_RETURN(device);
device->BindFragmentSamplers(
device->driverData,
commandBuffer,
pBindings
);
}
void Refresh_PushVertexShaderUniforms(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
NULL_RETURN(device);
device->PushVertexShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
}
void Refresh_PushFragmentShaderUniforms(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
NULL_RETURN(device);
device->PushFragmentShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
}
void Refresh_DrawInstancedPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount
) {
NULL_RETURN(device);
device->DrawInstancedPrimitives(
device->driverData,
commandBuffer,
baseVertex,
startIndex,
primitiveCount,
instanceCount
);
}
void Refresh_DrawIndexedPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount
) {
NULL_RETURN(device);
device->DrawIndexedPrimitives(
device->driverData,
commandBuffer,
baseVertex,
startIndex,
primitiveCount
);
}
void Refresh_DrawPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t vertexStart,
uint32_t primitiveCount
) {
NULL_RETURN(device);
device->DrawPrimitives(
device->driverData,
commandBuffer,
vertexStart,
primitiveCount
);
}
void Refresh_DrawPrimitivesIndirect(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *gpuBuffer,
uint32_t offsetInBytes,
uint32_t drawCount,
uint32_t stride
) {
NULL_RETURN(device);
device->DrawPrimitivesIndirect(
device->driverData,
commandBuffer,
gpuBuffer,
offsetInBytes,
drawCount,
stride
);
}
void Refresh_EndRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer
) {
NULL_RETURN(device);
device->EndRenderPass(
device->driverData,
commandBuffer
);
}
/* Compute Pass */
void Refresh_BeginComputePass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer
) {
NULL_RETURN(device);
device->BeginComputePass(
device->driverData,
commandBuffer
);
}
void Refresh_BindComputePipeline(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
@ -793,29 +654,295 @@ void Refresh_BindComputePipeline(
void Refresh_BindComputeBuffers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer **pBuffers
Refresh_ComputeBufferBinding *pBindings
) {
NULL_RETURN(device);
device->BindComputeBuffers(
device->driverData,
commandBuffer,
pBuffers
pBindings
);
}
void Refresh_BindComputeTextures(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures
Refresh_ComputeTextureBinding *pBindings
) {
NULL_RETURN(device);
device->BindComputeTextures(
device->driverData,
commandBuffer,
pTextures
pBindings
);
}
void Refresh_PushComputeShaderUniforms(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
NULL_RETURN(device);
device->PushComputeShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
}
void Refresh_DispatchCompute(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t groupCountX,
uint32_t groupCountY,
uint32_t groupCountZ
) {
NULL_RETURN(device);
device->DispatchCompute(
device->driverData,
commandBuffer,
groupCountX,
groupCountY,
groupCountZ
);
}
void Refresh_EndComputePass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer
) {
NULL_RETURN(device);
device->EndComputePass(
device->driverData,
commandBuffer
);
}
/* TransferBuffer Set/Get */
void Refresh_SetTransferData(
Refresh_Device *device,
void* data,
Refresh_TransferBuffer *transferBuffer,
Refresh_BufferCopy *copyParams,
Refresh_TransferOptions transferOption
) {
NULL_RETURN(device);
device->SetTransferData(
device->driverData,
data,
transferBuffer,
copyParams,
transferOption
);
}
void Refresh_GetTransferData(
Refresh_Device *device,
Refresh_TransferBuffer *transferBuffer,
void* data,
Refresh_BufferCopy *copyParams
) {
NULL_RETURN(device);
device->GetTransferData(
device->driverData,
transferBuffer,
data,
copyParams
);
}
/* Copy Pass */
void Refresh_BeginCopyPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer
) {
NULL_RETURN(device);
device->BeginCopyPass(
device->driverData,
commandBuffer
);
}
void Refresh_UploadToTexture(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TransferBuffer *transferBuffer,
Refresh_TextureRegion *textureRegion,
Refresh_BufferImageCopy *copyParams,
Refresh_WriteOptions writeOption
) {
NULL_RETURN(device);
device->UploadToTexture(
device->driverData,
commandBuffer,
transferBuffer,
textureRegion,
copyParams,
writeOption
);
}
void Refresh_UploadToBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TransferBuffer *transferBuffer,
Refresh_GpuBuffer *gpuBuffer,
Refresh_BufferCopy *copyParams,
Refresh_WriteOptions writeOption
) {
NULL_RETURN(device);
device->UploadToBuffer(
device->driverData,
commandBuffer,
transferBuffer,
gpuBuffer,
copyParams,
writeOption
);
}
void Refresh_DownloadFromTexture(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureRegion *textureRegion,
Refresh_TransferBuffer *transferBuffer,
Refresh_BufferImageCopy *copyParams,
Refresh_TransferOptions transferOption
) {
NULL_RETURN(device);
device->DownloadFromTexture(
device->driverData,
commandBuffer,
textureRegion,
transferBuffer,
copyParams,
transferOption
);
}
void Refresh_DownloadFromBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *gpuBuffer,
Refresh_TransferBuffer *transferBuffer,
Refresh_BufferCopy *copyParams,
Refresh_TransferOptions transferOption
) {
NULL_RETURN(device);
device->DownloadFromBuffer(
device->driverData,
commandBuffer,
gpuBuffer,
transferBuffer,
copyParams,
transferOption
);
}
void Refresh_CopyTextureToTexture(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureRegion *source,
Refresh_TextureRegion *destination,
Refresh_WriteOptions writeOption
) {
NULL_RETURN(device);
device->CopyTextureToTexture(
device->driverData,
commandBuffer,
source,
destination,
writeOption
);
}
void Refresh_CopyTextureToBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureRegion *textureRegion,
Refresh_GpuBuffer *gpuBuffer,
Refresh_BufferImageCopy *copyParameters,
Refresh_WriteOptions writeOption
) {
NULL_RETURN(device);
device->CopyTextureToBuffer(
device->driverData,
commandBuffer,
textureRegion,
gpuBuffer,
copyParameters,
writeOption
);
}
void Refresh_CopyBufferToTexture(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *gpuBuffer,
Refresh_TextureRegion *textureRegion,
Refresh_BufferImageCopy *copyParams,
Refresh_WriteOptions writeOption
) {
NULL_RETURN(device);
device->CopyBufferToTexture(
device->driverData,
commandBuffer,
gpuBuffer,
textureRegion,
copyParams,
writeOption
);
}
void Refresh_CopyBufferToBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *source,
Refresh_GpuBuffer *destination,
Refresh_BufferCopy *copyParams,
Refresh_WriteOptions writeOption
) {
NULL_RETURN(device);
device->CopyBufferToBuffer(
device->driverData,
commandBuffer,
source,
destination,
copyParams,
writeOption
);
}
void Refresh_GenerateMipmaps(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture *texture
) {
NULL_RETURN(device);
device->GenerateMipmaps(
device->driverData,
commandBuffer,
texture
);
}
void Refresh_EndCopyPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer
) {
NULL_RETURN(device);
device->EndCopyPass(
device->driverData,
commandBuffer
);
}
/* Submission/Presentation */
uint8_t Refresh_ClaimWindow(
Refresh_Device *device,
void *windowHandle,
@ -840,6 +967,30 @@ void Refresh_UnclaimWindow(
);
}
void Refresh_SetSwapchainPresentMode(
Refresh_Device *device,
void *windowHandle,
Refresh_PresentMode presentMode
) {
NULL_RETURN(device);
device->SetSwapchainPresentMode(
device->driverData,
windowHandle,
presentMode
);
}
Refresh_TextureFormat Refresh_GetSwapchainFormat(
Refresh_Device *device,
void *windowHandle
) {
if (device == NULL) { return 0; }
return device->GetSwapchainFormat(
device->driverData,
windowHandle
);
}
Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
Refresh_Device *device
) {
@ -866,30 +1017,6 @@ Refresh_Texture* Refresh_AcquireSwapchainTexture(
);
}
Refresh_TextureFormat Refresh_GetSwapchainFormat(
Refresh_Device *device,
void *windowHandle
) {
if (device == NULL) { return 0; }
return device->GetSwapchainFormat(
device->driverData,
windowHandle
);
}
void Refresh_SetSwapchainPresentMode(
Refresh_Device *device,
void *windowHandle,
Refresh_PresentMode presentMode
) {
NULL_RETURN(device);
device->SetSwapchainPresentMode(
device->driverData,
windowHandle,
presentMode
);
}
void Refresh_Submit(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer

View File

@ -181,58 +181,6 @@ struct Refresh_Device
void (*DestroyDevice)(Refresh_Device *device);
/* Drawing */
void (*DrawInstancedPrimitives)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
);
void (*DrawIndexedPrimitives)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
);
void (*DrawPrimitives)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t vertexStart,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
);
void (*DrawPrimitivesIndirect)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint32_t offsetInBytes,
uint32_t drawCount,
uint32_t stride,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
);
void (*DispatchCompute)(
Refresh_Renderer *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t groupCountX,
uint32_t groupCountY,
uint32_t groupCountZ,
uint32_t computeParamOffset
);
/* State Creation */
Refresh_ComputePipeline* (*CreateComputePipeline)(
@ -260,107 +208,15 @@ struct Refresh_Device
Refresh_TextureCreateInfo *textureCreateInfo
);
Refresh_Buffer* (*CreateBuffer)(
Refresh_GpuBuffer* (*CreateGpuBuffer)(
Refresh_Renderer *driverData,
Refresh_BufferUsageFlags usageFlags,
uint32_t sizeInBytes
);
/* Setters */
void (*SetTextureData)(
Refresh_TransferBuffer* (*CreateTransferBuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
void *data,
uint32_t dataLengthInBytes
);
void (*SetTextureDataYUV)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer* commandBuffer,
Refresh_Texture *y,
Refresh_Texture *u,
Refresh_Texture *v,
uint32_t yWidth,
uint32_t yHeight,
uint32_t uvWidth,
uint32_t uvHeight,
void *yDataPtr,
void *uDataPtr,
void *vDataPtr,
uint32_t yDataLength,
uint32_t uvDataLength,
uint32_t yStride,
uint32_t uvStride
);
void (*CopyTextureToTexture)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *sourceTextureSlice,
Refresh_TextureSlice *destinationTextureSlice,
Refresh_Filter filter
);
void (*CopyTextureToBuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
Refresh_Buffer *buffer
);
void (*SetBufferData)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint32_t offsetInBytes,
void* data,
uint32_t dataLength
);
uint32_t (*PushVertexShaderUniforms)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
);
uint32_t (*PushFragmentShaderUniforms)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
);
uint32_t (*PushComputeShaderUniforms)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
);
void (*BindVertexSamplers)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
);
void (*BindFragmentSamplers)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
);
/* Getters */
void (*GetBufferData)(
Refresh_Renderer *driverData,
Refresh_Buffer *buffer,
void *data,
uint32_t dataLengthInBytes
uint32_t sizeInBytes
);
/* Disposal */
@ -375,9 +231,14 @@ struct Refresh_Device
Refresh_Sampler *sampler
);
void (*QueueDestroyBuffer)(
void (*QueueDestroyGpuBuffer)(
Refresh_Renderer *driverData,
Refresh_Buffer *buffer
Refresh_GpuBuffer *gpuBuffer
);
void (*QueueDestroyTransferBuffer)(
Refresh_Renderer *driverData,
Refresh_TransferBuffer *transferBuffer
);
void (*QueueDestroyShaderModule)(
@ -395,7 +256,7 @@ struct Refresh_Device
Refresh_GraphicsPipeline *graphicsPipeline
);
/* Graphics State */
/* Render Pass */
void (*BeginRenderPass)(
Refresh_Renderer *driverData,
@ -405,9 +266,10 @@ struct Refresh_Device
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo
);
void (*EndRenderPass)(
void (*BindGraphicsPipeline)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline
);
void (*SetViewport)(
@ -422,29 +284,92 @@ struct Refresh_Device
Refresh_Rect *scissor
);
void (*BindGraphicsPipeline)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline
);
void (*BindVertexBuffers)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t firstBinding,
uint32_t bindingCount,
Refresh_Buffer **pBuffers,
uint64_t *pOffsets
Refresh_BufferBinding *pBindings
);
void (*BindIndexBuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint64_t offset,
Refresh_BufferBinding *pBinding,
Refresh_IndexElementSize indexElementSize
);
void (*BindVertexSamplers)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSamplerBinding *pBindings
);
void (*BindFragmentSamplers)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSamplerBinding *pBindings
);
void (*PushVertexShaderUniforms)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
);
void (*PushFragmentShaderUniforms)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
);
void (*DrawInstancedPrimitives)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount
);
void (*DrawIndexedPrimitives)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount
);
void (*DrawPrimitives)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t vertexStart,
uint32_t primitiveCount
);
void (*DrawPrimitivesIndirect)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *gpuBuffer,
uint32_t offsetInBytes,
uint32_t drawCount,
uint32_t stride
);
void (*EndRenderPass)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
);
/* Compute Pass */
void (*BeginComputePass)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
);
void (*BindComputePipeline)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
@ -454,15 +379,143 @@ struct Refresh_Device
void (*BindComputeBuffers)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer **pBuffers
Refresh_ComputeBufferBinding *pBindings
);
void (*BindComputeTextures)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures
Refresh_ComputeTextureBinding *pBindings
);
void (*PushComputeShaderUniforms)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
);
void (*DispatchCompute)(
Refresh_Renderer *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t groupCountX,
uint32_t groupCountY,
uint32_t groupCountZ
);
void (*EndComputePass)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
);
/* TransferBuffer Set/Get */
void (*SetTransferData)(
Refresh_Renderer *driverData,
void* data,
Refresh_TransferBuffer *transferBuffer,
Refresh_BufferCopy *copyParams,
Refresh_TransferOptions transferOption
);
void (*GetTransferData)(
Refresh_Renderer *driverData,
Refresh_TransferBuffer *transferBuffer,
void* data,
Refresh_BufferCopy *copyParams
);
/* Copy Pass */
void (*BeginCopyPass)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
);
void (*UploadToTexture)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TransferBuffer *transferBuffer,
Refresh_TextureRegion *textureSlice,
Refresh_BufferImageCopy *copyParams,
Refresh_WriteOptions writeOption
);
void (*UploadToBuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TransferBuffer *transferBuffer,
Refresh_GpuBuffer *gpuBuffer,
Refresh_BufferCopy *copyParams,
Refresh_WriteOptions writeOption
);
void (*DownloadFromTexture)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureRegion *textureSlice,
Refresh_TransferBuffer *transferBuffer,
Refresh_BufferImageCopy *copyParams,
Refresh_TransferOptions transferOption
);
void (*DownloadFromBuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *gpuBuffer,
Refresh_TransferBuffer *transferBuffer,
Refresh_BufferCopy *copyParams,
Refresh_TransferOptions transferOption
);
void (*CopyTextureToTexture)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureRegion *source,
Refresh_TextureRegion *destination,
Refresh_WriteOptions writeOption
);
void (*CopyTextureToBuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureRegion *textureSlice,
Refresh_GpuBuffer *gpuBuffer,
Refresh_BufferImageCopy *copyParams,
Refresh_WriteOptions writeOption
);
void (*CopyBufferToTexture)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *gpuBuffer,
Refresh_TextureRegion *textureSlice,
Refresh_BufferImageCopy *copyParams,
Refresh_WriteOptions writeOption
);
void (*CopyBufferToBuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_GpuBuffer *source,
Refresh_GpuBuffer *destination,
Refresh_BufferCopy *copyParams,
Refresh_WriteOptions writeOption
);
void (*GenerateMipmaps)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture *texture
);
void (*EndCopyPass)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
);
/* Submission/Presentation */
uint8_t (*ClaimWindow)(
Refresh_Renderer *driverData,
void *windowHandle,
@ -474,6 +527,17 @@ struct Refresh_Device
void *windowHandle
);
void (*SetSwapchainPresentMode)(
Refresh_Renderer *driverData,
void *windowHandle,
Refresh_PresentMode presentMode
);
Refresh_TextureFormat (*GetSwapchainFormat)(
Refresh_Renderer *driverData,
void *windowHandle
);
Refresh_CommandBuffer* (*AcquireCommandBuffer)(
Refresh_Renderer *driverData
);
@ -486,17 +550,6 @@ struct Refresh_Device
uint32_t *pHeight
);
Refresh_TextureFormat (*GetSwapchainFormat)(
Refresh_Renderer *driverData,
void *windowHandle
);
void (*SetSwapchainPresentMode)(
Refresh_Renderer *driverData,
void *windowHandle,
Refresh_PresentMode presentMode
);
void (*Submit)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
@ -536,50 +589,61 @@ struct Refresh_Device
result->func = name##_##func;
#define ASSIGN_DRIVER(name) \
ASSIGN_DRIVER_FUNC(DestroyDevice, name) \
ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawPrimitivesIndirect, name) \
ASSIGN_DRIVER_FUNC(DispatchCompute, name) \
ASSIGN_DRIVER_FUNC(CreateComputePipeline, name) \
ASSIGN_DRIVER_FUNC(CreateGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(CreateSampler, name) \
ASSIGN_DRIVER_FUNC(CreateShaderModule, name) \
ASSIGN_DRIVER_FUNC(CreateTexture, name) \
ASSIGN_DRIVER_FUNC(CreateBuffer, name) \
ASSIGN_DRIVER_FUNC(SetTextureData, name) \
ASSIGN_DRIVER_FUNC(SetTextureDataYUV, name) \
ASSIGN_DRIVER_FUNC(CopyTextureToTexture, name) \
ASSIGN_DRIVER_FUNC(CopyTextureToBuffer, name) \
ASSIGN_DRIVER_FUNC(SetBufferData, name) \
ASSIGN_DRIVER_FUNC(PushVertexShaderUniforms, name) \
ASSIGN_DRIVER_FUNC(PushFragmentShaderUniforms, name) \
ASSIGN_DRIVER_FUNC(PushComputeShaderUniforms, name) \
ASSIGN_DRIVER_FUNC(BindVertexSamplers, name) \
ASSIGN_DRIVER_FUNC(BindFragmentSamplers, name) \
ASSIGN_DRIVER_FUNC(GetBufferData, name) \
ASSIGN_DRIVER_FUNC(CreateGpuBuffer, name) \
ASSIGN_DRIVER_FUNC(CreateTransferBuffer, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyTexture, name) \
ASSIGN_DRIVER_FUNC(QueueDestroySampler, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyBuffer, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyGpuBuffer, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyTransferBuffer, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyShaderModule, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyComputePipeline, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(BeginRenderPass, name) \
ASSIGN_DRIVER_FUNC(EndRenderPass, name) \
ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(SetViewport, name) \
ASSIGN_DRIVER_FUNC(SetScissor, name) \
ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(BindVertexBuffers, name) \
ASSIGN_DRIVER_FUNC(BindIndexBuffer, name) \
ASSIGN_DRIVER_FUNC(BindVertexSamplers, name) \
ASSIGN_DRIVER_FUNC(BindFragmentSamplers, name) \
ASSIGN_DRIVER_FUNC(PushVertexShaderUniforms, name) \
ASSIGN_DRIVER_FUNC(PushFragmentShaderUniforms, name) \
ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawPrimitivesIndirect, name) \
ASSIGN_DRIVER_FUNC(EndRenderPass, name) \
ASSIGN_DRIVER_FUNC(BeginComputePass, name) \
ASSIGN_DRIVER_FUNC(BindComputePipeline, name) \
ASSIGN_DRIVER_FUNC(BindComputeBuffers, name) \
ASSIGN_DRIVER_FUNC(BindComputeTextures, name) \
ASSIGN_DRIVER_FUNC(PushComputeShaderUniforms, name) \
ASSIGN_DRIVER_FUNC(DispatchCompute, name) \
ASSIGN_DRIVER_FUNC(EndComputePass, name) \
ASSIGN_DRIVER_FUNC(SetTransferData, name) \
ASSIGN_DRIVER_FUNC(GetTransferData, name) \
ASSIGN_DRIVER_FUNC(BeginCopyPass, name) \
ASSIGN_DRIVER_FUNC(UploadToTexture, name) \
ASSIGN_DRIVER_FUNC(UploadToBuffer, name) \
ASSIGN_DRIVER_FUNC(DownloadFromTexture, name) \
ASSIGN_DRIVER_FUNC(DownloadFromBuffer, name) \
ASSIGN_DRIVER_FUNC(CopyTextureToTexture, name) \
ASSIGN_DRIVER_FUNC(CopyTextureToBuffer, name) \
ASSIGN_DRIVER_FUNC(CopyBufferToTexture, name) \
ASSIGN_DRIVER_FUNC(CopyBufferToBuffer, name) \
ASSIGN_DRIVER_FUNC(GenerateMipmaps, name) \
ASSIGN_DRIVER_FUNC(EndCopyPass, name) \
ASSIGN_DRIVER_FUNC(ClaimWindow, name) \
ASSIGN_DRIVER_FUNC(UnclaimWindow, name) \
ASSIGN_DRIVER_FUNC(SetSwapchainPresentMode, name) \
ASSIGN_DRIVER_FUNC(GetSwapchainFormat, name) \
ASSIGN_DRIVER_FUNC(AcquireCommandBuffer, name) \
ASSIGN_DRIVER_FUNC(AcquireSwapchainTexture, name) \
ASSIGN_DRIVER_FUNC(GetSwapchainFormat, name) \
ASSIGN_DRIVER_FUNC(SetSwapchainPresentMode, name) \
ASSIGN_DRIVER_FUNC(Submit, name) \
ASSIGN_DRIVER_FUNC(SubmitAndAcquireFence, name) \
ASSIGN_DRIVER_FUNC(Wait, name) \

File diff suppressed because it is too large Load Diff

View File

@ -218,7 +218,7 @@ uint8_t* Refresh_Image_Load(
* -flibit
*/
pixels = result;
*len = (*w) * (*h) *4;
*len = (*w) * (*h) * 4;
for (i = 0; i < *len; i += 4, pixels += 4)
{
if (pixels[3] == 0)
@ -232,6 +232,34 @@ uint8_t* Refresh_Image_Load(
return result;
}
uint8_t Refresh_Image_Info(
uint8_t *bufferPtr,
int32_t bufferLength,
int32_t *w,
int32_t *h,
int32_t *len
) {
int32_t format;
int32_t result;
result = stbi_info_from_memory(
bufferPtr,
bufferLength,
w,
h,
&format
);
if (result == 0)
{
SDL_LogWarn(SDL_LOG_CATEGORY_ERROR, "Image info failed: %s", stbi_failure_reason());
}
*len = (*w) * (*h) * 4;
return (uint8_t) result;
}
void Refresh_Image_Free(uint8_t *mem)
{
SDL_SIMDFree(mem);