24
24
#include "hw/xbox/nv2a/pgraph/swizzle.h"
25
25
#include "hw/xbox/nv2a/pgraph/s3tc.h"
26
26
#include "hw/xbox/nv2a/pgraph/texture.h"
27
+ #include "constants.h"
27
28
#include "debug.h"
28
29
#include "renderer.h"
30
+ #include <stdint.h>
29
31
30
- static TextureBinding * generate_texture (const TextureShape s , const uint8_t * texture_data , const uint8_t * palette_data );
32
+ static TextureBinding * generate_texture (const TextureShape s , const uint8_t * texture_data , const uint8_t * palette_data , uint32_t filter );
31
33
static void texture_binding_destroy (gpointer data );
32
34
33
35
struct pgraph_texture_possibly_dirty_struct {
@@ -343,7 +345,7 @@ void pgraph_gl_bind_textures(NV2AState *d)
343
345
344
346
if (key_out -> binding == NULL ) {
345
347
// Must create the texture
346
- key_out -> binding = generate_texture (state , texture_data , palette_data );
348
+ key_out -> binding = generate_texture (state , texture_data , palette_data , filter );
347
349
key_out -> binding -> data_hash = tex_data_hash ;
348
350
key_out -> binding -> scale = 1 ;
349
351
} else {
@@ -360,7 +362,7 @@ void pgraph_gl_bind_textures(NV2AState *d)
360
362
361
363
trace_nv2a_pgraph_surface_render_to_texture (
362
364
surface -> vram_addr , surface -> width , surface -> height );
363
- pgraph_gl_render_surface_to_texture (d , surface , binding , & state , i );
365
+ pgraph_gl_render_surface_to_texture (d , surface , binding , & state , i , filter );
364
366
binding -> draw_time = surface -> draw_time ;
365
367
binding -> scale = pg -> surface_scale_factor ;
366
368
}
@@ -403,9 +405,13 @@ gl_internal_format_to_s3tc_enum(GLint gl_internal_format)
403
405
static void upload_gl_texture (GLenum gl_target ,
404
406
const TextureShape s ,
405
407
const uint8_t * texture_data ,
406
- const uint8_t * palette_data )
408
+ const uint8_t * palette_data ,
409
+ uint32_t filter )
407
410
{
408
411
ColorFormatInfo f = kelvin_color_format_gl_map [s .color_format ];
412
+ if (filter & kelvin_signed_format_mask_gl_map [s .color_format ])
413
+ f = kelvin_signed_color_format_gl_map [s .color_format ];
414
+
409
415
nv2a_profile_inc_counter (NV2A_PROF_TEX_UPLOAD );
410
416
411
417
unsigned int adjusted_width = s .width ;
@@ -626,9 +632,12 @@ static void upload_gl_texture(GLenum gl_target,
626
632
627
633
static TextureBinding * generate_texture (const TextureShape s ,
628
634
const uint8_t * texture_data ,
629
- const uint8_t * palette_data )
635
+ const uint8_t * palette_data ,
636
+ uint32_t filter )
630
637
{
631
638
ColorFormatInfo f = kelvin_color_format_gl_map [s .color_format ];
639
+ if (filter & kelvin_signed_format_mask_gl_map [s .color_format ])
640
+ f = kelvin_signed_color_format_gl_map [s .color_format ];
632
641
633
642
/* Create a new opengl texture */
634
643
GLuint gl_texture ;
@@ -696,19 +705,19 @@ static TextureBinding* generate_texture(const TextureShape s,
696
705
length = (length + NV2A_CUBEMAP_FACE_ALIGNMENT - 1 ) & ~(NV2A_CUBEMAP_FACE_ALIGNMENT - 1 );
697
706
698
707
upload_gl_texture (GL_TEXTURE_CUBE_MAP_POSITIVE_X ,
699
- s , texture_data + 0 * length , palette_data );
708
+ s , texture_data + 0 * length , palette_data , filter );
700
709
upload_gl_texture (GL_TEXTURE_CUBE_MAP_NEGATIVE_X ,
701
- s , texture_data + 1 * length , palette_data );
710
+ s , texture_data + 1 * length , palette_data , filter );
702
711
upload_gl_texture (GL_TEXTURE_CUBE_MAP_POSITIVE_Y ,
703
- s , texture_data + 2 * length , palette_data );
712
+ s , texture_data + 2 * length , palette_data , filter );
704
713
upload_gl_texture (GL_TEXTURE_CUBE_MAP_NEGATIVE_Y ,
705
- s , texture_data + 3 * length , palette_data );
714
+ s , texture_data + 3 * length , palette_data , filter );
706
715
upload_gl_texture (GL_TEXTURE_CUBE_MAP_POSITIVE_Z ,
707
- s , texture_data + 4 * length , palette_data );
716
+ s , texture_data + 4 * length , palette_data , filter );
708
717
upload_gl_texture (GL_TEXTURE_CUBE_MAP_NEGATIVE_Z ,
709
- s , texture_data + 5 * length , palette_data );
718
+ s , texture_data + 5 * length , palette_data , filter );
710
719
} else {
711
- upload_gl_texture (gl_target , s , texture_data , palette_data );
720
+ upload_gl_texture (gl_target , s , texture_data , palette_data , filter );
712
721
}
713
722
714
723
/* Linear textures don't support mipmapping */
0 commit comments