[PATCH 2/5] wined3d: Pass a wined3d_ffp_texture_type enum to blit shader functions.

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


---
 dlls/wined3d/arb_program_shader.c | 108 ++++++++++++++++++++++++++++----------
 1 file changed, 80 insertions(+), 28 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 1353023..7e206a1 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -6908,7 +6908,7 @@ static void arbfp_blit_free(struct wined3d_device *device)
 }
 
 static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum complex_fixup fixup,
-        GLenum textype, char *luminance)
+        enum wined3d_ffp_texture_type textype, char *luminance)
 {
     char chroma;
     const char *tex, *texinstr;
@@ -6920,9 +6920,19 @@ static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum compl
         chroma = 'w';
         *luminance = 'x';
     }
-    switch(textype) {
-        case GL_TEXTURE_2D:             tex = "2D";     texinstr = "TXP"; break;
-        case GL_TEXTURE_RECTANGLE_ARB:  tex = "RECT";   texinstr = "TEX"; break;
+
+    switch(textype)
+    {
+        case WINED3D_FFP_TEXTURE_TYPE_2D:
+            tex = "2D";
+            texinstr = "TXP";
+            break;
+
+        case WINED3D_FFP_TEXTURE_TYPE_RECT:
+            tex = "RECT";
+            texinstr = "TEX";
+            break;
+
         default:
             /* This is more tricky than just replacing the texture type - we have to navigate
              * properly in the texture to find the correct chroma values
@@ -6943,10 +6953,13 @@ 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 != GL_TEXTURE_RECTANGLE_ARB) {
+    if (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");
-    } else {
+    }
+    else
+    {
         shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
     }
     /* We must not allow filtering between pixel x and x+1, this would mix U and V
@@ -6995,15 +7008,22 @@ 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, GLenum textype, char *luminance)
+static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp_texture_type textype, 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) {
-        case GL_TEXTURE_2D:             tex = "2D";     break;
-        case GL_TEXTURE_RECTANGLE_ARB:  tex = "RECT";   break;
+    switch (textype)
+    {
+        case WINED3D_FFP_TEXTURE_TYPE_2D:
+            tex = "2D";
+            break;
+
+        case WINED3D_FFP_TEXTURE_TYPE_RECT:
+            tex = "RECT";
+            break;
+
         default:
             FIXME("Implement yv12 correction for non-2d, non-rect textures\n");
             return FALSE;
@@ -7061,7 +7081,8 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
      * Don't forget to clamp the y values in into the range, otherwise we'll get filtering
      * bleeding
      */
-    if(textype == GL_TEXTURE_2D) {
+    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
+    {
 
         shader_addline(buffer, "RCP chroma.w, size.y;\n");
 
@@ -7081,7 +7102,9 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
         shader_addline(buffer, "MAX texcrd.y, temp.y, texcrd.y;\n");
         shader_addline(buffer, "MAD temp.y, -coef.y, chroma.w, yv12_coef.z;\n");
         shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
-    } else {
+    }
+    else
+    {
         /* Read from [size - size+size/4] */
         shader_addline(buffer, "FLR texcrd.y, texcrd.y;\n");
         shader_addline(buffer, "MAD texcrd.y, texcrd.y, coef.w, size.y;\n");
@@ -7111,11 +7134,10 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
     /* 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 == GL_TEXTURE_2D) {
+    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
         shader_addline(buffer, "ADD texcrd.y, texcrd.y, yv12_coef.y;\n");
-    } else {
+    else
         shader_addline(buffer, "MAD texcrd.y, size.y, coef.w, texcrd.y;\n");
-    }
     shader_addline(buffer, "TEX temp, texcrd, texture[0], %s;\n", tex);
     shader_addline(buffer, "MOV chroma.y, temp.w;\n");
 
@@ -7124,13 +7146,16 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
      * values due to filtering
      */
     shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
-    if(textype == GL_TEXTURE_2D) {
+    if (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");
         shader_addline(buffer, "MAD temp.y, -coef.y, chroma.w, yv12_coef.x;\n");
         shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
         shader_addline(buffer, "TEX luminance, texcrd, texture[0], %s;\n", tex);
-    } else {
+    }
+    else
+    {
         /* Reading from texture_rectangles is pretty straightforward, just use the unmodified
          * texture coordinate. It is still a good idea to clamp it though, since the opengl texture
          * is bigger
@@ -7144,7 +7169,7 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
     return TRUE;
 }
 
-static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
+static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, enum wined3d_ffp_texture_type textype,
         char *luminance)
 {
     const char *tex;
@@ -7153,10 +7178,10 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
 
     switch (textype)
     {
-        case GL_TEXTURE_2D:
+        case WINED3D_FFP_TEXTURE_TYPE_2D:
             tex = "2D";
             break;
-        case GL_TEXTURE_RECTANGLE_ARB:
+        case WINED3D_FFP_TEXTURE_TYPE_RECT:
             tex = "RECT";
             break;
         default:
@@ -7202,7 +7227,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
     /* We only have half the number of chroma pixels. */
     shader_addline(buffer, "MUL texcrd.x, texcrd.x, coef.y;\n");
 
-    if (textype == GL_TEXTURE_2D)
+    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
     {
         shader_addline(buffer, "RCP chroma.w, size.x;\n");
         shader_addline(buffer, "RCP chroma.z, size.y;\n");
@@ -7251,7 +7276,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
     shader_addline(buffer, "TEX temp, texcrd, texture[0], %s;\n", tex);
     shader_addline(buffer, "MOV chroma.y, temp.w;\n");
 
-    if (textype == GL_TEXTURE_2D)
+    if (textype == WINED3D_FFP_TEXTURE_TYPE_2D)
     {
         /* Add 1/size.x */
         shader_addline(buffer, "ADD texcrd.x, texcrd.x, chroma.w;\n");
@@ -7268,7 +7293,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
      * 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 == GL_TEXTURE_2D)
+    if (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");
@@ -7293,7 +7318,7 @@ static BOOL gen_nv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
 
 /* Context activation is done by the caller. */
 static GLuint gen_p8_shader(struct arbfp_blit_priv *priv,
-        const struct wined3d_gl_info *gl_info, GLenum textype)
+        const struct wined3d_gl_info *gl_info, enum wined3d_ffp_texture_type textype)
 {
     GLenum shader;
     struct wined3d_shader_buffer buffer;
@@ -7321,7 +7346,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 == GL_TEXTURE_RECTANGLE_ARB)
+    if (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");
@@ -7390,7 +7415,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, GLenum textype)
+        enum complex_fixup yuv_fixup, enum wined3d_ffp_texture_type textype)
 {
     GLenum shader;
     struct wined3d_shader_buffer buffer;
@@ -7541,6 +7566,7 @@ static HRESULT arbfp_blit_set(void *blit_priv, struct wined3d_context *context,
     struct wine_rb_entry *entry;
     struct arbfp_blit_type type;
     struct arbfp_blit_desc *desc;
+    enum wined3d_ffp_texture_type wined3d_tex_type;
 
     if (surface->container->flags & WINED3D_TEXTURE_CONVERTED)
     {
@@ -7561,6 +7587,32 @@ static HRESULT arbfp_blit_set(void *blit_priv, struct wined3d_context *context,
 
     fixup = get_complex_fixup(surface->resource.format->color_fixup);
 
+    switch (textype)
+    {
+        case GL_TEXTURE_1D:
+            wined3d_tex_type = WINED3D_FFP_TEXTURE_TYPE_1D;
+            break;
+
+        case GL_TEXTURE_2D:
+            wined3d_tex_type = WINED3D_FFP_TEXTURE_TYPE_2D;
+            break;
+
+        case GL_TEXTURE_3D:
+            wined3d_tex_type = WINED3D_FFP_TEXTURE_TYPE_3D;
+            break;
+
+        case GL_TEXTURE_CUBE_MAP_ARB:
+            wined3d_tex_type = WINED3D_FFP_TEXTURE_TYPE_CUBE;
+            break;
+
+        case GL_TEXTURE_RECTANGLE_ARB:
+            wined3d_tex_type = WINED3D_FFP_TEXTURE_TYPE_RECT;
+            break;
+
+        default:
+            ERR("Unexpected GL texture type %x.\n", textype);
+            wined3d_tex_type = WINED3D_FFP_TEXTURE_TYPE_2D;
+    }
     type.fixup = fixup;
     type.textype = textype;
     entry = wine_rb_get(&priv->shaders, &type);
@@ -7574,11 +7626,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, textype);
+                shader = gen_p8_shader(priv, gl_info, wined3d_tex_type);
                 break;
 
             default:
-                shader = gen_yuv_shader(priv, gl_info, fixup, textype);
+                shader = gen_yuv_shader(priv, gl_info, fixup, wined3d_tex_type);
                 break;
         }
 
-- 
2.3.4




More information about the wine-patches mailing list