Commit 8b4a508f authored by Sam Lantinga's avatar Sam Lantinga

Slight optimization of the shader, no need to scale into 0..255

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403307
parent 5908561e
...@@ -380,12 +380,14 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) ...@@ -380,12 +380,14 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
} }
--info->num_texture_formats; --info->num_texture_formats;
} }
/*
if (SDL_GL_ExtensionSupported("GL_APPLE_ycbcr_422")) { if (SDL_GL_ExtensionSupported("GL_APPLE_ycbcr_422")) {
data->GL_APPLE_ycbcr_422_supported = SDL_TRUE; data->GL_APPLE_ycbcr_422_supported = SDL_TRUE;
} }
if (SDL_GL_ExtensionSupported("GL_MESA_ycbcr_texture")) { if (SDL_GL_ExtensionSupported("GL_MESA_ycbcr_texture")) {
data->GL_MESA_ycbcr_texture_supported = SDL_TRUE; data->GL_MESA_ycbcr_texture_supported = SDL_TRUE;
} }
*/
if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) { if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) {
data->glTextureRangeAPPLE = data->glTextureRangeAPPLE =
(void (*)(GLenum, GLsizei, const GLvoid *)) (void (*)(GLenum, GLsizei, const GLvoid *))
...@@ -515,7 +517,7 @@ compile_shader(GL_RenderData *data, GLenum shader_type, const char *source) ...@@ -515,7 +517,7 @@ compile_shader(GL_RenderData *data, GLenum shader_type, const char *source)
// Byte layout is Cb, Y1, Cr, Y2. // Byte layout is Cb, Y1, Cr, Y2.
// 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr // 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr
// !!! FIXME: this ignores blendmodes, etc. // !!! FIXME: this ignores blendmodes, etc.
// !!! FIXME: this could be more efficient...use a dot product for green, not convert to 255.0 range, etc. // !!! FIXME: this could be more efficient...use a dot product for green, etc.
static const char *fragment_program_UYVY_source_code = static const char *fragment_program_UYVY_source_code =
"!!ARBfp1.0\n" "!!ARBfp1.0\n"
...@@ -531,13 +533,12 @@ static const char *fragment_program_UYVY_source_code = ...@@ -531,13 +533,12 @@ static const char *fragment_program_UYVY_source_code =
// halve the coordinates to grab the correct 32 bits for the fragment. // halve the coordinates to grab the correct 32 bits for the fragment.
"MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n" "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n"
// Sample the YUV texture. Cb, Y1, Cr, Y2, are stored in r,g,b,a. // Sample the YUV texture. Cb, Y1, Cr, Y2, are stored x,y,z,w
// !!! FIXME: "RECT" needs to be "2D" if we're not using texture_rectangle extension. :/ // !!! FIXME: "RECT" needs to be "2D" if we're not using texture_rectangle extension. :/
"TEX uyvy, work, texture[0], RECT;\n" "TEX uyvy, work, texture[0], RECT;\n"
// Scale from 0.0/1.0 to 0.0/255.0 and do subtractions. (!!! FIXME: optimize!) // Do subtractions (128/255, 16/255, 128/255, 16/255)
"MUL uyvy, uyvy, { 255.0, 255.0, 255.0, 255.0 };\n" "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n"
"SUB uyvy, uyvy, { 128.0, 16.0, 128.0, 16.0 };\n"
// Choose the luminance component by texcoord. // Choose the luminance component by texcoord.
// !!! FIXME: laziness wins out for now... just average Y1 and Y2. // !!! FIXME: laziness wins out for now... just average Y1 and Y2.
...@@ -556,9 +557,6 @@ static const char *fragment_program_UYVY_source_code = ...@@ -556,9 +557,6 @@ static const char *fragment_program_UYVY_source_code =
// Do final addition for Green channel. (!!! FIXME: this should be a DPH?) // Do final addition for Green channel. (!!! FIXME: this should be a DPH?)
"ADD work.g, work.g, uyvy.w;\n" "ADD work.g, work.g, uyvy.w;\n"
// Scale back to 0.0/1.0. (this number is 1.0/255.0).
"MUL work, work, { 0.0039215686274509803, 0.0039215686274509803, 0.0039215686274509803, 0.0039215686274509803 };\n"
// Make sure alpha channel is fully opaque. (!!! FIXME: blend modes!) // Make sure alpha channel is fully opaque. (!!! FIXME: blend modes!)
"MOV work.a, { 1.0 };\n" "MOV work.a, { 1.0 };\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment