Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/wined3d/context.c | 6 ++++-- dlls/wined3d/device.c | 4 +++- dlls/wined3d/directx.c | 14 ++++++++++++++ dlls/wined3d/resource.c | 1 + dlls/wined3d/utils.c | 1 + include/wine/wined3d.h | 5 +++-- 6 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 2e12d75213..53f177980d 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -392,10 +392,11 @@ static inline void context_set_fbo_key_for_render_target(const struct wined3d_co struct wined3d_resource *resource = render_target->resource; struct wined3d_texture *texture;
+ if (resource && (resource->type == WINED3D_RTYPE_BUFFER || resource->type == WINED3D_RTYPE_TEXTURE_1D)) + FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); + if (!resource || resource->format->id == WINED3DFMT_NULL || resource->type == WINED3D_RTYPE_BUFFER) { - if (resource && resource->type == WINED3D_RTYPE_BUFFER) - FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); key->objects[idx].object = 0; key->objects[idx].target = 0; key->objects[idx].level = key->objects[idx].layer = 0; @@ -1017,6 +1018,7 @@ void context_resource_released(const struct wined3d_device *device,
switch (type) { + case WINED3D_RTYPE_TEXTURE_1D: case WINED3D_RTYPE_TEXTURE_2D: case WINED3D_RTYPE_TEXTURE_3D: texture = texture_from_resource(resource); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index a25b98d749..2b7d515af4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4239,7 +4239,8 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str height = 1; depth = 1; } - else if (resource->type == WINED3D_RTYPE_TEXTURE_2D || resource->type == WINED3D_RTYPE_TEXTURE_3D) + else if (resource->type == WINED3D_RTYPE_TEXTURE_1D || resource->type == WINED3D_RTYPE_TEXTURE_2D + || resource->type == WINED3D_RTYPE_TEXTURE_3D) { struct wined3d_texture *texture = texture_from_resource(resource); unsigned int level; @@ -5003,6 +5004,7 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
switch (type) { + case WINED3D_RTYPE_TEXTURE_1D: case WINED3D_RTYPE_TEXTURE_2D: case WINED3D_RTYPE_TEXTURE_3D: for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 1586bdc821..abab0b1024 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -5300,6 +5300,20 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D; break;
+ case WINED3D_RTYPE_TEXTURE_1D: + allowed_usage = WINED3DUSAGE_AUTOGENMIPMAP + | WINED3DUSAGE_DYNAMIC + | WINED3DUSAGE_SOFTWAREPROCESSING + | WINED3DUSAGE_TEXTURE + | WINED3DUSAGE_QUERY_FILTER + | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING + | WINED3DUSAGE_QUERY_SRGBREAD + | WINED3DUSAGE_QUERY_SRGBWRITE + | WINED3DUSAGE_QUERY_VERTEXTEXTURE + | WINED3DUSAGE_QUERY_WRAPANDMIP; + gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_1D; + break; + case WINED3D_RTYPE_TEXTURE_2D: allowed_usage = WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_RENDERTARGET diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 40890cc99e..6260abb2f4 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -95,6 +95,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * resource_types[] = { {WINED3D_RTYPE_BUFFER, 0, WINED3D_GL_RES_TYPE_BUFFER}, + {WINED3D_RTYPE_TEXTURE_1D, 0, WINED3D_GL_RES_TYPE_TEX_1D}, {WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_2D}, {WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_RECT}, {WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_RB}, diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index b3003f1302..daf7e7cba6 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4217,6 +4217,7 @@ const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) #define WINED3D_TO_STR(x) case x: return #x WINED3D_TO_STR(WINED3D_RTYPE_NONE); WINED3D_TO_STR(WINED3D_RTYPE_BUFFER); + WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_1D); WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_2D); WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_3D); #undef WINED3D_TO_STR diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index a519e94bb3..af89a7465f 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -672,8 +672,9 @@ enum wined3d_resource_type { WINED3D_RTYPE_NONE = 0, WINED3D_RTYPE_BUFFER = 1, - WINED3D_RTYPE_TEXTURE_2D = 2, - WINED3D_RTYPE_TEXTURE_3D = 3, + WINED3D_RTYPE_TEXTURE_1D = 2, + WINED3D_RTYPE_TEXTURE_2D = 3, + WINED3D_RTYPE_TEXTURE_3D = 4, };
enum wined3d_pool
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/wined3d/view.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index a8e025965d..6138cc076b 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -46,6 +46,10 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info, { {GL_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_CUBE_MAP}, {GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_RECTANGLE}, + {GL_TEXTURE_1D, 0, GL_TEXTURE_1D}, + {GL_TEXTURE_1D, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_1D_ARRAY}, + {GL_TEXTURE_1D_ARRAY, 0, GL_TEXTURE_1D}, + {GL_TEXTURE_1D_ARRAY, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_1D_ARRAY}, {GL_TEXTURE_2D, 0, GL_TEXTURE_2D}, {GL_TEXTURE_2D, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_ARRAY}, {GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_2D},
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/wined3d/context.c | 21 ++++++++++++++++++++- dlls/wined3d/device.c | 26 ++++++++++++++++++++++++++ dlls/wined3d/glsl_shader.c | 7 +++++++ dlls/wined3d/utils.c | 28 ++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 5 files changed, 83 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 53f177980d..e654f24d60 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -139,7 +139,8 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context, gl_info->fbo_ops.glFramebufferTexture(fbo_target, attachment, resource->object, resource->level); } - else if (resource->target == GL_TEXTURE_2D_ARRAY || resource->target == GL_TEXTURE_3D) + else if (resource->target == GL_TEXTURE_1D_ARRAY || resource->target == GL_TEXTURE_2D_ARRAY + || resource->target == GL_TEXTURE_3D) { if (!gl_info->fbo_ops.glFramebufferTextureLayer) { @@ -150,6 +151,12 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context, gl_info->fbo_ops.glFramebufferTextureLayer(fbo_target, attachment, resource->object, resource->level, resource->layer); } + else if (resource->target == GL_TEXTURE_1D) + { + gl_info->fbo_ops.glFramebufferTexture1D(fbo_target, attachment, + resource->target, resource->object, resource->level); + checkGLcall("glFramebufferTexture1D()"); + } else { gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment, @@ -1709,6 +1716,7 @@ void context_bind_dummy_textures(const struct wined3d_device *device, const stru GL_EXTCALL(glActiveTexture(GL_TEXTURE0 + i)); checkGLcall("glActiveTexture");
+ gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d); gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, device->dummy_textures.tex_2d);
if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) @@ -1724,7 +1732,10 @@ void context_bind_dummy_textures(const struct wined3d_device *device, const stru gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, device->dummy_textures.tex_cube_array);
if (gl_info->supported[EXT_TEXTURE_ARRAY]) + { + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array); gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, device->dummy_textures.tex_2d_array); + }
if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_textures.tex_buffer); @@ -2705,6 +2716,14 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint case GL_NONE: /* nothing to do */ break; + case GL_TEXTURE_1D: + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d); + checkGLcall("glBindTexture"); + break; + case GL_TEXTURE_1D_ARRAY: + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array); + checkGLcall("glBindTexture"); + break; case GL_TEXTURE_2D: gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, device->dummy_textures.tex_2d); checkGLcall("glBindTexture"); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 2b7d515af4..c26fe4f4f2 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -620,6 +620,17 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_ * to each texture stage when the currently set D3D texture is NULL. */ context_active_texture(context, gl_info, 0);
+ gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_1d); + checkGLcall("glGenTextures"); + TRACE("Dummy 1D texture given name %u.\n", device->dummy_textures.tex_1d); + + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d); + checkGLcall("glBindTexture"); + + gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, 1, 0, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color); + checkGLcall("glTexImage1D"); + gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d); checkGLcall("glGenTextures"); TRACE("Dummy 2D texture given name %u.\n", device->dummy_textures.tex_2d); @@ -696,6 +707,17 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
if (gl_info->supported[EXT_TEXTURE_ARRAY]) { + gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_1d_array); + checkGLcall("glGenTextures"); + TRACE("Dummy 1D array texture given name %u.\n", device->dummy_textures.tex_1d_array); + + gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array); + checkGLcall("glBindTexture"); + + gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_1D_ARRAY, 0, GL_RGBA8, 1, 1, 0, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color); + checkGLcall("glTexImage2D"); + gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d_array); checkGLcall("glGenTextures"); TRACE("Dummy 2D array texture given name %u.\n", device->dummy_textures.tex_2d_array); @@ -743,7 +765,10 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_buffer);
if (gl_info->supported[EXT_TEXTURE_ARRAY]) + { + gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d_array); gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d_array); + }
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP_ARRAY]) gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_cube_array); @@ -757,6 +782,7 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_rect);
+ gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d); gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d);
checkGLcall("Delete dummy textures"); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index e18a99f066..9c5f6ef77c 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2577,6 +2577,13 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont sampler_type = "samplerCube"; break;
+ case WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY: + if (shadow_sampler) + sampler_type = "sampler1DArrayShadow"; + else + sampler_type = "sampler1DArray"; + break; + case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY: if (shadow_sampler) sampler_type = "sampler2DArrayShadow"; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index daf7e7cba6..13a60f9e97 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5705,7 +5705,27 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st { switch (texture->target) { + case GL_TEXTURE_1D: + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable(GL_TEXTURE_2D)"); + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); + checkGLcall("glDisable(GL_TEXTURE_3D)"); + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + } + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } + gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_1D); + checkGLcall("glEnable(GL_TEXTURE_1D)"); + break; case GL_TEXTURE_2D: + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D); + checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) @@ -5722,6 +5742,8 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st checkGLcall("glEnable(GL_TEXTURE_2D)"); break; case GL_TEXTURE_RECTANGLE_ARB: + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D); + checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); @@ -5745,12 +5767,16 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D); + checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_3D); checkGLcall("glEnable(GL_TEXTURE_3D)"); break; case GL_TEXTURE_CUBE_MAP_ARB: + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D); + checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); @@ -5767,6 +5793,8 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st } else { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D); + checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D); checkGLcall("glEnable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 20f53aa9e9..e7c4b2742d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2919,11 +2919,13 @@ struct wined3d_device /* Textures for when no other textures are mapped */ struct { + GLuint tex_1d; GLuint tex_2d; GLuint tex_rect; GLuint tex_3d; GLuint tex_cube; GLuint tex_cube_array; + GLuint tex_1d_array; GLuint tex_2d_array; GLuint tex_buffer; } dummy_textures;
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse shesse@codeweavers.com wrote:
@@ -5705,7 +5705,27 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st { switch (texture->target) {
case GL_TEXTURE_1D:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable(GL_TEXTURE_2D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable(GL_TEXTURE_3D)");
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
}
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
}
gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_1D);
checkGLcall("glEnable(GL_TEXTURE_1D)");
break; case GL_TEXTURE_2D:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
@@ -5722,6 +5742,8 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st checkGLcall("glEnable(GL_TEXTURE_2D)"); break; case GL_TEXTURE_RECTANGLE_ARB:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
@@ -5745,12 +5767,16 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); }
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_3D); checkGLcall("glEnable(GL_TEXTURE_3D)"); break; case GL_TEXTURE_CUBE_MAP_ARB:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
@@ -5767,6 +5793,8 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st } else {
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)"); gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D); checkGLcall("glEnable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
Textures need to be enabled only for fixed-function pipeline. We do not want to use 1D textures with fixed-function pipeline.
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/wined3d/texture.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index ddbe340dc8..03871d7158 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1623,6 +1623,41 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s context, box, data, row_pitch, slice_pitch); }
+/* This call just uploads data, the caller is responsible for binding the + * correct texture. */ +/* Context activation is done by the caller. */ +static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, + const struct wined3d_context *context, const struct wined3d_box *box, + const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch) +{ + FIXME("Not implemented.\n"); +} + +/* Context activation is done by the caller. */ +static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_context *context, DWORD location) +{ + FIXME("Not implemented.\n"); + return FALSE; +} + +static void texture1d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) +{ + FIXME("Not implemented.\n"); +} + +static void texture1d_cleanup_sub_resources(struct wined3d_texture *texture) +{ +} + +static const struct wined3d_texture_ops texture1d_ops = +{ + texture1d_upload_data, + texture1d_load_location, + texture1d_prepare_texture, + texture1d_cleanup_sub_resources, +}; + static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch) @@ -2036,6 +2071,123 @@ static const struct wined3d_resource_ops texture_resource_ops = texture_resource_sub_resource_unmap, };
+static HRESULT texture1d_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, + unsigned int layer_count, unsigned int level_count, DWORD flags, struct wined3d_device *device, + void *parent, const struct wined3d_parent_ops *parent_ops) +{ + struct wined3d_device_parent *device_parent = device->device_parent; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; + struct wined3d_surface *surfaces; + unsigned int i, j; + HRESULT hr; + + if (layer_count > 1 && !gl_info->supported[EXT_TEXTURE_ARRAY]) + { + WARN("OpenGL implementation does not support array textures.\n"); + return WINED3DERR_INVALIDCALL; + } + + /* TODO: It should only be possible to create textures for formats + * that are reported as supported. */ + if (WINED3DFMT_UNKNOWN >= desc->format) + { + WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture); + return WINED3DERR_INVALIDCALL; + } + + if (desc->usage & WINED3DUSAGE_DYNAMIC && desc->pool == WINED3D_POOL_MANAGED) + FIXME("Trying to create a managed texture with dynamic usage.\n"); + + if ((desc->width & (desc->width - 1)) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]) + { + WARN("Attempted to create a NPOT 1D texture (%u) without GL support.\n", desc->width); + return WINED3DERR_INVALIDCALL; + } + + if (desc->width > gl_info->limits.texture_size && (desc->usage & WINED3DUSAGE_TEXTURE)) + { + WARN("Dimensions (%ux) exceed the maximum texture size.\n", desc->width); + return WINED3DERR_NOTAVAILABLE; + } + + /* Calculate levels for mip mapping. */ + if (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP) + { + if (!gl_info->supported[SGIS_GENERATE_MIPMAP]) + { + WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n"); + return WINED3DERR_INVALIDCALL; + } + + if (level_count != 1) + { + WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning D3DERR_INVALIDCALL.\n"); + return WINED3DERR_INVALIDCALL; + } + } + + if (FAILED(hr = wined3d_texture_init(texture, &texture1d_ops, layer_count, level_count, desc, + flags, device, parent, parent_ops, &texture_resource_ops))) + { + WARN("Failed to initialize texture, returning %#x.\n", hr); + return hr; + } + + texture->pow2_matrix[0] = 1.0f; + texture->pow2_matrix[5] = 1.0f; + texture->pow2_matrix[10] = 1.0f; + texture->pow2_matrix[15] = 1.0f; + texture->target = (layer_count > 1) ? GL_TEXTURE_1D_ARRAY : GL_TEXTURE_1D; + + if (wined3d_texture_use_pbo(texture, gl_info)) + texture->resource.map_binding = WINED3D_LOCATION_BUFFER; + + if (level_count > ~(SIZE_T)0 / layer_count + || !(surfaces = wined3d_calloc(level_count * layer_count, sizeof(*surfaces)))) + { + wined3d_texture_cleanup_sync(texture); + return E_OUTOFMEMORY; + } + + /* Generate all the surfaces. */ + for (i = 0; i < texture->level_count; ++i) + { + for (j = 0; j < texture->layer_count; ++j) + { + struct wined3d_texture_sub_resource *sub_resource; + unsigned int idx = j * texture->level_count + i; + struct wined3d_surface *surface; + + surface = &surfaces[idx]; + surface->container = texture; + surface->texture_target = texture->target; + surface->texture_level = i; + surface->texture_layer = j; + list_init(&surface->renderbuffers); + list_init(&surface->overlays); + + sub_resource = &texture->sub_resources[idx]; + sub_resource->locations = WINED3D_LOCATION_DISCARDED; + sub_resource->u.surface = surface; + + if (FAILED(hr = device_parent->ops->surface_created(device_parent, + texture, idx, &sub_resource->parent, &sub_resource->parent_ops))) + { + WARN("Failed to create surface parent, hr %#x.\n", hr); + sub_resource->parent = NULL; + wined3d_texture_cleanup_sync(texture); + return hr; + } + + TRACE("parent %p, parent_ops %p.\n", sub_resource->parent, sub_resource->parent_ops); + + TRACE("Created surface level %u, layer %u @ %p.\n", i, j, surface); + } + } + + return WINED3D_OK; +} + static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops) @@ -2965,6 +3117,10 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
switch (desc->resource_type) { + case WINED3D_RTYPE_TEXTURE_1D: + hr = texture1d_init(object, desc, layer_count, level_count, flags, device, parent, parent_ops); + break; + case WINED3D_RTYPE_TEXTURE_2D: hr = texture_init(object, desc, layer_count, level_count, flags, device, parent, parent_ops); break;
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse shesse@codeweavers.com wrote:
@@ -2036,6 +2071,123 @@ static const struct wined3d_resource_ops texture_resource_ops = texture_resource_sub_resource_unmap, };
+static HRESULT texture1d_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
unsigned int layer_count, unsigned int level_count, DWORD flags, struct wined3d_device *device,
void *parent, const struct wined3d_parent_ops *parent_ops)
+{
- struct wined3d_device_parent *device_parent = device->device_parent;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
- struct wined3d_surface *surfaces;
- unsigned int i, j;
- HRESULT hr;
- if (layer_count > 1 && !gl_info->supported[EXT_TEXTURE_ARRAY])
- {
WARN("OpenGL implementation does not support array textures.\n");
return WINED3DERR_INVALIDCALL;
- }
- /* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
- if (WINED3DFMT_UNKNOWN >= desc->format)
- {
WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
return WINED3DERR_INVALIDCALL;
- }
- if (desc->usage & WINED3DUSAGE_DYNAMIC && desc->pool == WINED3D_POOL_MANAGED)
FIXME("Trying to create a managed texture with dynamic usage.\n");
- if ((desc->width & (desc->width - 1)) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
- {
WARN("Attempted to create a NPOT 1D texture (%u) without GL support.\n", desc->width);
return WINED3DERR_INVALIDCALL;
- }
- if (desc->width > gl_info->limits.texture_size && (desc->usage & WINED3DUSAGE_TEXTURE))
- {
WARN("Dimensions (%ux) exceed the maximum texture size.\n", desc->width);
return WINED3DERR_NOTAVAILABLE;
- }
- /* Calculate levels for mip mapping. */
- if (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP)
- {
if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
{
WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (level_count != 1)
{
WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
- }
- if (FAILED(hr = wined3d_texture_init(texture, &texture1d_ops, layer_count, level_count, desc,
flags, device, parent, parent_ops, &texture_resource_ops)))
- {
WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr;
- }
- texture->pow2_matrix[0] = 1.0f;
- texture->pow2_matrix[5] = 1.0f;
- texture->pow2_matrix[10] = 1.0f;
- texture->pow2_matrix[15] = 1.0f;
- texture->target = (layer_count > 1) ? GL_TEXTURE_1D_ARRAY : GL_TEXTURE_1D;
- if (wined3d_texture_use_pbo(texture, gl_info))
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
- if (level_count > ~(SIZE_T)0 / layer_count
|| !(surfaces = wined3d_calloc(level_count * layer_count, sizeof(*surfaces))))
- {
wined3d_texture_cleanup_sync(texture);
return E_OUTOFMEMORY;
- }
- /* Generate all the surfaces. */
- for (i = 0; i < texture->level_count; ++i)
- {
for (j = 0; j < texture->layer_count; ++j)
{
struct wined3d_texture_sub_resource *sub_resource;
unsigned int idx = j * texture->level_count + i;
struct wined3d_surface *surface;
surface = &surfaces[idx];
surface->container = texture;
surface->texture_target = texture->target;
surface->texture_level = i;
surface->texture_layer = j;
list_init(&surface->renderbuffers);
list_init(&surface->overlays);
sub_resource = &texture->sub_resources[idx];
sub_resource->locations = WINED3D_LOCATION_DISCARDED;
sub_resource->u.surface = surface;
if (FAILED(hr = device_parent->ops->surface_created(device_parent,
texture, idx, &sub_resource->parent, &sub_resource->parent_ops)))
{
WARN("Failed to create surface parent, hr %#x.\n", hr);
sub_resource->parent = NULL;
wined3d_texture_cleanup_sync(texture);
return hr;
}
TRACE("parent %p, parent_ops %p.\n", sub_resource->parent, sub_resource->parent_ops);
TRACE("Created surface level %u, layer %u @ %p.\n", i, j, surface);
}
- }
- return WINED3D_OK;
+}
This duplicates quite a lot of code. Did you consider integrating 1D textures with 2D textures more closely?
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/wined3d/texture.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 03871d7158..ac441fe677 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1643,7 +1643,30 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in
static void texture1d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) { - FIXME("Not implemented.\n"); + const struct wined3d_format *format = texture->resource.format; + GLenum internal = srgb ? format->glGammaInternal : format->glInternal; + unsigned int sub_count = texture->level_count * texture->layer_count; + const struct wined3d_gl_info *gl_info = context->gl_info; + unsigned int i; + + wined3d_texture_bind_and_dirtify(texture, context, srgb); + + if (wined3d_texture_use_immutable_storage(texture, gl_info)) + { + GL_EXTCALL(glTexStorage1D(GL_TEXTURE_1D, texture->level_count, internal, + wined3d_texture_get_level_width(texture, 0))); + checkGLcall("glTexStorage1D"); + } + else + { + for (i = 0; i < sub_count; ++i) + { + gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, i, internal, + wined3d_texture_get_level_width(texture, i), + 0, format->glFormat, format->glType, NULL); + checkGLcall("glTexImage1D"); + } + } }
static void texture1d_cleanup_sub_resources(struct wined3d_texture *texture)
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse shesse@codeweavers.com wrote:
Signed-off-by: Sven Hesse shesse@codeweavers.com
dlls/wined3d/texture.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 03871d7158..ac441fe677 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1643,7 +1643,30 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in
static void texture1d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) {
- FIXME("Not implemented.\n");
- const struct wined3d_format *format = texture->resource.format;
- GLenum internal = srgb ? format->glGammaInternal : format->glInternal;
- unsigned int sub_count = texture->level_count * texture->layer_count;
- const struct wined3d_gl_info *gl_info = context->gl_info;
- unsigned int i;
- wined3d_texture_bind_and_dirtify(texture, context, srgb);
- if (wined3d_texture_use_immutable_storage(texture, gl_info))
- {
GL_EXTCALL(glTexStorage1D(GL_TEXTURE_1D, texture->level_count, internal,
wined3d_texture_get_level_width(texture, 0)));
checkGLcall("glTexStorage1D");
- }
- else
- {
for (i = 0; i < sub_count; ++i)
{
gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, i, internal,
wined3d_texture_get_level_width(texture, i),
0, format->glFormat, format->glType, NULL);
checkGLcall("glTexImage1D");
}
- }
}
We need to handle 1D array textures in texture1d_prepare_texture().
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/wined3d/texture.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index ac441fe677..ffd6e88f30 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1630,7 +1630,68 @@ static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch) { - FIXME("Not implemented.\n"); + const struct wined3d_format *format = texture->resource.format; + unsigned int level = sub_resource_idx % texture->level_count; + const struct wined3d_gl_info *gl_info = context->gl_info; + unsigned int x, update_w; + unsigned int dst_row_pitch, dst_slice_pitch; + unsigned int width; + const void *mem = data->addr; + void *converted_mem = NULL; + + TRACE("texture %p, sub_resource_idx %u, context %p, box %s, data {%#x:%p}, row_pitch %#x, slice_pitch %#x.\n", + texture, sub_resource_idx, context, debug_box(box), + data->buffer_object, data->addr, row_pitch, slice_pitch); + + width = wined3d_texture_get_level_width(texture, level); + + if (!box) + { + x = 0; + update_w = width; + } + else + { + x = box->left; + update_w = box->right - box->left; + } + + if (format->convert) + { + if (data->buffer_object) + ERR("Loading a converted texture from a PBO.\n"); + if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS) + ERR("Converting a block-based format.\n"); + + dst_row_pitch = update_w * format->conv_byte_count; + + converted_mem = wined3d_calloc(1, dst_row_pitch); + format->convert(data->addr, converted_mem, row_pitch, slice_pitch, dst_row_pitch, dst_row_pitch, update_w, 1, 1); + mem = converted_mem; + } + else + { + wined3d_texture_get_pitch(texture, sub_resource_idx, &dst_row_pitch, &dst_slice_pitch); + if (row_pitch != dst_row_pitch || slice_pitch != dst_slice_pitch) + FIXME("Ignoring row/slice pitch (%u/%u).\n", row_pitch, slice_pitch); + } + + if (data->buffer_object) + { + GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, data->buffer_object)); + checkGLcall("glBindBuffer"); + } + + gl_info->gl_ops.gl.p_glTexSubImage1D(GL_TEXTURE_1D, level, x, update_w, format->glFormat, format->glType, mem); + checkGLcall("glTexSubImage1D"); + + if (data->buffer_object) + { + GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); + checkGLcall("glBindBuffer"); + } + + HeapFree(GetProcessHeap(), 0, converted_mem); }
/* Context activation is done by the caller. */
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/wined3d/texture.c | 152 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index ffd6e88f30..0c29b1e19a 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1694,12 +1694,160 @@ static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int HeapFree(GetProcessHeap(), 0, converted_mem); }
+/* Context activation is done by the caller. */ +static void texture1d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, + const struct wined3d_context *context, const struct wined3d_bo_address *data) +{ + const struct wined3d_format *format = texture->resource.format; + const struct wined3d_gl_info *gl_info = context->gl_info; + + if (format->convert) + { + FIXME("Attempting to download a converted 1d texture, format %s.\n", + debug_d3dformat(format->id)); + return; + } + + if (data->buffer_object) + { + GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object)); + checkGLcall("glBindBuffer"); + } + + gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_1D, sub_resource_idx, + format->glFormat, format->glType, data->addr); + checkGLcall("glGetTexImage"); + + if (data->buffer_object) + { + GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0)); + checkGLcall("glBindBuffer"); + } +} + +/* Context activation is done by the caller. */ +static void texture1d_srgb_transfer(struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_context *context, BOOL dest_is_srgb) +{ + struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx]; + unsigned int row_pitch, slice_pitch; + struct wined3d_bo_address data; + + /* Optimisations are possible, but the effort should be put into either + * implementing EXT_SRGB_DECODE in the driver or finding out why we + * picked the wrong copy for the original upload and fixing that. + * + * Also keep in mind that we want to avoid using resource.heap_memory + * for DEFAULT pool surfaces. */ + WARN_(d3d_perf)("Performing slow rgb/srgb 1d texture transfer.\n"); + data.buffer_object = 0; + if (!(data.addr = HeapAlloc(GetProcessHeap(), 0, sub_resource->size))) + return; + + wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); + wined3d_texture_bind_and_dirtify(texture, context, !dest_is_srgb); + texture1d_download_data(texture, sub_resource_idx, context, &data); + wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb); + texture1d_upload_data(texture, sub_resource_idx, context, NULL, + wined3d_const_bo_address(&data), row_pitch, slice_pitch); + + HeapFree(GetProcessHeap(), 0, data.addr); +} + /* Context activation is done by the caller. */ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) { - FIXME("Not implemented.\n"); - return FALSE; + struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx]; + unsigned int row_pitch, slice_pitch; + + if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location)) + return FALSE; + + switch (location) + { + case WINED3D_LOCATION_TEXTURE_RGB: + case WINED3D_LOCATION_TEXTURE_SRGB: + if (sub_resource->locations & WINED3D_LOCATION_SYSMEM) + { + struct wined3d_const_bo_address data = {0, texture->resource.heap_memory}; + data.addr += sub_resource->offset; + wined3d_texture_bind_and_dirtify(texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB); + wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); + texture1d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch); + } + else if (sub_resource->locations & WINED3D_LOCATION_BUFFER) + { + struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL}; + wined3d_texture_bind_and_dirtify(texture, context, + location == WINED3D_LOCATION_TEXTURE_SRGB); + wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); + texture1d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch); + } + else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) + { + texture1d_srgb_transfer(texture, sub_resource_idx, context, TRUE); + } + else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_SRGB) + { + texture1d_srgb_transfer(texture, sub_resource_idx, context, FALSE); + } + else + { + FIXME("Implement 1d texture loading from %s.\n", wined3d_debug_location(sub_resource->locations)); + return FALSE; + } + break; + + case WINED3D_LOCATION_SYSMEM: + if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB)) + { + struct wined3d_bo_address data = {0, texture->resource.heap_memory}; + + data.addr += sub_resource->offset; + if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) + wined3d_texture_bind_and_dirtify(texture, context, FALSE); + else + wined3d_texture_bind_and_dirtify(texture, context, TRUE); + + texture1d_download_data(texture, sub_resource_idx, context, &data); + ++texture->download_count; + } + else + { + FIXME("Implement WINED3D_LOCATION_SYSMEM loading from %s.\n", + wined3d_debug_location(sub_resource->locations)); + return FALSE; + } + break; + + case WINED3D_LOCATION_BUFFER: + if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB)) + { + struct wined3d_bo_address data = {sub_resource->buffer_object, NULL}; + + if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) + wined3d_texture_bind_and_dirtify(texture, context, FALSE); + else + wined3d_texture_bind_and_dirtify(texture, context, TRUE); + + texture1d_download_data(texture, sub_resource_idx, context, &data); + } + else + { + FIXME("Implement WINED3D_LOCATION_BUFFER loading from %s.\n", + wined3d_debug_location(sub_resource->locations)); + return FALSE; + } + break; + + default: + FIXME("Implement %s loading from %s.\n", wined3d_debug_location(location), + wined3d_debug_location(sub_resource->locations)); + return FALSE; + } + + return TRUE; }
static void texture1d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse shesse@codeweavers.com wrote:
+/* Context activation is done by the caller. */ +static void texture1d_srgb_transfer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, BOOL dest_is_srgb)
+{
- struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
- unsigned int row_pitch, slice_pitch;
- struct wined3d_bo_address data;
- /* Optimisations are possible, but the effort should be put into either
* implementing EXT_SRGB_DECODE in the driver or finding out why we
* picked the wrong copy for the original upload and fixing that.
*
* Also keep in mind that we want to avoid using resource.heap_memory
* for DEFAULT pool surfaces. */
- WARN_(d3d_perf)("Performing slow rgb/srgb 1d texture transfer.\n");
- data.buffer_object = 0;
- if (!(data.addr = HeapAlloc(GetProcessHeap(), 0, sub_resource->size)))
return;
- wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
- wined3d_texture_bind_and_dirtify(texture, context, !dest_is_srgb);
- texture1d_download_data(texture, sub_resource_idx, context, &data);
- wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb);
- texture1d_upload_data(texture, sub_resource_idx, context, NULL,
wined3d_const_bo_address(&data), row_pitch, slice_pitch);
- HeapFree(GetProcessHeap(), 0, data.addr);
+}
We would like to avoid code duplication, if possible. Other than that, do we really need sRGB transfers for 1D textures? I think we are going to use 1D textures only when WINED3D_SRGB_READ_WRITE_CONTROL is disabled. We should avoid a separate sRGB texture if possible.
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/d3d11/d3d11_private.h | 24 ++ dlls/d3d11/device.c | 13 +- dlls/d3d11/texture.c | 537 +++++++++++++++++++++++++++++++++++++++++++++ dlls/d3d11/utils.c | 4 + 4 files changed, 576 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 4d9f34ea42..6f4184b0b1 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -112,6 +112,30 @@ void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN; HRESULT parse_dxbc(const char *data, SIZE_T data_size, HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
+/* ID3D11Texture1D, ID3D10Texture1D */ +struct d3d_texture1d +{ + ID3D11Texture1D ID3D11Texture1D_iface; + ID3D10Texture1D ID3D10Texture1D_iface; + LONG refcount; + + struct wined3d_private_store private_store; + IUnknown *dxgi_surface; + struct wined3d_texture *wined3d_texture; + D3D11_TEXTURE1D_DESC desc; + ID3D11Device *device; +}; + +static inline struct d3d_texture1d *impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) +{ + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface); +} + +HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc, + const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **texture) DECLSPEC_HIDDEN; +struct d3d_texture1d *unsafe_impl_from_ID3D11Texture1D(ID3D11Texture1D *iface) DECLSPEC_HIDDEN; +struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) DECLSPEC_HIDDEN; + /* ID3D11Texture2D, ID3D10Texture2D */ struct d3d_texture2d { diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index b2a40b3c6d..68279f71d3 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2739,9 +2739,18 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface, const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture) { - FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture); + struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_texture1d *object; + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture); + + if (FAILED(hr = d3d_texture1d_create(device, desc, data, &object))) + return hr; + + *texture = &object->ID3D11Texture1D_iface; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface, diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c index 177c0cc939..ba9001ac60 100644 --- a/dlls/d3d11/texture.c +++ b/dlls/d3d11/texture.c @@ -25,6 +25,543 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
+/* ID3D11Texture1D methods */ + +static inline struct d3d_texture1d *impl_from_ID3D11Texture1D(ID3D11Texture1D *iface) +{ + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D11Texture1D_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_QueryInterface(ID3D11Texture1D *iface, REFIID riid, void **object) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D11Texture1D) + || IsEqualGUID(riid, &IID_ID3D11Resource) + || IsEqualGUID(riid, &IID_ID3D11DeviceChild) + || IsEqualGUID(riid, &IID_IUnknown)) + { + *object = &texture->ID3D11Texture1D_iface; + IUnknown_AddRef((IUnknown *)*object); + return S_OK; + } + else if (IsEqualGUID(riid, &IID_ID3D10Texture1D) + || IsEqualGUID(riid, &IID_ID3D10Resource) + || IsEqualGUID(riid, &IID_ID3D10DeviceChild)) + { + *object = &texture->ID3D10Texture1D_iface; + IUnknown_AddRef((IUnknown *)*object); + return S_OK; + } + + if (texture->dxgi_surface) + { + TRACE("Forwarding to dxgi surface.\n"); + return IUnknown_QueryInterface(texture->dxgi_surface, riid, object); + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d11_texture1d_AddRef(ID3D11Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + ULONG refcount = InterlockedIncrement(&texture->refcount); + + TRACE("%p increasing refcount to %u.\n", texture, refcount); + + if (refcount == 1) + { + ID3D11Device_AddRef(texture->device); + wined3d_mutex_lock(); + wined3d_texture_incref(texture->wined3d_texture); + wined3d_mutex_unlock(); + } + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d11_texture1d_Release(ID3D11Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + ULONG refcount = InterlockedDecrement(&texture->refcount); + + TRACE("%p decreasing refcount to %u.\n", texture, refcount); + + if (!refcount) + { + ID3D11Device *device = texture->device; + + wined3d_mutex_lock(); + wined3d_texture_decref(texture->wined3d_texture); + wined3d_mutex_unlock(); + /* Release the device last, it may cause the wined3d device to be + * destroyed. */ + ID3D11Device_Release(device); + } + + return refcount; +} + +static void STDMETHODCALLTYPE d3d11_texture1d_GetDevice(ID3D11Texture1D *iface, ID3D11Device **device) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + + TRACE("iface %p, device %p.\n", iface, device); + + *device = texture->device; + ID3D11Device_AddRef(*device); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_GetPrivateData(ID3D11Texture1D *iface, + REFGUID guid, UINT *data_size, void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + IDXGISurface *dxgi_surface; + HRESULT hr; + + TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + if (texture->dxgi_surface + && SUCCEEDED(IUnknown_QueryInterface(texture->dxgi_surface, &IID_IDXGISurface, (void **)&dxgi_surface))) + { + hr = IDXGISurface_GetPrivateData(dxgi_surface, guid, data_size, data); + IDXGISurface_Release(dxgi_surface); + return hr; + } + + return d3d_get_private_data(&texture->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_SetPrivateData(ID3D11Texture1D *iface, + REFGUID guid, UINT data_size, const void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + IDXGISurface *dxgi_surface; + HRESULT hr; + + TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + if (texture->dxgi_surface + && SUCCEEDED(IUnknown_QueryInterface(texture->dxgi_surface, &IID_IDXGISurface, (void **)&dxgi_surface))) + { + hr = IDXGISurface_SetPrivateData(dxgi_surface, guid, data_size, data); + IDXGISurface_Release(dxgi_surface); + return hr; + } + + return d3d_set_private_data(&texture->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_SetPrivateDataInterface(ID3D11Texture1D *iface, + REFGUID guid, const IUnknown *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + IDXGISurface *dxgi_surface; + HRESULT hr; + + TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); + + if (texture->dxgi_surface + && SUCCEEDED(IUnknown_QueryInterface(texture->dxgi_surface, &IID_IDXGISurface, (void **)&dxgi_surface))) + { + hr = IDXGISurface_SetPrivateDataInterface(dxgi_surface, guid, data); + IDXGISurface_Release(dxgi_surface); + return hr; + } + + return d3d_set_private_data_interface(&texture->private_store, guid, data); +} + +static void STDMETHODCALLTYPE d3d11_texture1d_GetType(ID3D11Texture1D *iface, + D3D11_RESOURCE_DIMENSION *resource_dimension) +{ + TRACE("iface %p, resource_dimension %p.\n", iface, resource_dimension); + + *resource_dimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D; +} + +static void STDMETHODCALLTYPE d3d11_texture1d_SetEvictionPriority(ID3D11Texture1D *iface, UINT eviction_priority) +{ + FIXME("iface %p, eviction_priority %#x stub!\n", iface, eviction_priority); +} + +static UINT STDMETHODCALLTYPE d3d11_texture1d_GetEvictionPriority(ID3D11Texture1D *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static void STDMETHODCALLTYPE d3d11_texture1d_GetDesc(ID3D11Texture1D *iface, D3D11_TEXTURE1D_DESC *desc) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + struct wined3d_resource_desc wined3d_desc; + + TRACE("iface %p, desc %p.\n", iface, desc); + + *desc = texture->desc; + + wined3d_mutex_lock(); + wined3d_resource_get_desc(wined3d_texture_get_resource(texture->wined3d_texture), &wined3d_desc); + wined3d_mutex_unlock(); + + /* FIXME: Resizing swapchain buffers can cause these to change. We'd like + * to get everything from wined3d, but e.g. bind flags don't exist as such + * there (yet). */ + desc->Width = wined3d_desc.width; + desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format); +} + +static const struct ID3D11Texture1DVtbl d3d11_texture1d_vtbl = +{ + /* IUnknown methods */ + d3d11_texture1d_QueryInterface, + d3d11_texture1d_AddRef, + d3d11_texture1d_Release, + /* ID3D11DeviceChild methods */ + d3d11_texture1d_GetDevice, + d3d11_texture1d_GetPrivateData, + d3d11_texture1d_SetPrivateData, + d3d11_texture1d_SetPrivateDataInterface, + /* ID3D11Resource methods */ + d3d11_texture1d_GetType, + d3d11_texture1d_SetEvictionPriority, + d3d11_texture1d_GetEvictionPriority, + /* ID3D11Texture1D methods */ + d3d11_texture1d_GetDesc, +}; + +struct d3d_texture1d *unsafe_impl_from_ID3D11Texture1D(ID3D11Texture1D *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &d3d11_texture1d_vtbl); + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D11Texture1D_iface); +} + +/* IUnknown methods */ + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_QueryInterface(ID3D10Texture1D *iface, REFIID riid, void **object) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); + + return d3d11_texture1d_QueryInterface(&texture->ID3D11Texture1D_iface, riid, object); +} + +static ULONG STDMETHODCALLTYPE d3d10_texture1d_AddRef(ID3D10Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p.\n", iface); + + return d3d11_texture1d_AddRef(&texture->ID3D11Texture1D_iface); +} + +static void STDMETHODCALLTYPE d3d_texture1d_wined3d_object_released(void *parent) +{ + struct d3d_texture1d *texture = parent; + + if (texture->dxgi_surface) IUnknown_Release(texture->dxgi_surface); + wined3d_private_store_cleanup(&texture->private_store); + HeapFree(GetProcessHeap(), 0, texture); +} + +static ULONG STDMETHODCALLTYPE d3d10_texture1d_Release(ID3D10Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p.\n", iface); + + return d3d11_texture1d_Release(&texture->ID3D11Texture1D_iface); +} + +/* ID3D10DeviceChild methods */ + +static void STDMETHODCALLTYPE d3d10_texture1d_GetDevice(ID3D10Texture1D *iface, ID3D10Device **device) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, device %p.\n", iface, device); + + ID3D11Device_QueryInterface(texture->device, &IID_ID3D10Device, (void **)device); +} + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_GetPrivateData(ID3D10Texture1D *iface, + REFGUID guid, UINT *data_size, void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return d3d11_texture1d_GetPrivateData(&texture->ID3D11Texture1D_iface, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_SetPrivateData(ID3D10Texture1D *iface, + REFGUID guid, UINT data_size, const void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return d3d11_texture1d_SetPrivateData(&texture->ID3D11Texture1D_iface, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_SetPrivateDataInterface(ID3D10Texture1D *iface, + REFGUID guid, const IUnknown *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); + + return d3d11_texture1d_SetPrivateDataInterface(&texture->ID3D11Texture1D_iface, guid, data); +} + +/* ID3D10Resource methods */ + +static void STDMETHODCALLTYPE d3d10_texture1d_GetType(ID3D10Texture1D *iface, + D3D10_RESOURCE_DIMENSION *resource_dimension) +{ + TRACE("iface %p, resource_dimension %p\n", iface, resource_dimension); + + *resource_dimension = D3D10_RESOURCE_DIMENSION_TEXTURE1D; +} + +static void STDMETHODCALLTYPE d3d10_texture1d_SetEvictionPriority(ID3D10Texture1D *iface, UINT eviction_priority) +{ + FIXME("iface %p, eviction_priority %u stub!\n", iface, eviction_priority); +} + +static UINT STDMETHODCALLTYPE d3d10_texture1d_GetEvictionPriority(ID3D10Texture1D *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +/* ID3D10Texture1D methods */ + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_Map(ID3D10Texture1D *iface, UINT sub_resource_idx, + D3D10_MAP map_type, UINT map_flags, void **ppData) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + struct wined3d_map_desc wined3d_map_desc; + HRESULT hr; + + TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, ppData %p.\n", + iface, sub_resource_idx, map_type, map_flags, ppData); + + if (map_flags) + FIXME("Ignoring map_flags %#x.\n", map_flags); + + wined3d_mutex_lock(); + if (SUCCEEDED(hr = wined3d_resource_map(wined3d_texture_get_resource(texture->wined3d_texture), sub_resource_idx, + &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type)))) + { + *ppData = wined3d_map_desc.data; + } + wined3d_mutex_unlock(); + + return hr; +} + +static void STDMETHODCALLTYPE d3d10_texture1d_Unmap(ID3D10Texture1D *iface, UINT sub_resource_idx) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx); + + wined3d_mutex_lock(); + wined3d_resource_unmap(wined3d_texture_get_resource(texture->wined3d_texture), sub_resource_idx); + wined3d_mutex_unlock(); +} + +static void STDMETHODCALLTYPE d3d10_texture1d_GetDesc(ID3D10Texture1D *iface, D3D10_TEXTURE1D_DESC *desc) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + D3D11_TEXTURE1D_DESC d3d11_desc; + + TRACE("iface %p, desc %p\n", iface, desc); + + d3d11_texture1d_GetDesc(&texture->ID3D11Texture1D_iface, &d3d11_desc); + + desc->Width = d3d11_desc.Width; + desc->MipLevels = d3d11_desc.MipLevels; + desc->ArraySize = d3d11_desc.ArraySize; + desc->Format = d3d11_desc.Format; + desc->Usage = d3d10_usage_from_d3d11_usage(d3d11_desc.Usage); + desc->BindFlags = d3d10_bind_flags_from_d3d11_bind_flags(d3d11_desc.BindFlags); + desc->CPUAccessFlags = d3d10_cpu_access_flags_from_d3d11_cpu_access_flags(d3d11_desc.CPUAccessFlags); + desc->MiscFlags = d3d10_resource_misc_flags_from_d3d11_resource_misc_flags(d3d11_desc.MiscFlags); +} + +static const struct ID3D10Texture1DVtbl d3d10_texture1d_vtbl = +{ + /* IUnknown methods */ + d3d10_texture1d_QueryInterface, + d3d10_texture1d_AddRef, + d3d10_texture1d_Release, + /* ID3D10DeviceChild methods */ + d3d10_texture1d_GetDevice, + d3d10_texture1d_GetPrivateData, + d3d10_texture1d_SetPrivateData, + d3d10_texture1d_SetPrivateDataInterface, + /* ID3D10Resource methods */ + d3d10_texture1d_GetType, + d3d10_texture1d_SetEvictionPriority, + d3d10_texture1d_GetEvictionPriority, + /* ID3D10Texture1D methods */ + d3d10_texture1d_Map, + d3d10_texture1d_Unmap, + d3d10_texture1d_GetDesc, +}; + +struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &d3d10_texture1d_vtbl); + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface); +} + +static const struct wined3d_parent_ops d3d_texture1d_wined3d_parent_ops = +{ + d3d_texture1d_wined3d_object_released, +}; + +/* +static BOOL is_gdi_compatible_texture(const D3D11_TEXTURE1D_DESC *desc) +{ + if (!(desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM + || desc->Format == DXGI_FORMAT_B8G8R8A8_TYPELESS + || desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB)) + return FALSE; + + if (desc->Usage != D3D11_USAGE_DEFAULT) + return FALSE; + + return TRUE; +} + +static BOOL validate_texture1d_desc(const D3D11_TEXTURE1D_DESC *desc) +{ + if (desc->MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE + && desc->ArraySize < 6) + { + WARN("Invalid array size %u for cube texture.\n", desc->ArraySize); + return FALSE; + } + + if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE + && !is_gdi_compatible_texture(desc)) + { + WARN("Incompatible description used to create GDI compatible texture.\n"); + return FALSE; + } + + return TRUE; +} +*/ + +HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc, + const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **out) +{ + struct wined3d_resource_desc wined3d_desc; + struct d3d_texture1d *texture; + unsigned int levels; + DWORD flags = 0; + HRESULT hr; + +/* + if (!validate_texture1d_desc(desc)) + { + WARN("Failed to validate texture desc.\n"); + return E_INVALIDARG; + } +*/ + + if (!(texture = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*texture)))) + return E_OUTOFMEMORY; + + texture->ID3D11Texture1D_iface.lpVtbl = &d3d11_texture1d_vtbl; + texture->ID3D10Texture1D_iface.lpVtbl = &d3d10_texture1d_vtbl; + texture->refcount = 1; + wined3d_mutex_lock(); + wined3d_private_store_init(&texture->private_store); + texture->desc = *desc; + + wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_1D; + wined3d_desc.format = wined3dformat_from_dxgi_format(desc->Format); + wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE; + wined3d_desc.multisample_quality = 0; + wined3d_desc.usage = wined3d_usage_from_d3d11(desc->BindFlags, desc->Usage); + wined3d_desc.pool = WINED3D_POOL_DEFAULT; + wined3d_desc.width = desc->Width; + wined3d_desc.height = 1; + wined3d_desc.depth = 1; + wined3d_desc.size = 0; + + levels = desc->MipLevels ? desc->MipLevels : wined3d_log2i(desc->Width) + 1; + + if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE) + flags |= WINED3D_TEXTURE_CREATE_GET_DC; + + if (FAILED(hr = wined3d_texture_create(device->wined3d_device, &wined3d_desc, + desc->ArraySize, levels, flags, (struct wined3d_sub_resource_data *)data, + texture, &d3d_texture1d_wined3d_parent_ops, &texture->wined3d_texture))) + { + WARN("Failed to create wined3d texture, hr %#x.\n", hr); + wined3d_private_store_cleanup(&texture->private_store); + HeapFree(GetProcessHeap(), 0, texture); + wined3d_mutex_unlock(); + if (hr == WINED3DERR_NOTAVAILABLE || hr == WINED3DERR_INVALIDCALL) + hr = E_INVALIDARG; + return hr; + } + texture->desc.MipLevels = levels; + + if (desc->MipLevels == 1 && desc->ArraySize == 1) + { + IWineDXGIDevice *wine_device; + + if (FAILED(hr = ID3D10Device1_QueryInterface(&device->ID3D10Device1_iface, &IID_IWineDXGIDevice, + (void **)&wine_device))) + { + ERR("Device should implement IWineDXGIDevice.\n"); + wined3d_texture_decref(texture->wined3d_texture); + wined3d_mutex_unlock(); + return E_FAIL; + } + + hr = IWineDXGIDevice_create_surface(wine_device, texture->wined3d_texture, 0, NULL, + (IUnknown *)&texture->ID3D10Texture1D_iface, (void **)&texture->dxgi_surface); + IWineDXGIDevice_Release(wine_device); + if (FAILED(hr)) + { + ERR("Failed to create DXGI surface, returning %#.x\n", hr); + texture->dxgi_surface = NULL; + wined3d_texture_decref(texture->wined3d_texture); + wined3d_mutex_unlock(); + return hr; + } + } + wined3d_mutex_unlock(); + + ID3D11Device_AddRef(texture->device = &device->ID3D11Device_iface); + + TRACE("Created texture %p.\n", texture); + *out = texture; + + return S_OK; +} + /* ID3D11Texture2D methods */
static inline struct d3d_texture2d *impl_from_ID3D11Texture2D(ID3D11Texture2D *iface) diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c index e919c58da4..790e16eaaf 100644 --- a/dlls/d3d11/utils.c +++ b/dlls/d3d11/utils.c @@ -607,6 +607,10 @@ struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *re return wined3d_buffer_get_resource(unsafe_impl_from_ID3D11Buffer( (ID3D11Buffer *)resource)->wined3d_buffer);
+ case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture1D( + (ID3D11Texture1D *)resource)->wined3d_texture); + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture2D( (ID3D11Texture2D *)resource)->wined3d_texture);
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse shesse@codeweavers.com wrote:
Signed-off-by: Sven Hesse shesse@codeweavers.com
dlls/d3d11/d3d11_private.h | 24 ++ dlls/d3d11/device.c | 13 +- dlls/d3d11/texture.c | 537 +++++++++++++++++++++++++++++++++++++++++++++ dlls/d3d11/utils.c | 4 + 4 files changed, 576 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 4d9f34ea42..6f4184b0b1 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -112,6 +112,30 @@ void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN; HRESULT parse_dxbc(const char *data, SIZE_T data_size, HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
+/* ID3D11Texture1D, ID3D10Texture1D */ +struct d3d_texture1d +{
- ID3D11Texture1D ID3D11Texture1D_iface;
- ID3D10Texture1D ID3D10Texture1D_iface;
- LONG refcount;
- struct wined3d_private_store private_store;
- IUnknown *dxgi_surface;
- struct wined3d_texture *wined3d_texture;
- D3D11_TEXTURE1D_DESC desc;
- ID3D11Device *device;
+};
+static inline struct d3d_texture1d *impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) +{
- return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface);
+}
Please move impl_from_ID3D10Texture1D() to texture.c file.
+static void STDMETHODCALLTYPE d3d11_texture1d_GetDesc(ID3D11Texture1D *iface, D3D11_TEXTURE1D_DESC *desc) +{
- struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface);
- struct wined3d_resource_desc wined3d_desc;
- TRACE("iface %p, desc %p.\n", iface, desc);
- *desc = texture->desc;
- wined3d_mutex_lock();
- wined3d_resource_get_desc(wined3d_texture_get_resource(texture->wined3d_texture), &wined3d_desc);
- wined3d_mutex_unlock();
- /* FIXME: Resizing swapchain buffers can cause these to change. We'd like
* to get everything from wined3d, but e.g. bind flags don't exist as such
* there (yet). */
- desc->Width = wined3d_desc.width;
- desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format);
+}
Is it possible to create swapchains with 1D textures? We do not ever create such swapchains so the comment (and code) is not accurate.
+struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) +{
- if (!iface)
return NULL;
- assert(iface->lpVtbl == &d3d10_texture1d_vtbl);
- return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface);
+}
+static const struct wined3d_parent_ops d3d_texture1d_wined3d_parent_ops = +{
- d3d_texture1d_wined3d_object_released,
+};
+/* +static BOOL is_gdi_compatible_texture(const D3D11_TEXTURE1D_DESC *desc) +{
- if (!(desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM
|| desc->Format == DXGI_FORMAT_B8G8R8A8_TYPELESS
|| desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB))
return FALSE;
- if (desc->Usage != D3D11_USAGE_DEFAULT)
return FALSE;
- return TRUE;
+}
+static BOOL validate_texture1d_desc(const D3D11_TEXTURE1D_DESC *desc) +{
- if (desc->MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE
&& desc->ArraySize < 6)
- {
WARN("Invalid array size %u for cube texture.\n", desc->ArraySize);
return FALSE;
- }
- if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE
&& !is_gdi_compatible_texture(desc))
- {
WARN("Incompatible description used to create GDI compatible texture.\n");
return FALSE;
- }
- return TRUE;
+}
It would be good to test if 1D textures need GDI support.
+*/
+HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **out)
+{
- struct wined3d_resource_desc wined3d_desc;
- struct d3d_texture1d *texture;
- unsigned int levels;
- DWORD flags = 0;
- HRESULT hr;
+/*
- if (!validate_texture1d_desc(desc))
- {
WARN("Failed to validate texture desc.\n");
return E_INVALIDARG;
- }
+*/
Please do not introduce commented out code.
diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c index e919c58da4..790e16eaaf 100644 --- a/dlls/d3d11/utils.c +++ b/dlls/d3d11/utils.c @@ -607,6 +607,10 @@ struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *re return wined3d_buffer_get_resource(unsafe_impl_from_ID3D11Buffer( (ID3D11Buffer *)resource)->wined3d_buffer);
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture1D(
(ID3D11Texture1D *)resource)->wined3d_texture);
case D3D11_RESOURCE_DIMENSION_TEXTURE2D: return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture2D( (ID3D11Texture2D *)resource)->wined3d_texture);
You should also handle 1D textures in wined3d_resource_from_d3d10_resource().
-- 2.15.1
2018-01-04 12:21 GMT+01:00 Józef Kucia joseph.kucia@gmail.com:
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse shesse@codeweavers.com wrote:
+/* +static BOOL is_gdi_compatible_texture(const D3D11_TEXTURE1D_DESC *desc) +{
- if (!(desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM
|| desc->Format == DXGI_FORMAT_B8G8R8A8_TYPELESS
|| desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB))
return FALSE;
- if (desc->Usage != D3D11_USAGE_DEFAULT)
return FALSE;
- return TRUE;
+}
+static BOOL validate_texture1d_desc(const D3D11_TEXTURE1D_DESC *desc) +{
- if (desc->MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE
&& desc->ArraySize < 6)
- {
WARN("Invalid array size %u for cube texture.\n", desc->ArraySize);
return FALSE;
- }
- if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE
&& !is_gdi_compatible_texture(desc))
- {
WARN("Incompatible description used to create GDI compatible texture.\n");
return FALSE;
- }
- return TRUE;
+}
It would be good to test if 1D textures need GDI support.
+*/
+HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **out)
+{
- struct wined3d_resource_desc wined3d_desc;
- struct d3d_texture1d *texture;
- unsigned int levels;
- DWORD flags = 0;
- HRESULT hr;
+/*
- if (!validate_texture1d_desc(desc))
- {
WARN("Failed to validate texture desc.\n");
return E_INVALIDARG;
- }
+*/
Please do not introduce commented out code.
Yeah, you need to resolve this one way or another. I don't think 1D cube textures can possibly be a thing, but in general this is matter of writing some tests.
Signed-off-by: Sven Hesse shesse@codeweavers.com --- dlls/d3d11/tests/d3d11.c | 734 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 734 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 74c0488f06..9aba802d1b 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -1734,6 +1734,737 @@ static void test_get_immediate_context(void) ok(!refcount, "Device has %u references left.\n", refcount); }
+static void test_create_texture1d(void) +{ + ULONG refcount, expected_refcount; + D3D11_SUBRESOURCE_DATA data = {0}; + ID3D11Device *device, *tmp; + D3D11_TEXTURE1D_DESC desc; + ID3D11Texture1D *texture; + unsigned int i; + HRESULT hr; + + static const struct + { + DXGI_FORMAT format; + UINT array_size; + D3D11_BIND_FLAG bind_flags; + UINT misc_flags; + BOOL succeeds; + BOOL todo; + } + tests[] = + { + {DXGI_FORMAT_R32G32B32A32_TYPELESS, 0, D3D11_BIND_SHADER_RESOURCE, 0, FALSE, FALSE}, + {DXGI_FORMAT_R32G32B32A32_TYPELESS, 1, D3D11_BIND_SHADER_RESOURCE, 0, TRUE, FALSE}, + {DXGI_FORMAT_R32G32B32A32_TYPELESS, 2, D3D11_BIND_SHADER_RESOURCE, 0, TRUE, FALSE}, + {DXGI_FORMAT_R32G32B32A32_TYPELESS, 3, D3D11_BIND_SHADER_RESOURCE, 0, TRUE, FALSE}, + }; + + if (!(device = create_device(NULL))) + { + skip("Failed to create device.\n"); + return; + } + + desc.Width = 512; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; + desc.MiscFlags = 0; + + hr = ID3D11Device_CreateTexture1D(device, &desc, &data, &texture); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + + expected_refcount = get_refcount(device) + 1; + hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture); + ok(SUCCEEDED(hr), "Failed to create a 1d texture, hr %#x.\n", hr); + refcount = get_refcount(device); + ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount); + tmp = NULL; + expected_refcount = refcount + 1; + ID3D11Texture1D_GetDevice(texture, &tmp); + ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device); + refcount = get_refcount(device); + ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + ID3D11Device_Release(tmp); + + check_interface(texture, &IID_IDXGISurface, TRUE, FALSE); + ID3D11Texture1D_Release(texture); + + desc.MipLevels = 0; + expected_refcount = get_refcount(device) + 1; + hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture); + ok(SUCCEEDED(hr), "Failed to create a 1d texture, hr %#x.\n", hr); + refcount = get_refcount(device); + ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount); + tmp = NULL; + expected_refcount = refcount + 1; + ID3D11Texture1D_GetDevice(texture, &tmp); + ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device); + refcount = get_refcount(device); + ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); + ID3D11Device_Release(tmp); + + ID3D11Texture1D_GetDesc(texture, &desc); + ok(desc.Width == 512, "Got unexpected Width %u.\n", desc.Width); + ok(desc.MipLevels == 10, "Got unexpected MipLevels %u.\n", desc.MipLevels); + ok(desc.ArraySize == 1, "Got unexpected ArraySize %u.\n", desc.ArraySize); + ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format); + ok(desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected Usage %u.\n", desc.Usage); + ok(desc.BindFlags == D3D11_BIND_SHADER_RESOURCE, "Got unexpected BindFlags %#x.\n", desc.BindFlags); + ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %#x.\n", desc.CPUAccessFlags); + ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %#x.\n", desc.MiscFlags); + + check_interface(texture, &IID_IDXGISurface, FALSE, FALSE); + ID3D11Texture1D_Release(texture); + + desc.MipLevels = 1; + desc.ArraySize = 2; + hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture); + ok(SUCCEEDED(hr), "Failed to create a 1d texture, hr %#x.\n", hr); + + check_interface(texture, &IID_IDXGISurface, FALSE, FALSE); + ID3D11Texture1D_Release(texture); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + HRESULT expected_hr = tests[i].succeeds ? S_OK : E_INVALIDARG; + BOOL todo = tests[i].todo; + + desc.ArraySize = tests[i].array_size; + desc.Format = tests[i].format; + desc.BindFlags = tests[i].bind_flags; + desc.MiscFlags = tests[i].misc_flags; + hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, (ID3D11Texture1D **)&texture); + + todo_wine_if(todo) + ok(hr == expected_hr, "Test %u: Got unexpected hr %#x (format %#x).\n", + i, hr, desc.Format); + + if (SUCCEEDED(hr)) + ID3D11Texture1D_Release(texture); + } + + refcount = ID3D11Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + +static void test_texture1d_interfaces(void) +{ + ID3D10Texture1D *d3d10_texture; + D3D11_TEXTURE1D_DESC desc; + ID3D11Texture1D *texture; + ID3D11Device *device; + unsigned int i; + ULONG refcount; + HRESULT hr; + + static const struct test + { + BOOL implements_d3d10_interfaces; + UINT bind_flags; + UINT misc_flags; + UINT expected_bind_flags; + UINT expected_misc_flags; + } + desc_conversion_tests[] = + { + { + TRUE, + D3D11_BIND_SHADER_RESOURCE, 0, + D3D10_BIND_SHADER_RESOURCE, 0 + }, + { + TRUE, + D3D11_BIND_UNORDERED_ACCESS, 0, + D3D11_BIND_UNORDERED_ACCESS, 0 + }, + { + FALSE, + 0, D3D11_RESOURCE_MISC_RESOURCE_CLAMP, + 0, 0 + }, + { + TRUE, + 0, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, + 0, D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX + }, + }; + + if (!(device = create_device(NULL))) + { + skip("Failed to create ID3D11Device, skipping tests.\n"); + return; + } + + desc.Width = 512; + desc.MipLevels = 0; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_RENDER_TARGET; + desc.CPUAccessFlags = 0; + desc.MiscFlags = 0; + + hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture); + ok(SUCCEEDED(hr), "Failed to create a 1d texture, hr %#x.\n", hr); + check_interface(texture, &IID_IDXGISurface, FALSE, FALSE); + hr = check_interface(texture, &IID_ID3D10Texture1D, TRUE, TRUE); /* Not available on all Windows versions. */ + ID3D11Texture1D_Release(texture); + if (FAILED(hr)) + { + win_skip("1D textures do not implement ID3D10Texture1D, skipping tests.\n"); + ID3D11Device_Release(device); + return; + } + + for (i = 0; i < ARRAY_SIZE(desc_conversion_tests); ++i) + { + const struct test *current = &desc_conversion_tests[i]; + D3D10_TEXTURE1D_DESC d3d10_desc; + ID3D10Device *d3d10_device; + + desc.Width = 512; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = current->bind_flags; + desc.CPUAccessFlags = 0; + desc.MiscFlags = current->misc_flags; + + hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture); + /* Shared resources are not supported by REF and WARP devices. */ + ok(SUCCEEDED(hr) || broken(hr == E_OUTOFMEMORY), + "Test %u: Failed to create a 1d texture, hr %#x.\n", i, hr); + if (FAILED(hr)) + { + win_skip("Failed to create ID3D11Texture1D, skipping test %u.\n", i); + continue; + } + + check_interface(texture, &IID_IDXGISurface, TRUE, FALSE); + + hr = ID3D11Texture1D_QueryInterface(texture, &IID_ID3D10Texture1D, (void **)&d3d10_texture); + ID3D11Texture1D_Release(texture); + + if (current->implements_d3d10_interfaces) + { + ok(SUCCEEDED(hr), "Test %u: Texture should implement ID3D10Texture1D.\n", i); + } + else + { + todo_wine ok(hr == E_NOINTERFACE, "Test %u: Texture should not implement ID3D10Texture1D.\n", i); + if (SUCCEEDED(hr)) ID3D10Texture1D_Release(d3d10_texture); + continue; + } + + ID3D10Texture1D_GetDesc(d3d10_texture, &d3d10_desc); + + ok(d3d10_desc.Width == desc.Width, + "Test %u: Got unexpected Width %u.\n", i, d3d10_desc.Width); + ok(d3d10_desc.MipLevels == desc.MipLevels, + "Test %u: Got unexpected MipLevels %u.\n", i, d3d10_desc.MipLevels); + ok(d3d10_desc.ArraySize == desc.ArraySize, + "Test %u: Got unexpected ArraySize %u.\n", i, d3d10_desc.ArraySize); + ok(d3d10_desc.Format == desc.Format, + "Test %u: Got unexpected Format %u.\n", i, d3d10_desc.Format); + ok(d3d10_desc.BindFlags == current->expected_bind_flags, + "Test %u: Got unexpected BindFlags %#x.\n", i, d3d10_desc.BindFlags); + ok(d3d10_desc.CPUAccessFlags == desc.CPUAccessFlags, + "Test %u: Got unexpected CPUAccessFlags %#x.\n", i, d3d10_desc.CPUAccessFlags); + ok(d3d10_desc.MiscFlags == current->expected_misc_flags, + "Test %u: Got unexpected MiscFlags %#x.\n", i, d3d10_desc.MiscFlags); + + d3d10_device = (ID3D10Device *)0xdeadbeef; + ID3D10Texture1D_GetDevice(d3d10_texture, &d3d10_device); + todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); + if (d3d10_device) ID3D10Device_Release(d3d10_device); + + ID3D10Texture1D_Release(d3d10_texture); + } + + refcount = ID3D11Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + +static void test_texture1d(void) +{ + struct shader + { + const DWORD *code; + size_t size; + }; + struct texture + { + UINT width; + UINT miplevel_count; + UINT array_size; + DXGI_FORMAT format; + D3D11_SUBRESOURCE_DATA data[3]; + }; + + D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc; + struct d3d11_test_context test_context; + const struct texture *current_texture; + D3D11_TEXTURE1D_DESC texture_desc; + D3D11_SAMPLER_DESC sampler_desc; + const struct shader *current_ps; + D3D_FEATURE_LEVEL feature_level; + ID3D11ShaderResourceView *srv; + ID3D11DeviceContext *context; + ID3D11SamplerState *sampler; + struct resource_readback rb; + ID3D11Texture1D *texture; + struct vec4 ps_constant; + ID3D11PixelShader *ps; + ID3D11Device *device; + unsigned int i, x; + ID3D11Buffer *cb; + DWORD color; + HRESULT hr; + + static const DWORD ps_ld_code[] = + { +#if 0 + Texture1D t; + + float miplevel; + + float4 main(float4 position : SV_POSITION) : SV_TARGET + { + float2 p; + t.GetDimensions(miplevel, p.x, p.y); + p.y = miplevel; + p *= float2(position.x / 640.0f, 1.0f); + return t.Load(int2(p)); + } +#endif + 0x43425844, 0x7b0c6359, 0x598178f6, 0xef2ddbdb, 0x88fc794c, 0x00000001, 0x000001ac, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040, + 0x00000044, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001058, 0x00107000, 0x00000000, + 0x00005555, 0x04002064, 0x00101012, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, + 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, + 0x0700003d, 0x001000f2, 0x00000000, 0x0010000a, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, + 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0010100a, 0x00000000, 0x06000036, 0x001000e2, + 0x00000000, 0x00208006, 0x00000000, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46, + 0x00000000, 0x00004002, 0x3acccccd, 0x3f800000, 0x3f800000, 0x3f800000, 0x0500001b, 0x001000f2, + 0x00000000, 0x00100e46, 0x00000000, 0x0700002d, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, + 0x00107e46, 0x00000000, 0x0100003e, + }; + static const struct shader ps_ld = {ps_ld_code, sizeof(ps_ld_code)}; + static const DWORD ps_ld_sint8_code[] = + { +#if 0 + Texture1D<int4> t; + + float4 main(float4 position : SV_POSITION) : SV_TARGET + { + float2 p, s; + int4 c; + + p = float2(position.x / 640.0f, 0.0f); + t.GetDimensions(0, s.x, s.y); + p *= s; + + c = t.Load(int2(p)); + return (max(c / (float4)127, (float4)-1) + (float4)1) / 2.0f; + } +#endif + 0x43425844, 0x65a13d1e, 0x8a0bfc92, 0xa2f2708a, 0x0bafafb6, 0x00000001, 0x00000234, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000198, 0x00000040, + 0x00000066, 0x04001058, 0x00107000, 0x00000000, 0x00003333, 0x04002064, 0x00101012, 0x00000000, + 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2, + 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100012, 0x00000001, + 0x0010100a, 0x00000000, 0x00004001, 0x3acccccd, 0x08000036, 0x001000e2, 0x00000001, 0x00004002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038, 0x001000f2, 0x00000000, 0x00100fc6, + 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, + 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x0500002b, + 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46, + 0x00000000, 0x00004002, 0x3c010204, 0x3c010204, 0x3c010204, 0x3c010204, 0x0a000034, 0x001000f2, + 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0xbf800000, 0xbf800000, 0xbf800000, 0xbf800000, + 0x0a000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, + 0x3f800000, 0x3f800000, 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, + 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e, + }; + static const struct shader ps_ld_sint8 = {ps_ld_sint8_code, sizeof(ps_ld_sint8_code)}; + static const DWORD ps_ld_uint8_code[] = + { +#if 0 + Texture1D<uint4> t; + + float4 main(float4 position : SV_POSITION) : SV_TARGET + { + float2 p, s; + + p = float2(position.x / 640.0f, 0.0f); + t.GetDimensions(0, s.x, s.y); + p *= s; + + return t.Load(int2(p)) / (float4)255; + } +#endif + 0x43425844, 0x35186c1f, 0x55bad4fd, 0xb7c97a57, 0x99c060e7, 0x00000001, 0x000001bc, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000010f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000120, 0x00000040, + 0x00000048, 0x04001058, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101012, 0x00000000, + 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0700003d, 0x001000f2, + 0x00000000, 0x00004001, 0x00000000, 0x00107e46, 0x00000000, 0x07000038, 0x00100012, 0x00000001, + 0x0010100a, 0x00000000, 0x00004001, 0x3acccccd, 0x08000036, 0x001000e2, 0x00000001, 0x00004002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07000038, 0x001000f2, 0x00000000, 0x00100fc6, + 0x00000000, 0x00100e46, 0x00000001, 0x0500001b, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, + 0x0700002d, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x05000056, + 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46, + 0x00000000, 0x00004002, 0x3b808081, 0x3b808081, 0x3b808081, 0x3b808081, 0x0100003e, + }; + static const struct shader ps_ld_uint8 = {ps_ld_uint8_code, sizeof(ps_ld_uint8_code)}; + + static const DWORD rgba_level_0[] = + { + 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00, + }; + static const DWORD rgba_level_1[] = + { + 0xffffffff, 0xff0000ff, + }; + static const DWORD rgba_level_2[] = + { + 0xffff0000, + }; + static const DWORD srgb_data[] = + { + 0x00000000, 0xffffffff, 0xff000000, 0x7f7f7f7f, + }; + static const DWORD r32_uint[] = + { + 0, 1, 2, 3, + }; + static const DWORD r9g9b9e5_data[] = + { + 0x80000100, 0x80020000, 0x84000000, 0x84000100, + }; + static const struct texture rgba_texture = + { + 4, 3, 1, DXGI_FORMAT_R8G8B8A8_UNORM, + { + {rgba_level_0, 4 * sizeof(*rgba_level_0), 0}, + {rgba_level_1, 2 * sizeof(*rgba_level_1), 0}, + {rgba_level_2, sizeof(*rgba_level_2), 0}, + } + }; + static const struct texture srgb_texture = {4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + {{srgb_data, 4 * sizeof(*srgb_data)}}}; + static const struct texture sint8_texture = {4, 1, 1, DXGI_FORMAT_R8G8B8A8_SINT, + {{rgba_level_0, 4 * sizeof(*rgba_level_0)}}}; + static const struct texture uint8_texture = {4, 1, 1, DXGI_FORMAT_R8G8B8A8_UINT, + {{rgba_level_0, 4 * sizeof(*rgba_level_0)}}}; + static const struct texture r32u_typeless = {4, 1, 1, DXGI_FORMAT_R32_TYPELESS, + {{r32_uint, 4 * sizeof(*r32_uint)}}}; + static const struct texture r9g9b9e5_texture = {4, 1, 1, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, + {{r9g9b9e5_data, 4 * sizeof(*r9g9b9e5_data)}}}; + + static const DWORD level_1_colors[] = + { + 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff, + }; + static const DWORD level_2_colors[] = + { + 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, + }; + static const DWORD srgb_colors[] = + { + 0x00000001, 0xffffffff, 0xff000000, 0x7f363636, + }; + static const DWORD sint8_colors[] = + { + 0x7e80807e, 0x7e807e7e, 0x7e807e80, 0x7e7e7e80, + }; + static const DWORD r32u_colors[4] = + { + 0x01000000, 0x01000001, 0x01000002, 0x01000003, + }; + static const DWORD r9g9b9e5_colors[4] = + { + 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffff00ff, + }; + static const DWORD zero_colors[4] = {0}; + static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f}; + static const struct texture_test + { + const struct shader *ps; + const struct texture *texture; + D3D11_FILTER filter; + float lod_bias; + float min_lod; + float max_lod; + float ps_constant; + const DWORD *expected_colors; + } + texture_tests[] = + { +#define POINT D3D11_FILTER_MIN_MAG_MIP_POINT +#define POINT_LINEAR D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR +#define MIP_MAX D3D11_FLOAT32_MAX + {&ps_ld, &rgba_texture, POINT, 0.0f, 0.0f, 0.0f, 0.0f, rgba_level_0}, + {&ps_ld, &rgba_texture, POINT, 0.0f, 0.0f, 0.0f, 1.0f, level_1_colors}, + {&ps_ld, &rgba_texture, POINT, 0.0f, 0.0f, 0.0f, 2.0f, level_2_colors}, + {&ps_ld, &rgba_texture, POINT, 0.0f, 0.0f, 0.0f, 3.0f, zero_colors}, + {&ps_ld, &srgb_texture, POINT, 0.0f, 0.0f, 0.0f, 0.0f, srgb_colors}, + {&ps_ld, &r9g9b9e5_texture, POINT, 0.0f, 0.0f, 0.0f, 0.0f, r9g9b9e5_colors}, + {&ps_ld, NULL, POINT, 0.0f, 0.0f, 0.0f, 0.0f, zero_colors}, + {&ps_ld, NULL, POINT, 0.0f, 0.0f, MIP_MAX, 0.0f, zero_colors}, + {&ps_ld_sint8, &sint8_texture, POINT, 0.0f, 0.0f, 0.0f, 0.0f, sint8_colors}, + {&ps_ld_uint8, &uint8_texture, POINT, 0.0f, 0.0f, 0.0f, 0.0f, rgba_level_0}, + }; +#undef POINT +#undef POINT_LINEAR +#undef MIP_MAX + static const struct srv_test + { + const struct shader *ps; + const struct texture *texture; + struct srv_desc srv_desc; + float ps_constant; + const DWORD *expected_colors; + } + srv_tests[] = + { +#define TEX_1D D3D11_SRV_DIMENSION_TEXTURE1D +#define R32_UINT DXGI_FORMAT_R32_UINT + {&ps_ld_uint8, &r32u_typeless, {R32_UINT, TEX_1D, 0, 1}, 0.0f, r32u_colors}, +#undef TEX_1D +#undef R32_UINT +#undef FMT_UNKNOWN + }; + + if (!init_test_context(&test_context, NULL)) + return; + + device = test_context.device; + context = test_context.immediate_context; + feature_level = ID3D11Device_GetFeatureLevel(device); + + cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(ps_constant), NULL); + + ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb); + + texture_desc.Usage = D3D11_USAGE_DEFAULT; + texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + texture_desc.CPUAccessFlags = 0; + texture_desc.MiscFlags = 0; + + sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + sampler_desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; + sampler_desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; + sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; + sampler_desc.MipLODBias = 0.0f; + sampler_desc.MaxAnisotropy = 0; + sampler_desc.ComparisonFunc = D3D11_COMPARISON_NEVER; + sampler_desc.BorderColor[0] = 0.0f; + sampler_desc.BorderColor[1] = 0.0f; + sampler_desc.BorderColor[2] = 0.0f; + sampler_desc.BorderColor[3] = 0.0f; + sampler_desc.MinLOD = 0.0f; + sampler_desc.MaxLOD = D3D11_FLOAT32_MAX; + + ps = NULL; + srv = NULL; + sampler = NULL; + texture = NULL; + current_ps = NULL; + current_texture = NULL; + for (i = 0; i < ARRAY_SIZE(texture_tests); ++i) + { + const struct texture_test *test = &texture_tests[i]; + + if (current_ps != test->ps) + { + if (ps) + ID3D11PixelShader_Release(ps); + + current_ps = test->ps; + + hr = ID3D11Device_CreatePixelShader(device, current_ps->code, current_ps->size, NULL, &ps); + ok(SUCCEEDED(hr), "Test %u: Failed to create pixel shader, hr %#x.\n", i, hr); + + ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); + } + + if (current_texture != test->texture) + { + if (texture) + ID3D11Texture1D_Release(texture); + if (srv) + ID3D11ShaderResourceView_Release(srv); + + current_texture = test->texture; + + if (current_texture) + { + texture_desc.Width = current_texture->width; + texture_desc.MipLevels = current_texture->miplevel_count; + texture_desc.ArraySize = current_texture->array_size; + texture_desc.Format = current_texture->format; + + hr = ID3D11Device_CreateTexture1D(device, &texture_desc, current_texture->data, &texture); + ok(SUCCEEDED(hr), "Test %u: Failed to create 1d texture, hr %#x.\n", i, hr); + + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, NULL, &srv); + ok(SUCCEEDED(hr), "Test %u: Failed to create shader resource view, hr %#x.\n", i, hr); + } + else + { + texture = NULL; + srv = NULL; + } + + ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv); + } + + if (!sampler || (sampler_desc.Filter != test->filter + || sampler_desc.MipLODBias != test->lod_bias + || sampler_desc.MinLOD != test->min_lod + || sampler_desc.MaxLOD != test->max_lod)) + { + if (sampler) + ID3D11SamplerState_Release(sampler); + + sampler_desc.Filter = test->filter; + sampler_desc.MipLODBias = test->lod_bias; + sampler_desc.MinLOD = test->min_lod; + sampler_desc.MaxLOD = test->max_lod; + + hr = ID3D11Device_CreateSamplerState(device, &sampler_desc, &sampler); + ok(SUCCEEDED(hr), "Test %u: Failed to create sampler state, hr %#x.\n", i, hr); + + ID3D11DeviceContext_PSSetSamplers(context, 0, 1, &sampler); + } + + ps_constant.x = test->ps_constant; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &ps_constant, 0, 0); + + ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red); + + draw_quad(&test_context); + + get_texture_readback(test_context.backbuffer, 0, &rb); + for (x = 0; x < 4; ++x) + { + color = get_readback_color(&rb, 80 + x * 160, 0); + ok(compare_color(color, test->expected_colors[x], 2), + "Test %u: Got unexpected color 0x%08x at (%u).\n", i, color, x); + } + release_resource_readback(&rb); + } + if (srv) + ID3D11ShaderResourceView_Release(srv); + ID3D11SamplerState_Release(sampler); + if (texture) + ID3D11Texture1D_Release(texture); + ID3D11PixelShader_Release(ps); + + if (is_warp_device(device) && feature_level < D3D_FEATURE_LEVEL_11_0) + { + win_skip("SRV tests are broken on WARP.\n"); + ID3D11Buffer_Release(cb); + release_test_context(&test_context); + return; + } + + sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + sampler_desc.MipLODBias = 0.0f; + sampler_desc.MinLOD = 0.0f; + sampler_desc.MaxLOD = D3D11_FLOAT32_MAX; + + hr = ID3D11Device_CreateSamplerState(device, &sampler_desc, &sampler); + ok(SUCCEEDED(hr), "Failed to create sampler state, hr %#x.\n", hr); + + ID3D11DeviceContext_PSSetSamplers(context, 0, 1, &sampler); + + ps = NULL; + srv = NULL; + texture = NULL; + current_ps = NULL; + current_texture = NULL; + for (i = 0; i < ARRAY_SIZE(srv_tests); ++i) + { + const struct srv_test *test = &srv_tests[i]; + + if (current_ps != test->ps) + { + if (ps) + ID3D11PixelShader_Release(ps); + + current_ps = test->ps; + + hr = ID3D11Device_CreatePixelShader(device, current_ps->code, current_ps->size, NULL, &ps); + ok(SUCCEEDED(hr), "Test %u: Failed to create pixel shader, hr %#x.\n", i, hr); + + ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); + } + + if (current_texture != test->texture) + { + if (texture) + ID3D11Texture1D_Release(texture); + + current_texture = test->texture; + + texture_desc.Width = current_texture->width; + texture_desc.MipLevels = current_texture->miplevel_count; + texture_desc.ArraySize = current_texture->array_size; + texture_desc.Format = current_texture->format; + + hr = ID3D11Device_CreateTexture1D(device, &texture_desc, current_texture->data, &texture); + ok(SUCCEEDED(hr), "Test %u: Failed to create 1d texture, hr %#x.\n", i, hr); + } + + if (srv) + ID3D11ShaderResourceView_Release(srv); + + get_srv_desc(&srv_desc, &test->srv_desc); + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, &srv_desc, &srv); + ok(SUCCEEDED(hr), "Test %u: Failed to create shader resource view, hr %#x.\n", i, hr); + + ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv); + + ps_constant.x = test->ps_constant; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &ps_constant, 0, 0); + + ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red); + + draw_quad(&test_context); + + get_texture_readback(test_context.backbuffer, 0, &rb); + for (x = 0; x < 4; ++x) + { + color = get_readback_color(&rb, 80 + x * 160, 0); + ok(compare_color(color, test->expected_colors[x], 1), + "Test %u: Got unexpected color 0x%08x at (%u).\n", i, color, x); + } + release_resource_readback(&rb); + } + ID3D11PixelShader_Release(ps); + ID3D11Texture1D_Release(texture); + ID3D11ShaderResourceView_Release(srv); + ID3D11SamplerState_Release(sampler); + + ID3D11Buffer_Release(cb); + release_test_context(&test_context); +} + static void test_create_texture2d(void) { ULONG refcount, expected_refcount; @@ -24385,6 +25116,8 @@ START_TEST(d3d11) test_create_device(); run_for_each_feature_level(test_device_interfaces); test_get_immediate_context(); + test_create_texture1d(); + test_texture1d_interfaces(); test_create_texture2d(); test_texture2d_interfaces(); test_create_texture3d(); @@ -24409,6 +25142,7 @@ START_TEST(d3d11) test_device_context_state(); test_blend(); test_texture(); + test_texture1d(); test_cube_maps(); test_depth_stencil_sampling(); test_sample_c_lz();
I don't think the series can be committed during the code freeze. However, we can get the patches ready so they can land immediately after the code freeze. Here are some initial comments.
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse shesse@codeweavers.com wrote:
Signed-off-by: Sven Hesse shesse@codeweavers.com
dlls/wined3d/context.c | 6 ++++-- dlls/wined3d/device.c | 4 +++- dlls/wined3d/directx.c | 14 ++++++++++++++ dlls/wined3d/resource.c | 1 + dlls/wined3d/utils.c | 1 + include/wine/wined3d.h | 5 +++-- 6 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 2e12d75213..53f177980d 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -392,10 +392,11 @@ static inline void context_set_fbo_key_for_render_target(const struct wined3d_co struct wined3d_resource *resource = render_target->resource; struct wined3d_texture *texture;
- if (resource && (resource->type == WINED3D_RTYPE_BUFFER || resource->type == WINED3D_RTYPE_TEXTURE_1D))
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
This FIXME() seems to be unnecessary. Does context_set_fbo_key_for_render_target() need special handling for 1D textures?
- if (!resource || resource->format->id == WINED3DFMT_NULL || resource->type == WINED3D_RTYPE_BUFFER) {
if (resource && resource->type == WINED3D_RTYPE_BUFFER)
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); key->objects[idx].object = 0; key->objects[idx].target = 0; key->objects[idx].level = key->objects[idx].layer = 0;
@@ -1017,6 +1018,7 @@ void context_resource_released(const struct wined3d_device *device,