trunk/src/osd/sdl/gl_shader_mgr.c
| r28745 | r28746 | |
| 19 | 19 | "/tmp/glsl_general.vsh" // general |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | | static const char * glsl_mamebm_fsh_files [GLSL_SHADER_TYPE_NUMBER][GLSL_SHADER_FEAT_INT_NUMBER] = |
| 22 | static const char * glsl_mamebm_fsh_files [GLSL_SHADER_FEAT_INT_NUMBER] = |
| 23 | 23 | { |
| 24 | | {"/tmp/glsl_plain_idx16_lut.fsh", // idx16 lut plain |
| 25 | | "/tmp/glsl_bilinear_idx16_lut.fsh" // idx16 lut bilinear |
| 26 | | }, |
| 27 | | |
| 28 | | {"/tmp/glsl_plain_rgb32_lut.fsh", // rgb32 lut plain |
| 29 | | "/tmp/glsl_bilinear_rgb32_lut.fsh" // rgb32 lut bilinear |
| 30 | | }, |
| 31 | | |
| 32 | | {"/tmp/glsl_plain_rgb32_dir.fsh", // rgb32 dir plain |
| 24 | "/tmp/glsl_plain_rgb32_dir.fsh", // rgb32 dir plain |
| 33 | 25 | "/tmp/glsl_bilinear_rgb32_dir.fsh" // rgb32 dir bilinear |
| 34 | | } |
| 35 | 26 | }; |
| 36 | 27 | |
| 37 | 28 | #else // GLSL_SOURCE_ON_DISK |
| 38 | 29 | |
| 39 | 30 | #include "shader/glsl_general.vsh.c" |
| 40 | 31 | |
| 41 | | #include "shader/glsl_plain_idx16_lut.fsh.c" |
| 42 | | #include "shader/glsl_bilinear_idx16_lut.fsh.c" |
| 43 | | |
| 44 | | #include "shader/glsl_plain_rgb32_lut.fsh.c" |
| 45 | | #include "shader/glsl_bilinear_rgb32_lut.fsh.c" |
| 46 | | |
| 47 | 32 | #include "shader/glsl_plain_rgb32_dir.fsh.c" |
| 48 | 33 | #include "shader/glsl_bilinear_rgb32_dir.fsh.c" |
| 49 | 34 | |
| r28745 | r28746 | |
| 52 | 37 | glsl_general_vsh_src // general |
| 53 | 38 | }; |
| 54 | 39 | |
| 55 | | static const char * glsl_mamebm_fsh_sources [GLSL_SHADER_TYPE_NUMBER][GLSL_SHADER_FEAT_INT_NUMBER] = |
| 40 | static const char * glsl_mamebm_fsh_sources [GLSL_SHADER_FEAT_INT_NUMBER] = |
| 56 | 41 | { |
| 57 | | {glsl_plain_idx16_lut_fsh_src, // idx16 lut plain |
| 58 | | glsl_bilinear_idx16_lut_fsh_src // idx16 lut bilinear |
| 59 | | }, |
| 60 | | |
| 61 | | {glsl_plain_rgb32_lut_fsh_src, // rgb32 lut plain |
| 62 | | glsl_bilinear_rgb32_lut_fsh_src // rgb32 lut bilinear |
| 63 | | }, |
| 64 | | |
| 65 | | {glsl_plain_rgb32_dir_fsh_src, // rgb32 dir plain |
| 42 | glsl_plain_rgb32_dir_fsh_src, // rgb32 dir plain |
| 66 | 43 | glsl_bilinear_rgb32_dir_fsh_src // rgb32 dir bilinear |
| 67 | | } |
| 68 | 44 | }; |
| 69 | 45 | |
| 70 | 46 | #endif // GLSL_SOURCE_ON_DISK |
| r28745 | r28746 | |
| 76 | 52 | "custom" |
| 77 | 53 | }; |
| 78 | 54 | |
| 79 | | static GLhandleARB glsl_mamebm_programs [GLSL_SHADER_TYPE_NUMBER][GLSL_SHADER_FEAT_MAX_NUMBER+9] = |
| 55 | static GLhandleARB glsl_mamebm_programs [GLSL_SHADER_FEAT_MAX_NUMBER+9] = |
| 80 | 56 | { |
| 81 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* idx16 lut: plain, bilinear, custom0-9, .. */ |
| 82 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 lut: plain, bilinear, custom0-9, .. */ |
| 83 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 dir: plain, bilinear, custom0-9, .. */ |
| 57 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* rgb32 dir: plain, bilinear, custom0-9, .. */ |
| 84 | 58 | }; |
| 85 | 59 | |
| 86 | 60 | /** |
| r28745 | r28746 | |
| 94 | 68 | }; |
| 95 | 69 | |
| 96 | 70 | static GLhandleARB glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_MAX_NUMBER+9] = |
| 97 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* general, custom0-9 */ |
| 71 | { |
| 72 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 73 | }; /* general, custom0-9 */ |
| 98 | 74 | |
| 99 | | static GLhandleARB glsl_mamebm_fsh_shader [GLSL_SHADER_TYPE_NUMBER][GLSL_SHADER_FEAT_MAX_NUMBER+9] = |
| 75 | static GLhandleARB glsl_mamebm_fsh_shader [GLSL_SHADER_FEAT_MAX_NUMBER+9] = |
| 100 | 76 | { |
| 101 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* idx16 lut: plain, bilinear, custom0-9 */ |
| 102 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 lut: plain, bilinear, custom0-9 */ |
| 103 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 dir: plain, bilinear, custom0-9 */ |
| 77 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* rgb32 dir: plain, bilinear, custom0-9 */ |
| 104 | 78 | }; |
| 105 | 79 | |
| 106 | 80 | static GLhandleARB glsl_scrn_programs [10] = |
| r28745 | r28746 | |
| 109 | 83 | }; |
| 110 | 84 | |
| 111 | 85 | static GLhandleARB glsl_scrn_vsh_shader[10] = |
| 112 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* custom0-9 */ |
| 86 | { |
| 87 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 88 | }; /* custom0-9 */ |
| 113 | 89 | |
| 114 | 90 | static GLhandleARB glsl_scrn_fsh_shader [10] = |
| 115 | | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* rgb32: custom0-9 */ |
| 91 | { |
| 92 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 93 | }; /* rgb32: custom0-9 */ |
| 116 | 94 | |
| 117 | 95 | const char * glsl_shader_get_filter_name_mamebm(int glslShaderFeature) |
| 118 | 96 | { |
| r28745 | r28746 | |
| 122 | 100 | return glsl_mamebm_filter_names[glslShaderFeature]; |
| 123 | 101 | } |
| 124 | 102 | |
| 125 | | GLhandleARB glsl_shader_get_program_mamebm(int glslShaderType, int glslShaderFeature, int idx) |
| 103 | GLhandleARB glsl_shader_get_program_mamebm(int glslShaderFeature, int idx) |
| 126 | 104 | { |
| 127 | | if ( !(0 <= glslShaderType && glslShaderType < GLSL_SHADER_TYPE_NUMBER) ) |
| 128 | | return 0; |
| 129 | | |
| 130 | 105 | if ( !(0 <= glslShaderFeature && glslShaderFeature < GLSL_SHADER_FEAT_MAX_NUMBER) ) |
| 131 | 106 | return 0; |
| 132 | 107 | |
| 133 | | return glsl_mamebm_programs[glslShaderType][glslShaderFeature+idx]; |
| 108 | return glsl_mamebm_programs[glslShaderFeature+idx]; |
| 134 | 109 | } |
| 135 | 110 | |
| 136 | 111 | GLhandleARB glsl_shader_get_program_scrn(int idx) |
| r28745 | r28746 | |
| 163 | 138 | |
| 164 | 139 | if(err) return NULL; |
| 165 | 140 | |
| 166 | | for (i=0; !err && i<GLSL_SHADER_TYPE_NUMBER; i++) |
| 141 | for (j=0; !err && j<GLSL_SHADER_FEAT_INT_NUMBER; j++) |
| 167 | 142 | { |
| 168 | | for (j=0; !err && j<GLSL_SHADER_FEAT_INT_NUMBER; j++) |
| 169 | | { |
| 170 | | #ifdef GLSL_SOURCE_ON_DISK |
| 171 | | if(glsl_mamebm_fsh_files[i][j]) |
| 172 | | err = gl_compile_shader_files (&glsl_mamebm_programs[i][j], |
| 173 | | &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], |
| 174 | | &glsl_mamebmfsh_shader[i][j], |
| 175 | | NULL /*precompiled*/, glsl_mamebm_fsh_files[i][j], 0); |
| 176 | | #else |
| 177 | | if(glsl_mamebm_fsh_sources[i][j]) |
| 178 | | err = gl_compile_shader_sources(&glsl_mamebm_programs[i][j], |
| 179 | | &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], |
| 180 | | &glsl_mamebm_fsh_shader[i][j], |
| 181 | | NULL /*precompiled*/, glsl_mamebm_fsh_sources[i][j]); |
| 182 | | #endif |
| 183 | | } |
| 143 | #ifdef GLSL_SOURCE_ON_DISK |
| 144 | if(glsl_mamebm_fsh_files[j]) |
| 145 | err = gl_compile_shader_files (&glsl_mamebm_programs[j], |
| 146 | &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], |
| 147 | &glsl_mamebmfsh_shader[j], |
| 148 | NULL /*precompiled*/, glsl_mamebm_fsh_files[j], 0); |
| 149 | #else |
| 150 | if(glsl_mamebm_fsh_sources[j]) |
| 151 | err = gl_compile_shader_sources(&glsl_mamebm_programs[j], |
| 152 | &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], |
| 153 | &glsl_mamebm_fsh_shader[j], |
| 154 | NULL /*precompiled*/, glsl_mamebm_fsh_sources[j]); |
| 155 | #endif |
| 184 | 156 | } |
| 185 | 157 | if (err) return NULL; |
| 186 | 158 | return (glsl_shader_info *) malloc(sizeof(glsl_shader_info *)); |
| r28745 | r28746 | |
| 199 | 171 | (void) gl_delete_shader( NULL, &glsl_mamebm_vsh_shader[i], NULL); |
| 200 | 172 | } |
| 201 | 173 | |
| 202 | | for (i=0; i<GLSL_SHADER_TYPE_NUMBER; i++) |
| 174 | for (j=0; j<GLSL_SHADER_FEAT_MAX_NUMBER+9; j++) |
| 203 | 175 | { |
| 204 | | for (j=0; j<GLSL_SHADER_FEAT_MAX_NUMBER+9; j++) |
| 205 | | { |
| 206 | | if ( glsl_mamebm_fsh_shader[i][j] ) |
| 207 | | (void) gl_delete_shader( NULL, NULL, &glsl_mamebm_fsh_shader[i][j]); |
| 208 | | } |
| 176 | if ( glsl_mamebm_fsh_shader[j] ) |
| 177 | (void) gl_delete_shader( NULL, NULL, &glsl_mamebm_fsh_shader[j]); |
| 209 | 178 | } |
| 210 | 179 | |
| 211 | | for (i=0; i<GLSL_SHADER_TYPE_NUMBER; i++) |
| 180 | for (j=0; j<GLSL_SHADER_FEAT_MAX_NUMBER+9; j++) |
| 212 | 181 | { |
| 213 | | for (j=0; j<GLSL_SHADER_FEAT_MAX_NUMBER+9; j++) |
| 214 | | { |
| 215 | | if ( glsl_mamebm_programs[i][j] ) |
| 216 | | (void) gl_delete_shader( &glsl_mamebm_programs[i][j], NULL, NULL); |
| 217 | | } |
| 182 | if ( glsl_mamebm_programs[j] ) |
| 183 | (void) gl_delete_shader( &glsl_mamebm_programs[j], NULL, NULL); |
| 218 | 184 | } |
| 219 | 185 | |
| 220 | 186 | for (i=0; i<10; i++) |
| r28745 | r28746 | |
| 241 | 207 | err = gl_compile_shader_file ( &glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_CUSTOM+idx], GL_VERTEX_SHADER_ARB, fname, 0); |
| 242 | 208 | if(err) return err; |
| 243 | 209 | |
| 244 | | for (i=0; !err && i<GLSL_SHADER_TYPE_NUMBER; i++) |
| 245 | | { |
| 246 | | switch(i) |
| 247 | | { |
| 248 | | case GLSL_SHADER_TYPE_IDX16: |
| 249 | | snprintf(fname, 8192, "%s_idx16_lut.fsh", custShaderPrefix); fname[8191]=0; |
| 250 | | break; |
| 251 | | case GLSL_SHADER_TYPE_RGB32_LUT: |
| 252 | | snprintf(fname, 8192, "%s_rgb32_lut.fsh", custShaderPrefix); fname[8191]=0; |
| 253 | | break; |
| 254 | | case GLSL_SHADER_TYPE_RGB32_DIRECT: |
| 255 | | snprintf(fname, 8192, "%s_rgb32_dir.fsh", custShaderPrefix); fname[8191]=0; |
| 256 | | break; |
| 257 | | } |
| 210 | snprintf(fname, 8192, "%s_rgb32_dir.fsh", custShaderPrefix); fname[8191]=0; |
| 258 | 211 | |
| 259 | | err = gl_compile_shader_files (&glsl_mamebm_programs[i][GLSL_SHADER_FEAT_CUSTOM+idx], |
| 260 | | &glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_CUSTOM+idx], |
| 261 | | &glsl_mamebm_fsh_shader[i][GLSL_SHADER_FEAT_CUSTOM+idx], |
| 262 | | NULL /*precompiled*/, fname, 0); |
| 263 | | } |
| 212 | err = gl_compile_shader_files (&glsl_mamebm_programs[GLSL_SHADER_FEAT_CUSTOM+idx], |
| 213 | &glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_CUSTOM+idx], |
| 214 | &glsl_mamebm_fsh_shader[GLSL_SHADER_FEAT_CUSTOM+idx], |
| 215 | NULL /*precompiled*/, fname, 0); |
| 216 | |
| 264 | 217 | return err; |
| 265 | 218 | } |
| 266 | 219 | |
trunk/src/osd/sdl/drawogl.c
| r28745 | r28746 | |
| 2 | 2 | // |
| 3 | 3 | // drawogl.c - SDL software and OpenGL implementation |
| 4 | 4 | // |
| 5 | | // Copyright (c) 1996-2011, Nicola Salmoria and the MAME Team. |
| 5 | // Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team. |
| 6 | 6 | // Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | 7 | // |
| 8 | 8 | // SDLMAME by Olivier Galibert and R. Belmont |
| r28745 | r28746 | |
| 251 | 251 | // as input, otherwise the screen bitmap. |
| 252 | 252 | // All progs >= glsl_program_mb2sc using the screen bitmap |
| 253 | 253 | // as output, otherwise the mame bitmap. |
| 254 | | int glsl_vid_attributes;// glsl brightness, contrast and gamma for RGB bitmaps |
| 255 | 254 | int usetexturerect; // use ARB_texture_rectangle for non-power-of-2, general use |
| 256 | 255 | |
| 257 | 256 | int init_context; // initialize context before next draw |
| 258 | 257 | |
| 259 | | int totalColors; // total colors from machine/sdl_window_config/sdl_window_info |
| 260 | | |
| 261 | 258 | float last_hofs; |
| 262 | 259 | float last_vofs; |
| 263 | 260 | |
| r28745 | r28746 | |
| 398 | 395 | static void texcopy_rgb15_paletted(texture_info *texture, const render_texinfo *texsource); |
| 399 | 396 | static void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource); |
| 400 | 397 | static void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource); |
| 401 | | #if 0 //def SDLMAME_MACOSX |
| 402 | | static void texcopy_yuv16_apple(texture_info *texture, const render_texinfo *texsource); |
| 403 | | static void texcopy_yuv16_paletted_apple(texture_info *texture, const render_texinfo *texsource); |
| 404 | | #endif |
| 405 | | // 16 bpp destination texture texcopy functions |
| 406 | | static void texcopy_palette16_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 407 | | static void texcopy_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 408 | | static void texcopy_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 409 | 398 | |
| 410 | 399 | //============================================================ |
| 411 | 400 | // Textures |
| r28745 | r28746 | |
| 622 | 611 | SDL_WM_SetCaption(window->title, "SDLMAME"); |
| 623 | 612 | |
| 624 | 613 | #endif |
| 625 | | sdl->totalColors = window->totalColors; |
| 626 | 614 | sdl->blittimer = 0; |
| 627 | 615 | sdl->surf_w = 0; |
| 628 | 616 | sdl->surf_h = 0; |
| r28745 | r28746 | |
| 767 | 755 | } |
| 768 | 756 | } |
| 769 | 757 | |
| 770 | | sdl->glsl_vid_attributes = video_config.glsl_vid_attributes; |
| 771 | | |
| 772 | 758 | if (osd_getenv(SDLENV_VMWARE) != NULL) |
| 773 | 759 | { |
| 774 | 760 | sdl->usetexturerect = 1; |
| r28745 | r28746 | |
| 1149 | 1135 | } |
| 1150 | 1136 | } |
| 1151 | 1137 | |
| 1152 | | if (_once) |
| 1153 | | { |
| 1154 | | if ( sdl->glsl_vid_attributes ) |
| 1155 | | { |
| 1156 | | mame_printf_verbose("OpenGL: GLSL direct brightness, contrast setting for RGB games\n"); |
| 1157 | | } |
| 1158 | | else |
| 1159 | | { |
| 1160 | | mame_printf_verbose("OpenGL: GLSL paletted gamma, brightness, contrast setting for RGB games\n"); |
| 1161 | | } |
| 1162 | | } |
| 1163 | 1138 | } else { |
| 1164 | 1139 | if (_once) |
| 1165 | 1140 | { |
| r28745 | r28746 | |
| 1594 | 1569 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_ARGB32 |
| 1595 | 1570 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB32 |
| 1596 | 1571 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB32_PALETTED |
| 1597 | | #if 0 //def SDLMAME_MACOSX |
| 1598 | | { GL_RGB8, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, sizeof(UINT16) }, // SDL_TEXFORMAT_YUY16 |
| 1599 | | { GL_RGB8, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, sizeof(UINT16) }, // SDL_TEXFORMAT_YUY16_PALETTED |
| 1600 | | #else |
| 1601 | 1572 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_YUY16 |
| 1602 | 1573 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_YUY16_PALETTED |
| 1603 | | #endif |
| 1604 | | { GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, sizeof(UINT16) }, // SDL_TEXFORMAT_PALETTE16 |
| 1605 | | { GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, sizeof(UINT16) }, // SDL_TEXFORMAT_RGB15 |
| 1606 | | { GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, sizeof(UINT16) }, // SDL_TEXFORMAT_RGB15_PALETTED |
| 1574 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_PALETTE16 |
| 1575 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB15 |
| 1576 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB15_PALETTED |
| 1607 | 1577 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) } // SDL_TEXFORMAT_PALETTE16A |
| 1608 | 1578 | }; |
| 1609 | 1579 | |
| r28745 | r28746 | |
| 1611 | 1581 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_ARGB32 |
| 1612 | 1582 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB32 |
| 1613 | 1583 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB32_PALETTED |
| 1614 | | #if 0 //def SDLMAME_MACOSX |
| 1615 | | { GL_RGB8, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, sizeof(UINT16) }, // SDL_TEXFORMAT_YUY16 |
| 1616 | | { GL_RGB8, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, sizeof(UINT16) }, // SDL_TEXFORMAT_YUY16_PALETTED |
| 1617 | | #else |
| 1618 | 1584 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_YUY16 |
| 1619 | 1585 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_YUY16_PALETTED |
| 1620 | | #endif |
| 1621 | 1586 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_PALETTE16 |
| 1622 | | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, sizeof(UINT16) }, // SDL_TEXFORMAT_RGB15 |
| 1623 | | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, sizeof(UINT16) }, // SDL_TEXFORMAT_RGB15_PALETTED |
| 1587 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB15 |
| 1588 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB15_PALETTED |
| 1624 | 1589 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) } // SDL_TEXFORMAT_PALETTE16A |
| 1625 | 1590 | }; |
| 1626 | 1591 | |
| r28745 | r28746 | |
| 1628 | 1593 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_ARGB32 |
| 1629 | 1594 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB32 |
| 1630 | 1595 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB32_PALETTED |
| 1631 | | #if 0 //def SDLMAME_MACOSX |
| 1632 | | { GL_RGB8, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, sizeof(UINT16) }, // SDL_TEXFORMAT_YUY16 |
| 1633 | | { GL_RGB8, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, sizeof(UINT16) }, // SDL_TEXFORMAT_YUY16_PALETTED |
| 1634 | | #else |
| 1635 | 1596 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_YUY16 |
| 1636 | 1597 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_YUY16_PALETTED |
| 1637 | | #endif |
| 1638 | 1598 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_PALETTE16 |
| 1639 | 1599 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB15 |
| 1640 | 1600 | { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, sizeof(UINT32) }, // SDL_TEXFORMAT_RGB15_PALETTED |
| r28745 | r28746 | |
| 1645 | 1605 | texcopy_argb32, |
| 1646 | 1606 | texcopy_rgb32, |
| 1647 | 1607 | texcopy_rgb32_paletted, |
| 1648 | | #if 0 //def SDLMAME_MACOSX |
| 1649 | | texcopy_yuv16_apple, |
| 1650 | | texcopy_yuv16_paletted_apple, |
| 1651 | | #else |
| 1652 | 1608 | texcopy_yuv16, |
| 1653 | 1609 | texcopy_yuv16_paletted, |
| 1654 | | #endif |
| 1655 | | |
| 1656 | | texcopy_palette16_argb1555, |
| 1657 | | texcopy_rgb15_argb1555, |
| 1658 | | texcopy_rgb15_paletted_argb1555, |
| 1610 | texcopy_palette16, |
| 1611 | texcopy_rgb15, |
| 1612 | texcopy_rgb15_paletted, |
| 1659 | 1613 | texcopy_palette16a |
| 1660 | 1614 | }; |
| 1661 | 1615 | |
| r28745 | r28746 | |
| 1663 | 1617 | texcopy_argb32, |
| 1664 | 1618 | texcopy_rgb32, |
| 1665 | 1619 | texcopy_rgb32_paletted, |
| 1666 | | #if 0 //def SDLMAME_MACOSX |
| 1667 | | texcopy_yuv16_apple, |
| 1668 | | texcopy_yuv16_paletted_apple, |
| 1669 | | #else |
| 1670 | 1620 | texcopy_yuv16, |
| 1671 | 1621 | texcopy_yuv16_paletted, |
| 1672 | | #endif |
| 1673 | | |
| 1674 | 1622 | texcopy_palette16, |
| 1675 | 1623 | texcopy_rgb15, |
| 1676 | 1624 | texcopy_rgb15_paletted, |
| r28745 | r28746 | |
| 1763 | 1711 | if ( texture->type == TEXTURE_TYPE_NONE && |
| 1764 | 1712 | sdl->useglsl && |
| 1765 | 1713 | ( |
| 1766 | | texture->format==SDL_TEXFORMAT_PALETTE16 || // glsl idx16 lut |
| 1767 | 1714 | texture->format==SDL_TEXFORMAT_RGB32_PALETTED || // glsl rgb32 lut/direct |
| 1768 | 1715 | texture->format==SDL_TEXFORMAT_RGB32 || |
| 1769 | 1716 | texture->format==SDL_TEXFORMAT_RGB15_PALETTED || // glsl rgb15 lut/direct |
| r28745 | r28746 | |
| 1806 | 1753 | texture->texpow2 = (sdl->usetexturerect)?0:sdl->texpoweroftwo; |
| 1807 | 1754 | } |
| 1808 | 1755 | |
| 1809 | | if ( texture->type!=TEXTURE_TYPE_SHADER && video_config.prefer16bpp_tex ) |
| 1756 | if ( texture->type!=TEXTURE_TYPE_SHADER ) |
| 1810 | 1757 | { |
| 1811 | 1758 | texture->texProperties = texture_gl_properties_srcNative_intNative[texture->format]; |
| 1812 | 1759 | texture->texCopyFn = texcopy_dstNative_f[texture->format]; |
| r28745 | r28746 | |
| 1928 | 1875 | ) |
| 1929 | 1876 | { |
| 1930 | 1877 | mame_printf_verbose("GL texture: copy %d, shader %d, dynamic %d, %dx%d %dx%d [%s, Equal: %d, Palette: %d,\n" |
| 1931 | | " scale %dx%d, border %d, pitch %d,%d/%d], colors: %d, bytes/pix %d\n", |
| 1878 | " scale %dx%d, border %d, pitch %d,%d/%d], bytes/pix %d\n", |
| 1932 | 1879 | !texture->nocopy, texture->type==TEXTURE_TYPE_SHADER, texture->type==TEXTURE_TYPE_DYNAMIC, |
| 1933 | 1880 | finalwidth, finalheight, finalwidth_create, finalheight_create, |
| 1934 | 1881 | texfmt_to_string[texture->format], |
| r28745 | r28746 | |
| 1936 | 1883 | (int)texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_HAS_PALETTE], |
| 1937 | 1884 | texture->xprescale, texture->yprescale, |
| 1938 | 1885 | texture->borderpix, texsource->rowpixels, finalwidth, sdl->texture_max_width, |
| 1939 | | sdl->totalColors, (int)texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE] |
| 1886 | (int)texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE] |
| 1940 | 1887 | ); |
| 1941 | 1888 | } |
| 1942 | 1889 | |
| r28745 | r28746 | |
| 2038 | 1985 | int uniform_location; |
| 2039 | 1986 | int lut_table_width_pow2=0; |
| 2040 | 1987 | int lut_table_height_pow2=0; |
| 2041 | | int glsl_shader_type_rgb32 = ( sdl->glsl_vid_attributes ) ? GLSL_SHADER_TYPE_RGB32_DIRECT : GLSL_SHADER_TYPE_RGB32_LUT; |
| 2042 | | int glsl_shader_type, i; |
| 2043 | | int lut_texture_width; |
| 1988 | int i; |
| 2044 | 1989 | int surf_w_pow2 = get_valid_pow2_value (window->width, texture->texpow2); |
| 2045 | 1990 | int surf_h_pow2 = get_valid_pow2_value (window->height, texture->texpow2); |
| 2046 | 1991 | |
| r28745 | r28746 | |
| 2052 | 1997 | { |
| 2053 | 1998 | case SDL_TEXFORMAT_RGB32_PALETTED: |
| 2054 | 1999 | case SDL_TEXFORMAT_RGB32: |
| 2055 | | glsl_shader_type = glsl_shader_type_rgb32; |
| 2056 | 2000 | texture->lut_table_width = 1 << 8; // 8 bits per component |
| 2057 | 2001 | texture->lut_table_width *= 3; // BGR .. |
| 2058 | 2002 | break; |
| 2059 | 2003 | |
| 2060 | 2004 | case SDL_TEXFORMAT_RGB15_PALETTED: |
| 2061 | 2005 | case SDL_TEXFORMAT_RGB15: |
| 2062 | | glsl_shader_type = glsl_shader_type_rgb32; |
| 2063 | 2006 | texture->lut_table_width = 1 << 5; // 5 bits per component |
| 2064 | 2007 | texture->lut_table_width *= 3; // BGR .. |
| 2065 | 2008 | break; |
| 2066 | 2009 | |
| 2067 | 2010 | case SDL_TEXFORMAT_PALETTE16: |
| 2068 | | glsl_shader_type = GLSL_SHADER_TYPE_IDX16; |
| 2069 | | texture->lut_table_width = sdl->totalColors; |
| 2011 | texture->lut_table_width = (1 << 8) * 3; |
| 2070 | 2012 | break; |
| 2071 | 2013 | |
| 2072 | 2014 | default: |
| r28745 | r28746 | |
| 2075 | 2017 | exit(1); |
| 2076 | 2018 | } |
| 2077 | 2019 | |
| 2078 | | /** |
| 2079 | | * We experience some GLSL LUT calculation inaccuracy on some GL drivers. |
| 2080 | | * while using the correct lut calculations. |
| 2081 | | * This error is due to the color index value to GLSL/texture passing process: |
| 2082 | | * mame:uint16_t -> OpenGL: GLfloat(alpha texture) -> GLSL:uint16_t (value regeneration) |
| 2083 | | * The latter inaccurate uint16_t value regeneration is buggy on some drivers/cards, |
| 2084 | | * therefor we always widen the lut size to pow2, |
| 2085 | | * and shape it equaly into 2D space (max texture size restriction). |
| 2086 | | * This is a practical GL driver workaround to minimize the chance for |
| 2087 | | * floating point arithmetic errors in the GLSL engine. |
| 2088 | | * |
| 2089 | | * Shape the lut texture to achieve texture max size compliance and equal 2D partitioning |
| 2090 | | */ |
| 2020 | texture->lut_table_height = 1; |
| 2091 | 2021 | |
| 2092 | | if ( texture->format == SDL_TEXFORMAT_PALETTE16 ) |
| 2093 | | { |
| 2094 | | lut_texture_width = sqrt((double)(texture->lut_table_width)); |
| 2095 | | lut_texture_width = get_valid_pow2_value (lut_texture_width, 1); |
| 2096 | | |
| 2097 | | texture->lut_table_height = texture->lut_table_width / lut_texture_width; |
| 2098 | | |
| 2099 | | if ( lut_texture_width*texture->lut_table_height < texture->lut_table_width ) |
| 2100 | | { |
| 2101 | | texture->lut_table_height += 1; |
| 2102 | | } |
| 2103 | | |
| 2104 | | texture->lut_table_width = lut_texture_width; |
| 2105 | | } |
| 2106 | | else |
| 2107 | | { |
| 2108 | | lut_texture_width = texture->lut_table_width; |
| 2109 | | texture->lut_table_height = 1; |
| 2110 | | } |
| 2111 | | |
| 2112 | 2022 | /** |
| 2113 | 2023 | * always use pow2 for LUT, to minimize the chance for floating point arithmetic errors |
| 2114 | 2024 | * (->buggy GLSL engine) |
| r28745 | r28746 | |
| 2116 | 2026 | lut_table_height_pow2 = get_valid_pow2_value (texture->lut_table_height, 1 /* texture->texpow2 */); |
| 2117 | 2027 | lut_table_width_pow2 = get_valid_pow2_value (texture->lut_table_width, 1 /* texture->texpow2 */); |
| 2118 | 2028 | |
| 2119 | | if ( !sdl->glsl_vid_attributes || texture->format==SDL_TEXFORMAT_PALETTE16 ) |
| 2120 | | { |
| 2121 | | mame_printf_verbose("GL texture: lut_texture_width %d, lut_table_sz %dx%d, lut_table_sz_pow2 %dx%d\n", |
| 2122 | | lut_texture_width, texture->lut_table_width, texture->lut_table_height, |
| 2123 | | lut_table_width_pow2, lut_table_height_pow2); |
| 2124 | | } |
| 2125 | | |
| 2126 | | |
| 2127 | 2029 | if ( lut_table_width_pow2 > sdl->texture_max_width || lut_table_height_pow2 > sdl->texture_max_height ) |
| 2128 | 2030 | { |
| 2129 | 2031 | mame_printf_error("Need lut size %dx%d, but max text size is %dx%d, bail out\n", |
| r28745 | r28746 | |
| 2149 | 2051 | { |
| 2150 | 2052 | if ( i<=sdl->glsl_program_mb2sc ) |
| 2151 | 2053 | { |
| 2152 | | sdl->glsl_program[i] = glsl_shader_get_program_mamebm(glsl_shader_type, glsl_shader_feature, i); |
| 2054 | sdl->glsl_program[i] = glsl_shader_get_program_mamebm(glsl_shader_feature, i); |
| 2153 | 2055 | } else { |
| 2154 | 2056 | sdl->glsl_program[i] = glsl_shader_get_program_scrn(i-1-sdl->glsl_program_mb2sc); |
| 2155 | 2057 | } |
| 2156 | 2058 | pfn_glUseProgramObjectARB(sdl->glsl_program[i]); |
| 2157 | 2059 | |
| 2158 | | if ( i<=sdl->glsl_program_mb2sc && !(sdl->glsl_vid_attributes && texture->format!=SDL_TEXFORMAT_PALETTE16) ) |
| 2159 | | { |
| 2160 | | // GL_TEXTURE1 GLSL Uniforms |
| 2161 | | uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[i], "colortable_texture"); |
| 2162 | | pfn_glUniform1iARB(uniform_location, 1); |
| 2163 | | GL_CHECK_ERROR_NORMAL(); |
| 2164 | | |
| 2165 | | { |
| 2166 | | GLfloat colortable_sz[2] = { (GLfloat)texture->lut_table_width, (GLfloat)texture->lut_table_height }; |
| 2167 | | uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[i], "colortable_sz"); |
| 2168 | | pfn_glUniform2fvARB(uniform_location, 1, &(colortable_sz[0])); |
| 2169 | | GL_CHECK_ERROR_NORMAL(); |
| 2170 | | } |
| 2171 | | |
| 2172 | | { |
| 2173 | | GLfloat colortable_pow2_sz[2] = { (GLfloat)lut_table_width_pow2, (GLfloat)lut_table_height_pow2 }; |
| 2174 | | uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[i], "colortable_pow2_sz"); |
| 2175 | | pfn_glUniform2fvARB(uniform_location, 1, &(colortable_pow2_sz[0])); |
| 2176 | | GL_CHECK_ERROR_NORMAL(); |
| 2177 | | } |
| 2178 | | } |
| 2179 | | |
| 2180 | 2060 | if ( i<=sdl->glsl_program_mb2sc ) |
| 2181 | 2061 | { |
| 2182 | 2062 | // GL_TEXTURE0 GLSL Uniforms |
| r28745 | r28746 | |
| 2264 | 2144 | window->width, window->height, surf_w_pow2, surf_h_pow2); |
| 2265 | 2145 | } |
| 2266 | 2146 | |
| 2267 | | if ( !(sdl->glsl_vid_attributes && texture->format!=SDL_TEXFORMAT_PALETTE16) ) |
| 2268 | | { |
| 2269 | | // GL_TEXTURE1 |
| 2270 | | glGenTextures(1, (GLuint *)&texture->lut_texture); |
| 2271 | | pfn_glActiveTexture(GL_TEXTURE1); |
| 2272 | | glBindTexture(GL_TEXTURE_2D, texture->lut_texture); |
| 2273 | | |
| 2274 | | glPixelStorei(GL_UNPACK_ROW_LENGTH, lut_table_width_pow2); |
| 2275 | | |
| 2276 | | { |
| 2277 | | GLint _width, _height; |
| 2278 | | if ( gl_texture_check_size(GL_TEXTURE_2D, 0, GL_RGBA8, lut_table_width_pow2, lut_table_height_pow2, |
| 2279 | | 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &_width, &_height, 1) ) |
| 2280 | | { |
| 2281 | | mame_printf_error("cannot create lut table texture, req: %dx%d, avail: %dx%d - bail out\n", |
| 2282 | | lut_table_width_pow2, lut_table_height_pow2, (int)_width, (int)_height); |
| 2283 | | return -1; |
| 2284 | | } |
| 2285 | | } |
| 2286 | | |
| 2287 | | { |
| 2288 | | UINT32 * dummy = (UINT32 *) malloc(lut_table_width_pow2*lut_table_height_pow2 * sizeof(UINT32)); // blank out the whole pal. |
| 2289 | | memset(dummy, 0, lut_table_width_pow2*lut_table_height_pow2 * sizeof(UINT32)); |
| 2290 | | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, lut_table_width_pow2, lut_table_height_pow2, |
| 2291 | | 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, dummy ); |
| 2292 | | glFinish(); // should not be necessary, .. but make sure we won't access the memory after free |
| 2293 | | free(dummy); |
| 2294 | | } |
| 2295 | | |
| 2296 | | glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->lut_table_width); |
| 2297 | | |
| 2298 | | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->lut_table_width, texture->lut_table_height, |
| 2299 | | GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, texsource->palette ); |
| 2300 | | |
| 2301 | | // non-screen textures will never be filtered |
| 2302 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 2303 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 2304 | | |
| 2305 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2306 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2307 | | |
| 2308 | | assert ( texture->lut_texture ); |
| 2309 | | } |
| 2310 | | |
| 2311 | 2147 | // GL_TEXTURE0 |
| 2312 | 2148 | // get a name for this texture |
| 2313 | 2149 | glGenTextures(1, (GLuint *)&texture->texture); |
| r28745 | r28746 | |
| 2316 | 2152 | |
| 2317 | 2153 | glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->rawwidth_create); |
| 2318 | 2154 | |
| 2319 | | if(texture->format!=SDL_TEXFORMAT_PALETTE16) |
| 2155 | UINT32 * dummy = NULL; |
| 2156 | GLint _width, _height; |
| 2157 | if ( gl_texture_check_size(GL_TEXTURE_2D, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], |
| 2158 | texture->rawwidth_create, texture->rawheight_create, |
| 2159 | 0, |
| 2160 | texture->texProperties[SDL_TEXFORMAT_FORMAT], |
| 2161 | texture->texProperties[SDL_TEXFORMAT_TYPE], |
| 2162 | &_width, &_height, 1) ) |
| 2320 | 2163 | { |
| 2321 | | UINT32 * dummy = NULL; |
| 2322 | | GLint _width, _height; |
| 2323 | | if ( gl_texture_check_size(GL_TEXTURE_2D, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], |
| 2324 | | texture->rawwidth_create, texture->rawheight_create, |
| 2325 | | 0, |
| 2326 | | texture->texProperties[SDL_TEXFORMAT_FORMAT], |
| 2327 | | texture->texProperties[SDL_TEXFORMAT_TYPE], |
| 2328 | | &_width, &_height, 1) ) |
| 2329 | | { |
| 2330 | | mame_printf_error("cannot create bitmap texture, req: %dx%d, avail: %dx%d - bail out\n", |
| 2331 | | texture->rawwidth_create, texture->rawheight_create, (int)_width, (int)_height); |
| 2332 | | return -1; |
| 2333 | | } |
| 2164 | mame_printf_error("cannot create bitmap texture, req: %dx%d, avail: %dx%d - bail out\n", |
| 2165 | texture->rawwidth_create, texture->rawheight_create, (int)_width, (int)_height); |
| 2166 | return -1; |
| 2167 | } |
| 2334 | 2168 | |
| 2335 | | dummy = (UINT32 *) malloc(texture->rawwidth_create * texture->rawheight_create * |
| 2336 | | texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); |
| 2337 | | memset(dummy, 0, texture->rawwidth_create * texture->rawheight_create * |
| 2338 | | texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); |
| 2339 | | glTexImage2D(GL_TEXTURE_2D, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], |
| 2340 | | texture->rawwidth_create, texture->rawheight_create, |
| 2341 | | 0, |
| 2342 | | texture->texProperties[SDL_TEXFORMAT_FORMAT], |
| 2343 | | texture->texProperties[SDL_TEXFORMAT_TYPE], dummy); |
| 2344 | | glFinish(); // should not be necessary, .. but make sure we won't access the memory after free |
| 2345 | | free(dummy); |
| 2169 | dummy = (UINT32 *) malloc(texture->rawwidth_create * texture->rawheight_create * |
| 2170 | texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); |
| 2171 | memset(dummy, 0, texture->rawwidth_create * texture->rawheight_create * |
| 2172 | texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); |
| 2173 | glTexImage2D(GL_TEXTURE_2D, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], |
| 2174 | texture->rawwidth_create, texture->rawheight_create, |
| 2175 | 0, |
| 2176 | texture->texProperties[SDL_TEXFORMAT_FORMAT], |
| 2177 | texture->texProperties[SDL_TEXFORMAT_TYPE], dummy); |
| 2178 | glFinish(); // should not be necessary, .. but make sure we won't access the memory after free |
| 2179 | free(dummy); |
| 2346 | 2180 | |
| 2347 | | if ((PRIMFLAG_GET_SCREENTEX(flags)) && video_config.filter) |
| 2348 | | { |
| 2349 | | assert( glsl_shader_feature == GLSL_SHADER_FEAT_PLAIN ); |
| 2181 | if ((PRIMFLAG_GET_SCREENTEX(flags)) && video_config.filter) |
| 2182 | { |
| 2183 | assert( glsl_shader_feature == GLSL_SHADER_FEAT_PLAIN ); |
| 2350 | 2184 | |
| 2351 | | // screen textures get the user's choice of filtering |
| 2352 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 2353 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 2354 | | } |
| 2355 | | else |
| 2356 | | { |
| 2357 | | // non-screen textures will never be filtered |
| 2358 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 2359 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 2360 | | } |
| 2361 | | |
| 2362 | | // set wrapping mode appropriately |
| 2363 | | if (texture->flags & PRIMFLAG_TEXWRAP_MASK) |
| 2364 | | { |
| 2365 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 2366 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 2367 | | } |
| 2368 | | else |
| 2369 | | { |
| 2370 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2371 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2372 | | } |
| 2373 | | } else { |
| 2374 | | UINT32 * dummy = NULL; |
| 2375 | | GLint _width, _height; |
| 2376 | | if ( gl_texture_check_size(GL_TEXTURE_2D, 0, GL_ALPHA16, texture->rawwidth_create, texture->rawheight_create, |
| 2377 | | 0, GL_ALPHA, GL_UNSIGNED_SHORT, &_width, &_height, 1) ) |
| 2378 | | { |
| 2379 | | mame_printf_error("cannot create lut bitmap texture, req: %dx%d, avail: %dx%d - bail out\n", |
| 2380 | | texture->rawwidth_create, texture->rawheight_create, |
| 2381 | | (int)_width, (int)_height); |
| 2382 | | return -1; |
| 2383 | | } |
| 2384 | | dummy = (UINT32 *) malloc(texture->rawwidth_create * texture->rawheight_create * sizeof(UINT16)); |
| 2385 | | memset(dummy, 0, texture->rawwidth_create * texture->rawheight_create * sizeof(UINT16)); |
| 2386 | | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA16, |
| 2387 | | texture->rawwidth_create, texture->rawheight_create, |
| 2388 | | 0, |
| 2389 | | GL_ALPHA, GL_UNSIGNED_SHORT, dummy); |
| 2390 | | glFinish(); // should not be necessary, .. but make sure we won't access the memory after free |
| 2391 | | free(dummy); |
| 2185 | // screen textures get the user's choice of filtering |
| 2186 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 2187 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 2188 | } |
| 2189 | else |
| 2190 | { |
| 2191 | // non-screen textures will never be filtered |
| 2392 | 2192 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 2393 | 2193 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 2394 | | if (texture->flags & PRIMFLAG_TEXWRAP_MASK) |
| 2395 | | { |
| 2396 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 2397 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 2398 | | } |
| 2399 | | else |
| 2400 | | { |
| 2401 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2402 | | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2403 | | } |
| 2404 | 2194 | } |
| 2405 | 2195 | |
| 2196 | // set wrapping mode appropriately |
| 2197 | if (texture->flags & PRIMFLAG_TEXWRAP_MASK) |
| 2198 | { |
| 2199 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 2200 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 2201 | } |
| 2202 | else |
| 2203 | { |
| 2204 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
| 2205 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
| 2206 | } |
| 2207 | |
| 2406 | 2208 | GL_CHECK_ERROR_NORMAL(); |
| 2407 | 2209 | |
| 2408 | 2210 | return 0; |
| r28745 | r28746 | |
| 2662 | 2464 | glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->texinfo.rowpixels); |
| 2663 | 2465 | |
| 2664 | 2466 | // and upload the image |
| 2665 | | if(texture->format!=SDL_TEXFORMAT_PALETTE16) |
| 2666 | | { |
| 2667 | | glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, |
| 2668 | | texture->texProperties[SDL_TEXFORMAT_FORMAT], |
| 2669 | | texture->texProperties[SDL_TEXFORMAT_TYPE], texture->data); |
| 2670 | | } |
| 2671 | | else |
| 2672 | | { |
| 2673 | | glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, |
| 2674 | | GL_ALPHA, GL_UNSIGNED_SHORT, texture->data); |
| 2675 | | } |
| 2467 | glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, |
| 2468 | texture->texProperties[SDL_TEXFORMAT_FORMAT], |
| 2469 | texture->texProperties[SDL_TEXFORMAT_TYPE], texture->data); |
| 2676 | 2470 | } |
| 2677 | 2471 | else if ( texture->type == TEXTURE_TYPE_DYNAMIC ) |
| 2678 | 2472 | { |
| r28745 | r28746 | |
| 2940 | 2734 | render_container *container; |
| 2941 | 2735 | GLfloat vid_attributes[4]; // gamma, contrast, brightness, effect |
| 2942 | 2736 | |
| 2943 | | assert ( sdl->glsl_vid_attributes && texture->format!=SDL_TEXFORMAT_PALETTE16 ); |
| 2944 | | |
| 2945 | 2737 | scrnum = 0; |
| 2946 | 2738 | container = (render_container *)NULL; |
| 2947 | 2739 | screen_device_iterator iter(window->machine().root_device()); |