Skip to content

Commit 70e60a3

Browse files
committed
WIP
1 parent 0af3eb8 commit 70e60a3

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

extensions/pl_graphics_ext.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ pl__format_stride(plFormat tFormat)
433433
case PL_FORMAT_EAC_R11G11_UNORM:
434434
case PL_FORMAT_EAC_R11G11_SNORM:
435435
return 64 / (4 * 8);
436-
437-
case PL_FORMAT_BC2_SRGB:
436+
438437
case PL_FORMAT_BC2_UNORM:
438+
case PL_FORMAT_BC2_SRGB:
439439
case PL_FORMAT_BC3_UNORM:
440440
case PL_FORMAT_BC3_SRGB:
441441
case PL_FORMAT_BC5_UNORM:

extensions/pl_graphics_metal.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,19 @@
873873
tDesc.pcDebugName = "unnamed texture";
874874

875875
if(tDesc.uMips == 0)
876-
tDesc.uMips = (uint32_t)floorf(log2f((float)pl_maxi((int)tDesc.tDimensions.x, (int)tDesc.tDimensions.y))) + 1u;
876+
tDesc.uMips = (uint32_t)floorf(log2f((float)pl_maxi((int)tDesc.tDimensions.x, (int)tDesc.tDimensions.y))) + 1;
877+
878+
for(uint32_t uMipLevel = 1; uMipLevel < tDesc.uMips; uMipLevel++)
879+
{
880+
int iCurrentWidth = (int)tDesc.tDimensions.x / ((1 << (int)uMipLevel));
881+
int iCurrentHeight = (int)tDesc.tDimensions.y / ((1 << (int)uMipLevel));
882+
883+
if(iCurrentHeight < 4 || iCurrentWidth < 4)
884+
{
885+
tDesc.uMips = uMipLevel;
886+
break;
887+
}
888+
}
877889

878890
ptTexture->tDesc = tDesc,
879891
ptTexture->tView = (plTextureViewDesc){

extensions/pl_resource_ext.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ pl_resource_load_ex(const char* pcName, plResourceLoadFlags tFlags, uint8_t* puO
382382

383383
bool bResizeNeeded = false;
384384
bool bGenerateMips = true;
385+
// bool bAttemptCompression = false;
385386
bool bAttemptCompression = true;
386387
plImageInfo tImageInfo = {0};
387388
size_t szStagingOffset = 0;
@@ -614,6 +615,9 @@ pl_resource_load_ex(const char* pcName, plResourceLoadFlags tFlags, uint8_t* puO
614615
uint8_t uGreen = (ptPixel0[1] + ptPixel1[1] + ptPixel2[1] + ptPixel3[1]) / 4;
615616
uint8_t uBlue = (ptPixel0[2] + ptPixel1[2] + ptPixel2[2] + ptPixel3[2]) / 4;
616617
uint8_t uAlpha = (ptPixel0[3] + ptPixel1[3] + ptPixel2[3] + ptPixel3[3]) / 4;
618+
// uint8_t uAlpha = pl_max(ptPixel0[3], ptPixel1[3]);
619+
// uAlpha = pl_max(uAlpha, ptPixel2[3]);
620+
// uAlpha = pl_max(uAlpha, ptPixel3[3]);
617621

618622

619623
puDstBuffer[j * iCurrentWidth * 4 + i * 4 + 0] = uRed;
@@ -647,7 +651,11 @@ pl_resource_load_ex(const char* pcName, plResourceLoadFlags tFlags, uint8_t* puO
647651
.uMipLevel = uMipLevel
648652
};
649653

650-
gptGfx->copy_buffer_to_texture(ptBlitEncoder, gptResourceManager->tStagingBuffer.tStagingBufferHandle, tResource.tTexture, 1, &tBufferImageCopy);
654+
gptGfx->copy_buffer_to_texture(ptBlitEncoder,
655+
gptResourceManager->tStagingBuffer.tStagingBufferHandle,
656+
tResource.tTexture,
657+
1,
658+
&tBufferImageCopy);
651659
szStagingOffset += szCurrentSize;
652660
}
653661

0 commit comments

Comments
 (0)