mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
D3D11: Fix recent commits introducing some bluriness into UI textures (thanks 123DMWM)
This commit is contained in:
parent
292c847777
commit
3abe11b093
@ -215,7 +215,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->height = height;
|
||||
|
||||
if (!Gfx.Created) Gfx_Create();
|
||||
fb_tex = Gfx_CreateTexture(bmp, TEXTURE_FLAG_NONPOW2, false);
|
||||
fb_tex = Gfx_AllocTexture(bmp, bmp->width, TEXTURE_FLAG_NONPOW2, false);
|
||||
AllocateVB();
|
||||
|
||||
Game.Width = Window_Main.Width;
|
||||
|
@ -121,6 +121,8 @@ cc_bool Gfx_CheckTextureSize(int width, int height, cc_uint8 flags);
|
||||
use mipmapping may be either a per-texture or global state depending on the backend */
|
||||
CC_API GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps);
|
||||
GfxResourceID Gfx_CreateTexture2(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps);
|
||||
/* NOTE: Should not be used directly, use Gfx_CreateTexture or Gfx_CreateTexture2 instead */
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps);
|
||||
/* Updates a region of the given texture. (and mipmapped regions if mipmaps) */
|
||||
CC_API void Gfx_UpdateTexturePart(GfxResourceID texId, int x, int y, struct Bitmap* part, cc_bool mipmaps);
|
||||
/* Updates a region of the given texture. (and mipmapped regions if mipmaps) */
|
||||
|
@ -418,7 +418,7 @@ static void ToMortonTexture(C3D_Tex* tex, int originX, int originY,
|
||||
}
|
||||
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
struct GPUTexture* tex = GPUTexture_Alloc();
|
||||
bool success = CreateNativeTexture(&tex->texture, bmp->width, bmp->height);
|
||||
if (!success) return NULL;
|
||||
|
@ -186,7 +186,6 @@ void Gfx_Create(void) {
|
||||
|
||||
Gfx.Created = true;
|
||||
Gfx.BackendType = CC_GFX_BACKEND_D3D11;
|
||||
Gfx.SupportsNonPowTwoTextures = true;
|
||||
customMipmapsLevels = true;
|
||||
Gfx_RestoreState();
|
||||
}
|
||||
@ -284,7 +283,7 @@ static void D3D11_DoMipmaps(ID3D11Resource* texture, int x, int y, struct Bitmap
|
||||
if (prev != bmp->scan0) Mem_Free(prev);
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
ID3D11Texture2D* tex = NULL;
|
||||
ID3D11ShaderResourceView* view = NULL;
|
||||
HRESULT hr;
|
||||
|
@ -328,7 +328,7 @@ static IDirect3DTexture9* DoCreateTexture(struct Bitmap* bmp, int levels, int po
|
||||
return tex;
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
IDirect3DTexture9* tex;
|
||||
IDirect3DTexture9* sys;
|
||||
cc_result res;
|
||||
|
@ -541,7 +541,7 @@ static TextureObject* FindFreeTexture(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
TextureObject* tex = FindFreeTexture();
|
||||
if (!tex) return NULL;
|
||||
|
||||
|
@ -145,7 +145,7 @@ static void ReorderPixels(CCTexture* tex, struct Bitmap* bmp,
|
||||
}
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
int size = bmp->width * bmp->height * 4;
|
||||
CCTexture* tex = (CCTexture*)memalign(32, 32 + size);
|
||||
if (!tex) return NULL;
|
||||
|
@ -133,7 +133,7 @@ typedef struct CCTexture {
|
||||
#define To16BitPixel(src) \
|
||||
((src & 0x80) >> 7) | ((src & 0xF800) >> 10) | ((src & 0xF80000) >> 13) | ((src & 0xF8000000) >> 16);
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
cc_bool bit16 = flags & TEXTURE_FLAG_LOWRES;
|
||||
// rows are actually 8 byte aligned in TMEM https://github.com/DragonMinded/libdragon/blob/f360fa1bb1fb3ff3d98f4ab58692d40c828636c9/src/rdpq/rdpq_tex.c#L132
|
||||
// so even though width * height * pixel size may fit within 4096 bytes, after adjusting for 8 byte alignment, row pitch * height may exceed 4096 bytes
|
||||
|
@ -101,7 +101,7 @@ void Gfx_EndFrame(void) {
|
||||
*#########################################################################################################################*/
|
||||
static int tex_width, tex_height;
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
vramSetBankA(VRAM_A_TEXTURE);
|
||||
|
||||
cc_uint16* tmp = Mem_TryAlloc(bmp->width * bmp->height, 2);
|
||||
|
@ -272,7 +272,7 @@ static void* AllocTextureAt(int i, struct Bitmap* bmp, int rowWidth) {
|
||||
return tex;
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
for (int i = 0; i < TEXTURES_MAX_COUNT; i++)
|
||||
{
|
||||
if (textures[i].width) continue;
|
||||
|
@ -166,7 +166,7 @@ typedef struct CCTexture_ {
|
||||
BitmapCol pixels[]; // aligned to 64 bytes (only need 16?)
|
||||
} CCTexture;
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
int size = bmp->width * bmp->height * 4;
|
||||
CCTexture* tex = (CCTexture*)memalign(16, 64 + size);
|
||||
|
||||
|
@ -581,7 +581,7 @@ typedef struct CCTexture_ {
|
||||
cc_uint32 pixels[];
|
||||
} CCTexture;
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
int size = bmp->width * bmp->height * 4;
|
||||
CCTexture* tex = (CCTexture*)rsxMemalign(128, 128 + size);
|
||||
|
||||
|
@ -114,7 +114,7 @@ typedef struct CCTexture_ {
|
||||
BitmapCol pixels[];
|
||||
} CCTexture;
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
int size = bmp->width * bmp->height * 4;
|
||||
CCTexture* tex = (CCTexture*)memalign(16, 16 + size);
|
||||
|
||||
|
@ -679,7 +679,7 @@ static void GPUTextures_DeleteUnreferenced(void) {
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
int size = bmp->width * bmp->height * 4;
|
||||
struct GPUTexture* tex = GPUTexture_Alloc(size);
|
||||
CopyTextureData(tex->data, bmp->width * BITMAPCOLOR_SIZE,
|
||||
|
@ -117,7 +117,7 @@ typedef struct CCTexture {
|
||||
void* addr;
|
||||
} CCTexture;
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
CCTexture* tex = Mem_TryAlloc(1, sizeof(CCTexture));
|
||||
if (!tex) return NULL;
|
||||
|
||||
|
@ -94,7 +94,7 @@ void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
*texId = NULL;
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
CCTexture* tex = (CCTexture*)Mem_Alloc(2 + bmp->width * bmp->height, 4, "Texture");
|
||||
|
||||
tex->width = bmp->width;
|
||||
|
@ -84,7 +84,7 @@ static void Gfx_RestoreState(void) {
|
||||
*#########################################################################################################################*/
|
||||
static GX2Texture* pendingTex;
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GX2Texture* tex = Mem_TryAllocCleared(1, sizeof(GX2Texture));
|
||||
if (!tex) return NULL;
|
||||
|
||||
|
@ -195,7 +195,7 @@ static void ConvertTexture(cc_uint32* dst, struct Bitmap* bmp, int rowWidth) {
|
||||
}
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
int size = bmp->width * bmp->height * 4;
|
||||
CCTexture* tex = Mem_Alloc(1, sizeof(CCTexture), "GPU texture");
|
||||
tex->pixels = MmAllocateContiguousMemoryEx(size, 0, MAX_RAM_ADDR, 0, PAGE_WRITECOMBINE | PAGE_READWRITE);
|
||||
|
@ -102,7 +102,7 @@ static void SetTextureData(struct XenosSurface* xtex, int x, int y, const struct
|
||||
Xe_Surface_Unlock(xe, xtex);
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
struct XenosSurface* xtex = Xe_CreateTexture(xe, bmp->width, bmp->height, 1, XE_FMT_8888, 0);
|
||||
SetTextureData(xtex, 0, 0, bmp, rowWidth, 0);
|
||||
return xtex;
|
||||
|
@ -118,7 +118,7 @@ static CC_NOINLINE void UpdateTextureSlow(int x, int y, struct Bitmap* part, int
|
||||
if (count > UPDATE_FAST_SIZE) Mem_Free(ptr);
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
GfxResourceID texId = NULL;
|
||||
_glGenTextures(1, (GLuint*)&texId);
|
||||
_glBindTexture(GL_TEXTURE_2D, ptr_to_uint(texId));
|
||||
|
@ -420,8 +420,6 @@ cc_bool Gfx_CheckTextureSize(int width, int height, cc_uint8 flags) {
|
||||
return maxSize == 0 || (width * height <= maxSize);
|
||||
}
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps);
|
||||
|
||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||
return Gfx_CreateTexture2(bmp, bmp->width, flags, mipmaps);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user