mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 08:36:38 -04:00
3DS: Try to transfer non-dynamic textures to VRAM
This commit is contained in:
parent
43e2197a2d
commit
1b6ebc5baf
@ -243,10 +243,12 @@ struct GPUTexture {
|
|||||||
};
|
};
|
||||||
static struct GPUTexture* del_textures_head;
|
static struct GPUTexture* del_textures_head;
|
||||||
static struct GPUTexture* del_textures_tail;
|
static struct GPUTexture* del_textures_tail;
|
||||||
|
|
||||||
struct GPUTexture* GPUTexture_Alloc(void) {
|
struct GPUTexture* GPUTexture_Alloc(void) {
|
||||||
struct GPUTexture* tex = Mem_AllocCleared(1, sizeof(struct GPUTexture), "GPU texture");
|
struct GPUTexture* tex = Mem_AllocCleared(1, sizeof(struct GPUTexture), "GPU texture");
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't delete textures until not used in any frames
|
// can't delete textures until not used in any frames
|
||||||
static void GPUTexture_Unref(GfxResourceID* resource) {
|
static void GPUTexture_Unref(GfxResourceID* resource) {
|
||||||
struct GPUTexture* tex = (struct GPUTexture*)(*resource);
|
struct GPUTexture* tex = (struct GPUTexture*)(*resource);
|
||||||
@ -255,10 +257,12 @@ static void GPUTexture_Unref(GfxResourceID* resource) {
|
|||||||
|
|
||||||
LinkedList_Append(tex, del_textures_head, del_textures_tail);
|
LinkedList_Append(tex, del_textures_head, del_textures_tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GPUTexture_Free(struct GPUTexture* tex) {
|
static void GPUTexture_Free(struct GPUTexture* tex) {
|
||||||
C3D_TexDelete(&tex->texture);
|
C3D_TexDelete(&tex->texture);
|
||||||
Mem_Free(tex);
|
Mem_Free(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GPUTextures_DeleteUnreferenced(void) {
|
static void GPUTextures_DeleteUnreferenced(void) {
|
||||||
if (!del_textures_head) return;
|
if (!del_textures_head) return;
|
||||||
|
|
||||||
@ -314,6 +318,15 @@ static bool CreateNativeTexture(C3D_Tex* tex, u32 width, u32 height) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TryTransferToVRAM(C3D_Tex* tex) {
|
||||||
|
void* vram = vramAlloc(tex->size);
|
||||||
|
if (!vram) return;
|
||||||
|
|
||||||
|
C3D_SyncTextureCopy((u32*)tex->data, 0, (u32*)vram, 0, tex->size, 8);
|
||||||
|
linearFree(tex->data);
|
||||||
|
tex->data = vram;
|
||||||
|
}
|
||||||
|
|
||||||
/*static inline cc_uint32 CalcZOrder(cc_uint32 x, cc_uint32 y) {
|
/*static inline cc_uint32 CalcZOrder(cc_uint32 x, cc_uint32 y) {
|
||||||
// Simplified "Interleave bits by Binary Magic Numbers" from
|
// Simplified "Interleave bits by Binary Magic Numbers" from
|
||||||
// http://graphics.stanford.edu/~seander/bithacks.html#InterleaveTableObvious
|
// http://graphics.stanford.edu/~seander/bithacks.html#InterleaveTableObvious
|
||||||
@ -375,6 +388,7 @@ static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_boo
|
|||||||
if (!success) return NULL;
|
if (!success) return NULL;
|
||||||
|
|
||||||
ToMortonTexture(&tex->texture, 0, 0, bmp, bmp->width);
|
ToMortonTexture(&tex->texture, 0, 0, bmp, bmp->width);
|
||||||
|
if (!(flags & TEXTURE_FLAG_DYNAMIC)) TryTransferToVRAM(&tex->texture);
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
third_party/citro3d.c
vendored
2
third_party/citro3d.c
vendored
@ -885,7 +885,7 @@ static void C3D_FrameBufClear(C3D_FrameBuf* frameBuf, C3D_ClearBits clearBits, u
|
|||||||
if (clearBits & C3D_CLEAR_COLOR)
|
if (clearBits & C3D_CLEAR_COLOR)
|
||||||
{
|
{
|
||||||
if (clearBits & C3D_CLEAR_DEPTH)
|
if (clearBits & C3D_CLEAR_DEPTH)
|
||||||
GX_gMemoryFill(
|
GX_MemoryFill(
|
||||||
(u32*)frameBuf->colorBuf, clearColor, (u32*)colorBufEnd, BIT(0) | (cfs << 8),
|
(u32*)frameBuf->colorBuf, clearColor, (u32*)colorBufEnd, BIT(0) | (cfs << 8),
|
||||||
(u32*)frameBuf->depthBuf, clearDepth, (u32*)depthBufEnd, BIT(0) | (dfs << 8));
|
(u32*)frameBuf->depthBuf, clearDepth, (u32*)depthBufEnd, BIT(0) | (dfs << 8));
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user