mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-08-05 11:47:17 -04:00
PS1: Fix paletted textures
This commit is contained in:
parent
8ca8877339
commit
587dfd1eea
@ -1,3 +1,7 @@
|
||||
// Scratchpad memory is essentially data cache of CPU,
|
||||
// and so takes less cycles to access
|
||||
#define SCRATCHPAD_MEM ((cc_uint8*)0x1F800000)
|
||||
|
||||
enum dma_chrc_flags {
|
||||
CHRC_STATUS_BUSY = (1 << 24),
|
||||
};
|
||||
|
@ -3,6 +3,10 @@
|
||||
; $SAMPLER_VARS[0].type= "sampler2D"
|
||||
; $SAMPLER_VARS[0].location = 0
|
||||
|
||||
; Set position field enabled
|
||||
; https://github.com/DirectFB/mesa/blob/01e637114914453451becc0dc8afe60faff48d84/src/gallium/drivers/r600/r600_state.c#L2925
|
||||
; $SPI_PS_IN_CONTROL_0.POSITION_ENA = true
|
||||
|
||||
; $NUM_SPI_PS_INPUT_CNTL = 2
|
||||
; $SPI_PS_INPUT_CNTL[0].semantic = 0
|
||||
; $SPI_PS_INPUT_CNTL[0].default_val = 1
|
||||
|
@ -3,6 +3,10 @@
|
||||
; $SAMPLER_VARS[0].type= "sampler2D"
|
||||
; $SAMPLER_VARS[0].location = 0
|
||||
|
||||
; Set position field enabled
|
||||
; https://github.com/DirectFB/mesa/blob/01e637114914453451becc0dc8afe60faff48d84/src/gallium/drivers/r600/r600_state.c#L2925
|
||||
; $SPI_PS_IN_CONTROL_0.POSITION_ENA = true
|
||||
|
||||
; $NUM_SPI_PS_INPUT_CNTL = 2
|
||||
; $SPI_PS_INPUT_CNTL[0].semantic = 0
|
||||
; $SPI_PS_INPUT_CNTL[0].default_val = 1
|
||||
|
@ -8,6 +8,7 @@ https://github.com/rw-r-r-0644/gx2-texture/blob/83d7707e8d4b33ec7ba63d5c7dfe62c3
|
||||
https://github.com/yawut/ntrview-wiiu/blob/45b1c7f05cfd9917b8b171f3db08dc63293fc5c5/gfx/gx2_shaders/main.psh
|
||||
https://github.com/Hydr8gon/NooDS/blob/b41cb3b9b889481c998e7e83db1ab3ef9d97b838/src/console/shaders/shader_wiiu.vsh
|
||||
https://github.com/luRaichu/recsbr/blob/163fa441712f6b25e780e914617941c2385b330e/src/Backends/Rendering/WiiUShaders/shader%20sources/wtf%20is%20this.txt
|
||||
https://github.com/comex/quiet_/blob/4b55e8c9585e336ad3e09628d951a4d7321e70f7/qmod/shader2.psh#L4
|
||||
|
||||
To generate shader assembly
|
||||
1) Get AMD ShaderAnalyzer
|
||||
|
Binary file not shown.
Binary file not shown.
@ -393,28 +393,31 @@ static void CreateFullTexture(BitmapCol* tmp, struct Bitmap* bmp, int rowWidth)
|
||||
}
|
||||
|
||||
static void CreatePalettedTexture(BitmapCol* tmp, struct Bitmap* bmp, int rowWidth, BitmapCol* palette, int pal_count) {
|
||||
cc_uint8* buf = (cc_uint8*)tmp;
|
||||
cc_uint8* dst = (cc_uint8*)tmp;
|
||||
BitmapCol* src = bmp->scan0;
|
||||
int stride = (bmp->width * 2) >> 2;
|
||||
|
||||
for (int y = 0; y < bmp->height; y++)
|
||||
{
|
||||
BitmapCol* row = bmp->scan0 + y * rowWidth;
|
||||
|
||||
for (int x = 0; x < bmp->width; x++)
|
||||
{
|
||||
int idx = FindInPalette(palette, pal_count, row[x]);
|
||||
int idx = FindInPalette(palette, pal_count, src[x]);
|
||||
|
||||
if ((x & 1) == 0) {
|
||||
buf[x >> 1] = idx;
|
||||
dst[x >> 1] = idx;
|
||||
} else {
|
||||
buf[x >> 1] |= idx << 4;
|
||||
dst[x >> 1] |= idx << 4;
|
||||
}
|
||||
}
|
||||
|
||||
src += rowWidth;
|
||||
dst += stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void* AllocTextureAt(int i, struct Bitmap* bmp, int rowWidth) {
|
||||
BitmapCol palette[16];
|
||||
int pal_count = 0;//CalcPalette(palette, bmp, rowWidth); TODO fix
|
||||
BitmapCol palette[16]; // = (BitmapCol*)SCRATCHPAD_MEM; TODO doesn't work
|
||||
int pal_count = CalcPalette(palette, bmp, rowWidth);
|
||||
|
||||
cc_uint16* tmp;
|
||||
int tmp_size;
|
||||
@ -468,11 +471,11 @@ static void* AllocTextureAt(int i, struct Bitmap* bmp, int rowWidth) {
|
||||
|
||||
int x = pageX * TPAGE_WIDTH + tex->xOffset;
|
||||
int y = pageY * TPAGE_HEIGHT + tex->yOffset;
|
||||
int w = pal_count > 0 ? (bmp->width / 4) : bmp->width;
|
||||
int w = pal_count > 0 ? (bmp->width >> 2) : bmp->width;
|
||||
int h = bmp->height;
|
||||
|
||||
Platform_Log2(" LOAD AT: %i, %i", &x, &y);
|
||||
Gfx_TransferToVRAM(x, y, w, h, tmp);
|
||||
Platform_Log4(" LOAD AT: %i, %i (%i x %i)", &x, &y, &w, &h);
|
||||
Gfx_TransferToVRAM(x, y, w, h, tmp);
|
||||
|
||||
Mem_Free(tmp);
|
||||
return tex;
|
||||
|
@ -130,7 +130,7 @@ static void UpdatePS(void) {
|
||||
cur_PS = texture_PS[2];
|
||||
} else if (gfx_fogEnabled && fog_func == FOG_LINEAR) {
|
||||
cur_PS = texture_PS[1];
|
||||
} */else {
|
||||
*/} else {
|
||||
cur_PS = texture_PS[0];
|
||||
}
|
||||
GX2SetPixelShader(cur_PS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user