[PATCH 4/5] wined3d: Pass a struct arbfp_blit_type to the blit shader generation functions.

Stefan Dösinger stefan at codeweavers.com
Sat Mar 28 11:06:20 CDT 2015


---
 dlls/wined3d/arb_program_shader.c | 56 +++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 26 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 3f86b80..f931b06 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -6904,21 +6904,24 @@ static void arbfp_blit_free(struct wined3d_device *device)
     device->blit_priv = NULL;
 }
 
-static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum complex_fixup fixup,
-        enum wined3d_ffp_texture_type textype, char *luminance)
+static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, const struct arbfp_blit_type *type,
+        char *luminance)
 {
     char chroma;
     const char *tex, *texinstr;
 
-    if (fixup == COMPLEX_FIXUP_UYVY) {
+    if (type->fixup == COMPLEX_FIXUP_UYVY)
+    {
         chroma = 'x';
         *luminance = 'w';
-    } else {
+    }
+    else
+    {
         chroma = 'w';
         *luminance = 'x';
     }
 
-    switch(textype)
+    switch (type->textype)
     {
         case WINED3D_FFP_TEXTURE_TYPE_2D:
             tex = "2D";
@@ -6950,7 +6953,7 @@ static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum compl
      *
      * So we have to get the sampling x position in non-normalized coordinates in integers
      */
-    if (textype != WINED3D_FFP_TEXTURE_TYPE_RECT)
+    if (type->textype != WINED3D_FFP_TEXTURE_TYPE_RECT)
     {
         shader_addline(buffer, "MUL texcrd.xy, fragment.texcoord[0], size.x;\n");
         shader_addline(buffer, "MOV texcrd.w, size.x;\n");
@@ -7005,13 +7008,14 @@ static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum compl
     return TRUE;
 }
 
-static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp_texture_type textype, char *luminance)
+static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, const struct arbfp_blit_type *type,
+        char *luminance)
 {
     const char *tex;
     static const float yv12_coef[]
             = {2.0f / 3.0f, 1.0f / 6.0f, (2.0f / 3.0f) + (1.0f / 6.0f), 1.0f / 3.0f};
 
-    switch (textype)
+    switch (type->textype)
     {
         case WINED3D_FFP_TEXTURE_TYPE_2D:
             tex = "2D";
@@ -7078,7 +7082,7 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
      * Don't forget to clamp the y values in into the range, otherwise we'll get filtering
      * bleeding
      */
-    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
+    if (type->textype == WINED3D_FFP_TEXTURE_TYPE_2D)
     {
 
         shader_addline(buffer, "RCP chroma.w, size.y;\n");
@@ -7131,7 +7135,7 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
     /* The other chroma value is 1/6th of the texture lower, from 5/6th to 6/6th
      * No need to clamp because we're just reusing the already clamped value from above
      */
-    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
+    if (type->textype == WINED3D_FFP_TEXTURE_TYPE_2D)
         shader_addline(buffer, "ADD texcrd.y, texcrd.y, yv12_coef.y;\n");
     else
         shader_addline(buffer, "MAD texcrd.y, size.y, coef.w, texcrd.y;\n");
@@ -7143,7 +7147,7 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
      * values due to filtering
      */
     shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
-    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
+    if (type->textype == WINED3D_FFP_TEXTURE_TYPE_2D)
     {
         /* Multiply the y coordinate by 2/3 and clamp it */
         shader_addline(buffer, "MUL texcrd.y, texcrd.y, yv12_coef.x;\n");
@@ -7166,14 +7170,14 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
     return TRUE;
 }
 
-static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp_texture_type textype,
+static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, const struct arbfp_blit_type *type,
         char *luminance)
 {
     const char *tex;
     static const float nv12_coef[]
             = {2.0f / 3.0f, 1.0f / 3.0f, 1.0f, 1.0f};
 
-    switch (textype)
+    switch (type->textype)
     {
         case WINED3D_FFP_TEXTURE_TYPE_2D:
             tex = "2D";
@@ -7224,7 +7228,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
     /* We only have half the number of chroma pixels. */
     shader_addline(buffer, "MUL texcrd.x, texcrd.x, coef.y;\n");
 
-    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
+    if (type->textype == WINED3D_FFP_TEXTURE_TYPE_2D)
     {
         shader_addline(buffer, "RCP chroma.w, size.x;\n");
         shader_addline(buffer, "RCP chroma.z, size.y;\n");
@@ -7273,7 +7277,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
     shader_addline(buffer, "TEX temp, texcrd, texture[0], %s;\n", tex);
     shader_addline(buffer, "MOV chroma.y, temp.w;\n");
 
-    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
+    if (type->textype == WINED3D_FFP_TEXTURE_TYPE_2D)
     {
         /* Add 1/size.x */
         shader_addline(buffer, "ADD texcrd.x, texcrd.x, chroma.w;\n");
@@ -7290,7 +7294,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
      * Clamp the y coordinate to prevent the chroma values from bleeding into the sampled luminance
      * values due to filtering. */
     shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
-    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
+    if (type->textype == WINED3D_FFP_TEXTURE_TYPE_2D)
     {
         /* Multiply the y coordinate by 2/3 and clamp it */
         shader_addline(buffer, "MUL texcrd.y, texcrd.y, nv12_coef.x;\n");
@@ -7315,7 +7319,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp
 
 /* Context activation is done by the caller. */
 static GLuint gen_p8_shader(struct arbfp_blit_priv *priv,
-        const struct wined3d_gl_info *gl_info, enum wined3d_ffp_texture_type textype)
+        const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
 {
     GLenum shader;
     struct wined3d_shader_buffer buffer;
@@ -7343,7 +7347,7 @@ static GLuint gen_p8_shader(struct arbfp_blit_priv *priv,
     shader_addline(&buffer, "PARAM constants = { 0.996, 0.00195, 0, 0 };\n");
 
     /* The alpha-component contains the palette index */
-    if (textype == WINED3D_FFP_TEXTURE_TYPE_RECT)
+    if (type->textype == WINED3D_FFP_TEXTURE_TYPE_RECT)
         shader_addline(&buffer, "TEX index, fragment.texcoord[0], texture[0], RECT;\n");
     else
         shader_addline(&buffer, "TEX index, fragment.texcoord[0], texture[0], 2D;\n");
@@ -7412,7 +7416,7 @@ static void upload_palette(const struct wined3d_texture *texture, struct wined3d
 
 /* Context activation is done by the caller. */
 static GLuint gen_yuv_shader(struct arbfp_blit_priv *priv, const struct wined3d_gl_info *gl_info,
-        enum complex_fixup yuv_fixup, enum wined3d_ffp_texture_type textype)
+        const struct arbfp_blit_type *type)
 {
     GLenum shader;
     struct wined3d_shader_buffer buffer;
@@ -7481,11 +7485,11 @@ static GLuint gen_yuv_shader(struct arbfp_blit_priv *priv, const struct wined3d_
     shader_addline(&buffer, "PARAM yuv_coef = {1.403, 0.344, 0.714, 1.770};\n");
     shader_addline(&buffer, "PARAM size = program.local[0];\n");
 
-    switch (yuv_fixup)
+    switch (type->fixup)
     {
         case COMPLEX_FIXUP_UYVY:
         case COMPLEX_FIXUP_YUY2:
-            if (!gen_planar_yuv_read(&buffer, yuv_fixup, textype, &luminance_component))
+            if (!gen_planar_yuv_read(&buffer, type, &luminance_component))
             {
                 shader_buffer_free(&buffer);
                 return 0;
@@ -7493,7 +7497,7 @@ static GLuint gen_yuv_shader(struct arbfp_blit_priv *priv, const struct wined3d_
             break;
 
         case COMPLEX_FIXUP_YV12:
-            if (!gen_yv12_read(&buffer, textype, &luminance_component))
+            if (!gen_yv12_read(&buffer, type, &luminance_component))
             {
                 shader_buffer_free(&buffer);
                 return 0;
@@ -7501,7 +7505,7 @@ static GLuint gen_yuv_shader(struct arbfp_blit_priv *priv, const struct wined3d_
             break;
 
         case COMPLEX_FIXUP_NV12:
-            if (!gen_nv12_read(&buffer, textype, &luminance_component))
+            if (!gen_nv12_read(&buffer, type, &luminance_component))
             {
                 shader_buffer_free(&buffer);
                 return 0;
@@ -7509,7 +7513,7 @@ static GLuint gen_yuv_shader(struct arbfp_blit_priv *priv, const struct wined3d_
             break;
 
         default:
-            FIXME("Unsupported YUV fixup %#x\n", yuv_fixup);
+            FIXME("Unsupported YUV fixup %#x\n", type->fixup);
             shader_buffer_free(&buffer);
             return 0;
     }
@@ -7623,11 +7627,11 @@ static HRESULT arbfp_blit_set(void *blit_priv, struct wined3d_context *context,
         switch (fixup)
         {
             case COMPLEX_FIXUP_P8:
-                shader = gen_p8_shader(priv, gl_info, type.textype);
+                shader = gen_p8_shader(priv, gl_info, &type);
                 break;
 
             default:
-                shader = gen_yuv_shader(priv, gl_info, fixup, type.textype);
+                shader = gen_yuv_shader(priv, gl_info, &type);
                 break;
         }
 
-- 
2.3.4




More information about the wine-patches mailing list