Merge pull request #41 from GloriousEggroll/upstream

fix wined3d-1DTextures, remove deprecated wined3d-GenerateMips
This commit is contained in:
GloriousEggroll 2018-02-19 16:53:42 -05:00 committed by GitHub
commit 209c938af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 144 additions and 512 deletions

View File

@ -437,7 +437,6 @@ patch_enable_all ()
enable_wined3d_DXTn="$1"
enable_wined3d_Dual_Source_Blending="$1"
enable_wined3d_GTX_560M="$1"
enable_wined3d_GenerateMips="$1"
enable_wined3d_Indexed_Vertex_Blending="$1"
enable_wined3d_Limit_Vram="$1"
enable_wined3d_QUERY_Stubs="$1"
@ -1564,9 +1563,6 @@ patch_enable ()
wined3d-GTX_560M)
enable_wined3d_GTX_560M="$2"
;;
wined3d-GenerateMips)
enable_wined3d_GenerateMips="$2"
;;
wined3d-Indexed_Vertex_Blending)
enable_wined3d_Indexed_Vertex_Blending="$2"
;;
@ -2177,9 +2173,6 @@ if test "$enable_wined3d_CSMT_Helper" -eq 1; then
if test "$enable_wined3d_Dual_Source_Blending" -gt 1; then
abort "Patchset wined3d-Dual_Source_Blending disabled, but wined3d-CSMT_Helper depends on that."
fi
if test "$enable_wined3d_GenerateMips" -gt 1; then
abort "Patchset wined3d-GenerateMips disabled, but wined3d-CSMT_Helper depends on that."
fi
if test "$enable_wined3d_QUERY_Stubs" -gt 1; then
abort "Patchset wined3d-QUERY_Stubs disabled, but wined3d-CSMT_Helper depends on that."
fi
@ -2197,19 +2190,11 @@ if test "$enable_wined3d_CSMT_Helper" -eq 1; then
enable_wined3d_Accounting=1
enable_wined3d_DXTn=1
enable_wined3d_Dual_Source_Blending=1
enable_wined3d_GenerateMips=1
enable_wined3d_QUERY_Stubs=1
enable_wined3d_Silence_FIXMEs=1
enable_wined3d_UAV_Counters=1
fi
if test "$enable_wined3d_GenerateMips" -eq 1; then
if test "$enable_wined3d_Dual_Source_Blending" -gt 1; then
abort "Patchset wined3d-Dual_Source_Blending disabled, but wined3d-GenerateMips depends on that."
fi
enable_wined3d_Dual_Source_Blending=1
fi
if test "$enable_wined3d_Dual_Source_Blending" -eq 1; then
if test "$enable_wined3d_Viewports" -gt 1; then
abort "Patchset wined3d-Viewports disabled, but wined3d-Dual_Source_Blending depends on that."
@ -9203,26 +9188,6 @@ if test "$enable_wined3d_Dual_Source_Blending" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-GenerateMips
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * wined3d-Core_Context, wined3d-Viewports, wined3d-Dual_Source_Blending
# |
# | Modified files:
# | * dlls/d3d11/device.c, dlls/d3d11/tests/d3d11.c, dlls/wined3d/cs.c, dlls/wined3d/device.c, dlls/wined3d/texture.c,
# | dlls/wined3d/wined3d.spec, dlls/wined3d/wined3d_private.h, include/wine/wined3d.h
# |
if test "$enable_wined3d_GenerateMips" -eq 1; then
patch_apply wined3d-GenerateMips/0001-d3d11-tests-Add-basic-test-for-mipmap-level-generati.patch
patch_apply wined3d-GenerateMips/0002-wined3d-Implement-generation-of-mip-maps-for-shader-.patch
patch_apply wined3d-GenerateMips/0003-d3d11-Implement-d3d10_device_GenerateMips.patch
(
printf '%s\n' '+ { "Michael Müller", "d3d11/tests: Add basic test for mipmap level generation.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Implement generation of mip maps for shader resource views.", 1 },';
printf '%s\n' '+ { "Michael Müller", "d3d11: Implement d3d10_device_GenerateMips.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-QUERY_Stubs
# |
# | This patchset fixes the following Wine bugs:
@ -9273,7 +9238,7 @@ fi
# | This patchset has the following (direct or indirect) dependencies:
# | * wined3d-1DTextures, d3d11-Deferred_Context, d3d9-Tests, makedep-PARENTSPEC, ntdll-DllOverrides_WOW64, ntdll-
# | Loader_Machine_Type, ntdll-DllRedirects, wined3d-Accounting, wined3d-DXTn, wined3d-Core_Context, wined3d-Viewports,
# | wined3d-Dual_Source_Blending, wined3d-GenerateMips, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs, wined3d-UAV_Counters
# | wined3d-Dual_Source_Blending, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs, wined3d-UAV_Counters
# |
# | Modified files:
# | * configure.ac, dlls/wined3d-csmt/Makefile.in, dlls/wined3d-csmt/version.rc
@ -9436,7 +9401,7 @@ fi
# | This patchset has the following (direct or indirect) dependencies:
# | * wined3d-1DTextures, d3d11-Deferred_Context, d3d9-Tests, makedep-PARENTSPEC, ntdll-DllOverrides_WOW64, ntdll-
# | Loader_Machine_Type, ntdll-DllRedirects, wined3d-Accounting, wined3d-DXTn, wined3d-Core_Context, wined3d-Viewports,
# | wined3d-Dual_Source_Blending, wined3d-GenerateMips, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs, wined3d-UAV_Counters,
# | wined3d-Dual_Source_Blending, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs, wined3d-UAV_Counters,
# | wined3d-CSMT_Helper
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,129 @@
From 16e895f9770039a4d9129d577698c8dcec90334e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 23 Aug 2016 22:54:14 +0200
Subject: wined3d: Create dummy 1d textures.
---
dlls/wined3d/context.c | 12 ++++++++++++
dlls/wined3d/device.c | 26 ++++++++++++++++++++++++++
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 40 insertions(+)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index a423fac2079..65853209864 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1514,6 +1514,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])
@@ -1529,7 +1530,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);
@@ -2411,6 +2415,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 eef9818affd..5b598e2f3a4 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -628,6 +628,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);
@@ -704,6 +715,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);
@@ -751,7 +773,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_2d_array);
+ gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d_array);
+ }
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP_ARRAY])
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_cube_array);
@@ -766,6 +791,7 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d
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_2d);
+ gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d);
checkGLcall("Delete dummy textures");
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cdc240058a2..34d8f18d698 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2666,11 +2666,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;
--
2.11.0

View File

@ -70,7 +70,7 @@ index 2a172ee..f81d7cf 100644
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)
@@ -2063,6 +2102,137 @@ static const struct wined3d_resource_ops texture_resource_ops =
@@ -2022,6 +2399,131 @@ static const struct wined3d_resource_ops texture_resource_ops =
texture_resource_sub_resource_unmap,
};
@ -104,16 +104,16 @@ index 2a172ee..f81d7cf 100644
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (desc->usage & WINED3DUSAGE_DYNAMIC && (desc->pool == WINED3D_POOL_MANAGED
+ || desc->pool == WINED3D_POOL_SCRATCH))
+ if (desc->usage & WINED3DUSAGE_DYNAMIC && wined3d_resource_access_is_managed(desc->access)
+ || desc->usage & WINED3DUSAGE_SCRATCH)
+ {
+ WARN("Attempted to create a DYNAMIC texture in pool %s.\n", debug_d3dpool(desc->pool));
+ WARN("Attempted to create a DYNAMIC texture in pool %s.\n", wined3d_debug_resource_access(desc->access));
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && !is_power_of_two(desc->width))
+ {
+ if (desc->pool == WINED3D_POOL_SCRATCH)
+ if (desc->usage & WINED3DUSAGE_SCRATCH)
+ {
+ WARN("Creating a scratch NPOT 1d texture despite lack of HW support.\n");
+ }
@ -127,15 +127,9 @@ index 2a172ee..f81d7cf 100644
+
+ if (desc->usage & WINED3DUSAGE_QUERY_GENMIPMAP)
+ {
+ if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
+ {
+ WARN("No mipmap generation support, returning WINED3DERR_INVALIDCALL.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (level_count != 1)
+ {
+ WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning WINED3DERR_INVALIDCALL.\n");
+ WARN("WINED3DUSAGE_QUERY_GENMIPMAP is set, and level count != 1, returning WINED3DERR_INVALIDCALL.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+ }
@ -160,7 +154,7 @@ index 2a172ee..f81d7cf 100644
+ }
+
+ if (level_count > ~(SIZE_T)0 / layer_count
+ || !(surfaces = wined3d_calloc(level_count * layer_count, sizeof(*surfaces))))
+ || !(surfaces = heap_calloc(level_count * layer_count, sizeof(*surfaces))))
+ {
+ wined3d_texture_cleanup_sync(texture);
+ return E_OUTOFMEMORY;

View File

@ -55,7 +55,7 @@ index 90c18e8..93b41e9 100644
+ update_w = box->right - box->left;
+ }
+
+ if (format->convert)
+ if (format->upload)
+ {
+ unsigned int dst_row_pitch;
+
@ -67,7 +67,7 @@ index 90c18e8..93b41e9 100644
+ dst_row_pitch = update_w * format->conv_byte_count;
+
+ converted_mem = HeapAlloc(GetProcessHeap(), 0, dst_row_pitch);
+ format->convert(data->addr, converted_mem, row_pitch, slice_pitch, dst_row_pitch, dst_row_pitch, update_w, 1, 1);
+ format->upload(data->addr, converted_mem, row_pitch, slice_pitch, dst_row_pitch, dst_row_pitch, update_w, 1, 1);
+ mem = converted_mem;
+ }
+

View File

@ -33,10 +33,10 @@ index 93b41e9..c5a4f0c 100644
+ return TRUE;
+ }
+
+ if ((texture->resource.access_flags & required_access) != required_access)
+ if ((texture->resource.access & required_access) != required_access)
+ {
+ ERR("Operation requires %#x access, but 1d texture only has %#x.\n",
+ required_access, texture->resource.access_flags);
+ required_access, texture->resource.access);
+ return FALSE;
+ }
+

View File

@ -28,7 +28,7 @@ index c5a4f0c..198d2a6 100644
+
+ sub_resource = &texture->sub_resources[sub_resource_idx];
+
+ if (format->convert)
+ if (format->upload)
+ {
+ FIXME("Attempting to download a converted 1d texture, format %s.\n",
+ debug_d3dformat(format->id));
@ -39,7 +39,7 @@ index c5a4f0c..198d2a6 100644
+ {
+ WARN_(d3d_perf)("Downloading all miplevel layers to get the surface data for a single sub-resource.\n");
+
+ if (!(temporary_mem = wined3d_calloc(texture->layer_count, sub_resource->size)))
+ if (!(temporary_mem = heap_calloc(texture->layer_count, sub_resource->size)))
+ {
+ ERR("Out of memory.\n");
+ return;

View File

@ -1,140 +0,0 @@
From 11060b421e2879d9307be95cba69117d6adf69aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 16 Sep 2017 05:13:04 +0200
Subject: d3d11/tests: Add basic test for mipmap level generation.
---
dlls/d3d11/tests/d3d11.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 3c8ff15d6eb..0dc1c94d883 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -25243,6 +25243,116 @@ static void test_dual_blending(void)
release_test_context(&test_context);
}
+static void test_mipmap_generation(void)
+{
+ D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc;
+ struct d3d11_test_context test_context;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11ShaderResourceView *srv;
+ ID3D11DeviceContext *context;
+ ID3D11Texture2D *texture;
+ ID3D11Device *device;
+ DWORD color[64*64];
+ HRESULT hr;
+ int i;
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ texture_desc.Width = 64;
+ texture_desc.Height = 64;
+ texture_desc.MipLevels = 3;
+ texture_desc.ArraySize = 2;
+ texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ texture_desc.SampleDesc.Count = 1;
+ texture_desc.SampleDesc.Quality = 0;
+ texture_desc.Usage = D3D11_USAGE_DEFAULT;
+ texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+ texture_desc.CPUAccessFlags = 0;
+ texture_desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
+
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+
+ hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, NULL, &srv);
+ ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr);
+
+ for (i = 0; i < texture_desc.Width * texture_desc.Height; i++)
+ color[i] = 0xff00ff00;
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource*)texture, 0, NULL, color, 64 * 4, 64 * 64 * 4);
+
+ for (i = 0; i < texture_desc.Width * texture_desc.Height; i++)
+ color[i] = 0x00ffff00;
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource*)texture, 3, NULL, color, 64 * 4, 64 * 64 * 4);
+
+ check_texture_sub_resource_color(texture, 0, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 1, NULL, 0x00000000, 0);
+ check_texture_sub_resource_color(texture, 2, NULL, 0x00000000, 0);
+ check_texture_sub_resource_color(texture, 3, NULL, 0x00ffff00, 0);
+ check_texture_sub_resource_color(texture, 4, NULL, 0x00000000, 0);
+ check_texture_sub_resource_color(texture, 5, NULL, 0x00000000, 0);
+
+ ID3D11DeviceContext_GenerateMips(context, srv);
+
+ check_texture_sub_resource_color(texture, 0, NULL, 0xff00ff00, 0);
+ todo_wine check_texture_sub_resource_color(texture, 1, NULL, 0xff00ff00, 0);
+ todo_wine check_texture_sub_resource_color(texture, 2, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 3, NULL, 0x00ffff00, 0);
+ todo_wine check_texture_sub_resource_color(texture, 4, NULL, 0x00ffff00, 0);
+ todo_wine check_texture_sub_resource_color(texture, 5, NULL, 0x00ffff00, 0);
+
+ ID3D11ShaderResourceView_Release(srv);
+ ID3D11Texture2D_Release(texture);
+
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+
+ srv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+ srv_desc.Texture2DArray.MostDetailedMip = 1;
+ srv_desc.Texture2DArray.MipLevels = -1;
+ srv_desc.Texture2DArray.FirstArraySlice = 0;
+ srv_desc.Texture2DArray.ArraySize = 1;
+
+ hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, &srv_desc, &srv);
+ ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr);
+
+ for (i = 0; i < texture_desc.Width * texture_desc.Height; i++)
+ color[i] = 0xff00ff00;
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource*)texture, 0, NULL, color, 64 * 4, 64 * 64 * 4);
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource*)texture, 3, NULL, color, 64 * 4, 64 * 64 * 4);
+
+ for (i = 0; i < texture_desc.Width * texture_desc.Height; i++)
+ color[i] = 0xffff0000;
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource*)texture, 1, NULL, color, 32 * 4, 32 * 32 * 4);
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource*)texture, 4, NULL, color, 32 * 4, 32 * 32 * 4);
+
+ check_texture_sub_resource_color(texture, 0, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 1, NULL, 0xffff0000, 0);
+ check_texture_sub_resource_color(texture, 2, NULL, 0x00000000, 0);
+ check_texture_sub_resource_color(texture, 3, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 4, NULL, 0xffff0000, 0);
+ check_texture_sub_resource_color(texture, 5, NULL, 0x00000000, 0);
+
+ ID3D11DeviceContext_GenerateMips(context, srv);
+
+ check_texture_sub_resource_color(texture, 0, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 1, NULL, 0xffff0000, 0);
+ if (!is_warp_device(device)) /* broken on WARP device */
+ todo_wine check_texture_sub_resource_color(texture, 2, NULL, 0xffff0000, 0);
+ check_texture_sub_resource_color(texture, 3, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 4, NULL, 0xffff0000, 0);
+ check_texture_sub_resource_color(texture, 5, NULL, 0x00000000, 0);
+
+ ID3D11ShaderResourceView_Release(srv);
+ ID3D11Texture2D_Release(texture);
+
+ release_test_context(&test_context);
+}
+
START_TEST(d3d11)
{
@@ -25370,6 +25480,7 @@ START_TEST(d3d11)
test_early_depth_stencil();
test_conservative_depth_output();
test_dual_blending();
+ test_mipmap_generation();
test_format_compatibility();
test_clip_distance();
test_combined_clip_and_cull_distances();
--
2.14.2

View File

@ -1,281 +0,0 @@
From ec757263776955ee6ca680109b47eb3bc6163845 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 16 Sep 2017 18:05:31 +0200
Subject: wined3d: Implement generation of mip maps for shader resource views.
---
dlls/d3d11/device.c | 14 ++++++-
dlls/d3d11/tests/d3d11.c | 10 ++---
dlls/wined3d/cs.c | 84 ++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/device.c | 7 ++++
dlls/wined3d/texture.c | 9 ++++-
dlls/wined3d/wined3d.spec | 1 +
dlls/wined3d/wined3d_private.h | 2 +
include/wine/wined3d.h | 1 +
8 files changed, 119 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index f71d4a3e910..bbdc97868db 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2528,14 +2528,18 @@ static void STDMETHODCALLTYPE d3d11_imme
}
static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext *iface,
- ID3D11ShaderResourceView *view)
+ ID3D11ShaderResourceView *shader_view)
{
- struct d3d_shader_resource_view *srv = unsafe_impl_from_ID3D11ShaderResourceView(view);
+ struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface);
+ struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(shader_view);
- TRACE("iface %p, view %p.\n", iface, view);
+ TRACE("iface %p, shader_view %p.\n", iface, shader_view);
+
+ if (!view)
+ return;
wined3d_mutex_lock();
- wined3d_shader_resource_view_generate_mipmaps(srv->wined3d_view);
+ wined3d_device_generate_mips_view(device->wined3d_device, view->wined3d_view);
wined3d_mutex_unlock();
}
static void STDMETHODCALLTYPE d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext *iface,
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 154771f4240..8906b9efa7a 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -22701,11 +22701,11 @@ static void test_mipmap_generation(void)
ID3D11DeviceContext_GenerateMips(context, srv);
check_texture_sub_resource_color(texture, 0, NULL, 0xff00ff00, 0);
- todo_wine check_texture_sub_resource_color(texture, 1, NULL, 0xff00ff00, 0);
- todo_wine check_texture_sub_resource_color(texture, 2, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 1, NULL, 0xff00ff00, 0);
+ check_texture_sub_resource_color(texture, 2, NULL, 0xff00ff00, 0);
check_texture_sub_resource_color(texture, 3, NULL, 0x00ffff00, 0);
- todo_wine check_texture_sub_resource_color(texture, 4, NULL, 0x00ffff00, 0);
- todo_wine check_texture_sub_resource_color(texture, 5, NULL, 0x00ffff00, 0);
+ check_texture_sub_resource_color(texture, 4, NULL, 0x00ffff00, 0);
+ check_texture_sub_resource_color(texture, 5, NULL, 0x00ffff00, 0);
ID3D11ShaderResourceView_Release(srv);
ID3D11Texture2D_Release(texture);
@@ -22745,7 +22745,7 @@ static void test_mipmap_generation(void)
check_texture_sub_resource_color(texture, 0, NULL, 0xff00ff00, 0);
check_texture_sub_resource_color(texture, 1, NULL, 0xffff0000, 0);
if (!is_warp_device(device)) /* broken on WARP device */
- todo_wine check_texture_sub_resource_color(texture, 2, NULL, 0xffff0000, 0);
+ check_texture_sub_resource_color(texture, 2, NULL, 0xffff0000, 0);
check_texture_sub_resource_color(texture, 3, NULL, 0xff00ff00, 0);
check_texture_sub_resource_color(texture, 4, NULL, 0xffff0000, 0);
check_texture_sub_resource_color(texture, 5, NULL, 0x00000000, 0);
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 6b37e9d6f03..70fb19382ea 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -73,6 +73,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW,
WINED3D_CS_OP_COPY_UAV_COUNTER,
WINED3D_CS_OP_GENERATE_MIPMAPS,
+ WINED3D_CS_OP_GENERATE_MIPS,
WINED3D_CS_OP_STOP,
};
@@ -435,6 +436,12 @@ struct wined3d_cs_generate_mipmaps
struct wined3d_shader_resource_view *view;
};
+struct wined3d_cs_generate_mips
+{
+ enum wined3d_cs_op opcode;
+ struct wined3d_shader_resource_view *view;
+};
+
struct wined3d_cs_stop
{
enum wined3d_cs_op opcode;
@@ -2388,6 +2395,82 @@ void wined3d_cs_emit_generate_mipmaps(st
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}
+static void wined3d_cs_exec_generate_mips(struct wined3d_cs *cs, const void *data)
+{
+ const struct wined3d_cs_generate_mips *op = data;
+ struct wined3d_shader_resource_view *view = op->view;
+ struct wined3d_resource *resource = view->resource;
+ const struct wined3d_gl_info *gl_info;
+ struct wined3d_texture *texture;
+ struct wined3d_context *context;
+ GLenum target;
+ int i, j;
+
+ if (resource->type != WINED3D_RTYPE_TEXTURE_1D &&
+ resource->type != WINED3D_RTYPE_TEXTURE_2D &&
+ resource->type != WINED3D_RTYPE_TEXTURE_3D)
+ {
+ FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
+ goto end;
+ }
+
+ texture = texture_from_resource(resource);
+ context = context_acquire(cs->device, NULL, 0);
+ gl_info = context->gl_info;
+
+ for (i = view->desc.u.texture.layer_idx; i < view->desc.u.texture.layer_idx + view->desc.u.texture.layer_count; i++)
+ {
+ wined3d_texture_load_location(texture, i * texture->level_count + view->desc.u.texture.level_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
+ }
+
+ if (view->gl_view.name)
+ {
+ context_bind_texture(context, view->gl_view.target, view->gl_view.name);
+ target = view->gl_view.target;
+ }
+ else
+ {
+ wined3d_texture_bind(texture, context, FALSE);
+ target = texture->target;
+ }
+
+ if (gl_info->fbo_ops.glGenerateMipmap)
+ {
+ gl_info->fbo_ops.glGenerateMipmap(target);
+ checkGLcall("glGenerateMipmap");
+ }
+ else
+ FIXME("Your OpenGL driver does not support glGenerateMipmap.\n");
+
+ for (i = view->desc.u.texture.layer_idx; i < view->desc.u.texture.layer_idx + view->desc.u.texture.layer_count; i++)
+ {
+ for (j = view->desc.u.texture.level_idx + 1; j < view->desc.u.texture.level_idx + view->desc.u.texture.level_count; j++)
+ {
+ wined3d_texture_validate_location(texture, i * texture->level_count + j, WINED3D_LOCATION_TEXTURE_RGB);
+ wined3d_texture_invalidate_location(texture, i * texture->level_count + j, ~WINED3D_LOCATION_TEXTURE_RGB);
+ }
+ }
+
+ wined3d_texture_dirtify(context);
+ context_release(context);
+
+end:
+ wined3d_resource_release(view->resource);
+}
+
+void wined3d_cs_emit_generate_mips(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view)
+{
+ struct wined3d_cs_generate_mips *op;
+
+ op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
+ op->opcode = WINED3D_CS_OP_GENERATE_MIPS;
+ op->view = view;
+
+ wined3d_resource_acquire(view->resource);
+
+ cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
+}
+
static void wined3d_cs_emit_stop(struct wined3d_cs *cs)
{
struct wined3d_cs_stop *op;
@@ -2448,6 +2531,7 @@ static void (* const wined3d_cs_op_handl
/* WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_clear_unordered_access_view,
/* WINED3D_CS_OP_COPY_UAV_COUNTER */ wined3d_cs_exec_copy_uav_counter,
/* WINED3D_CS_OP_GENERATE_MIPMAPS */ wined3d_cs_exec_generate_mipmaps,
+ /* WINED3D_CS_OP_GENERATE_MIPS */ wined3d_cs_exec_generate_mips,
};
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1194513879c..bf17029b89e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4363,6 +4363,13 @@ void CDECL wined3d_device_resolve_sub_re
src_texture, src_sub_resource_idx, &src_rect, 0, NULL, WINED3D_TEXF_POINT);
}
+void CDECL wined3d_device_generate_mips_view(struct wined3d_device *device, struct wined3d_shader_resource_view *view)
+{
+ TRACE("device %p, view %p.\n", device, view);
+
+ wined3d_cs_emit_generate_mips(device->cs, view);
+}
+
HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *view, const RECT *rect, DWORD flags,
const struct wined3d_color *color, float depth, DWORD stencil)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 14f5c4ecc7a..c91d40d18a9 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -765,8 +765,7 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
}
/* Context activation is done by the caller. */
-void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
- struct wined3d_context *context, BOOL srgb)
+void wined3d_texture_dirtify(struct wined3d_context *context)
{
/* We don't need a specific texture unit, but after binding the texture
* the current unit is dirty. Read the unit back instead of switching to
@@ -787,7 +786,13 @@ void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
* a shader. */
context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
+}
+/* Context activation is done by the caller. */
+void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
+ struct wined3d_context *context, BOOL srgb)
+{
+ wined3d_texture_dirtify(context);
wined3d_texture_bind(texture, context, srgb);
}
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index e4d5f2ed9ac..22c76a49281 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -55,6 +55,7 @@
@ cdecl wined3d_device_end_scene(ptr)
@ cdecl wined3d_device_end_stateblock(ptr ptr)
@ cdecl wined3d_device_evict_managed_resources(ptr)
+@ cdecl wined3d_device_generate_mips_view(ptr ptr)
@ cdecl wined3d_device_get_available_texture_mem(ptr)
@ cdecl wined3d_device_get_base_vertex_index(ptr)
@ cdecl wined3d_device_get_blend_state(ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 81628d21e8f..4960b513931 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3234,6 +3234,7 @@ void wined3d_texture_bind(struct wined3d
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
+void wined3d_texture_dirtify(struct wined3d_context *context) DECLSPEC_HIDDEN;
HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
@@ -3612,6 +3613,7 @@ void wined3d_cs_emit_unload_resource(str
void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
unsigned int slice_pitch) DECLSPEC_HIDDEN;
+void wined3d_cs_emit_generate_mips(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
void wined3d_cs_init_object(struct wined3d_cs *cs,
void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx,
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 37aee84308f..961762d2cf0 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2465,6 +2465,7 @@ void __cdecl wined3d_device_update_sub_resource(struct wined3d_device *device, s
HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture);
HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
+void CDECL wined3d_device_generate_mips_view(struct wined3d_device *device, struct wined3d_shader_resource_view *view);
HRESULT __cdecl wined3d_palette_create(struct wined3d_device *device, DWORD flags,
unsigned int entry_count, const PALETTEENTRY *entries, struct wined3d_palette **palette);
--
2.14.1

View File

@ -1,33 +0,0 @@
From 2f249a6a8c5906813d05470df61928d43eb289c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 20 Sep 2017 21:33:30 +0200
Subject: d3d11: Implement d3d10_device_GenerateMips.
---
dlls/d3d11/device.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 22adf361feb..d389c2625a0 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -4251,12 +4251,16 @@ static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *
static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
ID3D10ShaderResourceView *view)
{
+ struct d3d_device *device = impl_from_ID3D10Device(iface);
struct d3d_shader_resource_view *srv = unsafe_impl_from_ID3D10ShaderResourceView(view);
TRACE("iface %p, view %p.\n", iface, view);
+ if (!srv)
+ return;
+
wined3d_mutex_lock();
- wined3d_shader_resource_view_generate_mipmaps(srv->wined3d_view);
+ wined3d_device_generate_mips_view(device->wined3d_device, srv->wined3d_view);
wined3d_mutex_unlock();
}
--
2.14.1

View File

@ -1,2 +0,0 @@
Fixes: Support for GenerateMips
Depends: wined3d-Dual_Source_Blending