Wine-Devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
October 2018
- 60 participants
- 608 discussions
[PATCH] mshtml: Support retrieving command output in Exec(OLECMDID_OPTICAL_ZOOM).
by Piotr Caban Oct. 3, 2018
by Piotr Caban Oct. 3, 2018
Oct. 3, 2018
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/mshtml/mshtml_private.h | 1 +
dlls/mshtml/nsembed.c | 23 +++++++++++++++++++++++
dlls/mshtml/olecmd.c | 9 +++++++--
dlls/mshtml/tests/htmldoc.c | 16 ++++++++++++++--
4 files changed, 45 insertions(+), 4 deletions(-)
2
1
[v2 PATCH 1/4] include: Add ID2D1CommandList and ID2D1CommandSink definition.
by Nikolay Sivov Oct. 3, 2018
by Nikolay Sivov Oct. 3, 2018
Oct. 3, 2018
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
include/d2d1_1.idl | 124 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 123 insertions(+), 1 deletion(-)
diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl
index c6cd9c7398..4a644ffd4c 100644
--- a/include/d2d1_1.idl
+++ b/include/d2d1_1.idl
@@ -32,7 +32,6 @@ interface ID2D1Effect;
interface ID2D1GradientStopCollection1;
interface ID2D1ImageBrush;
interface ID2D1BitmapBrush1;
-interface ID2D1CommandList;
cpp_quote("#ifndef __dwrite_h__")
/* already defined in dwrite.h but needed for WIDL */
@@ -429,6 +428,129 @@ interface ID2D1Device : ID2D1Resource
);
}
+[
+ object,
+ uuid(54d7898a-a061-40a7-bec7-e465bcba2c4f),
+ local,
+]
+interface ID2D1CommandSink : IUnknown
+{
+ HRESULT BeginDraw();
+ HRESULT EndDraw();
+ HRESULT SetAntialiasMode(
+ [in] D2D1_ANTIALIAS_MODE antialias_mode
+ );
+ HRESULT SetTags(
+ [in] D2D1_TAG tag1,
+ [in] D2D1_TAG tag2
+ );
+ HRESULT SetTextAntialiasMode(
+ [in] D2D1_TEXT_ANTIALIAS_MODE antialias_mode
+ );
+ HRESULT SetTextRenderingParams(
+ [in] IDWriteRenderingParams *text_rendering_params
+ );
+ HRESULT SetTransform(
+ [in] D2D1_MATRIX_3X2_F *transform
+ );
+ HRESULT SetPrimitiveBlend(
+ [in] D2D1_PRIMITIVE_BLEND primitive_blend
+ );
+ HRESULT SetUnitMode(
+ [in] D2D1_UNIT_MODE unit_mode
+ );
+ HRESULT Clear(
+ [in] const D2D1_COLOR_F *color
+ );
+ HRESULT DrawGlyphRun(
+ [in] D2D1_POINT_2F baseline_origin,
+ [in] const DWRITE_GLYPH_RUN *glyph_run,
+ [in] const DWRITE_GLYPH_RUN_DESCRIPTION *glyph_run_desc,
+ [in] ID2D1Brush *brush,
+ [in] DWRITE_MEASURING_MODE measuring_mode
+ );
+ HRESULT DrawLine(
+ [in] D2D1_POINT_2F p0,
+ [in] D2D1_POINT_2F p1,
+ [in] ID2D1Brush *brush,
+ [in] float stroke_width,
+ [in] ID2D1StrokeStyle *stroke_style
+ );
+ HRESULT DrawGeometry(
+ [in] ID2D1Geometry *geometry,
+ [in] ID2D1Brush *brush,
+ [in] float stroke_width,
+ [in] ID2D1StrokeStyle *stroke_style
+ );
+ HRESULT DrawRectangle(
+ [in] const D2D1_RECT_F *rect,
+ [in] ID2D1Brush *brush,
+ [in] float stroke_width,
+ [in] ID2D1StrokeStyle *stroke_style
+ );
+ HRESULT DrawBitmap(
+ [in] ID2D1Bitmap *bitmap,
+ [in] const D2D1_RECT_F *dst_rect,
+ [in] float opacity,
+ [in] D2D1_INTERPOLATION_MODE interpolation_mode,
+ [in] const D2D1_RECT_F *src_rect,
+ [in] const D2D1_MATRIX_4X4_F *perspective_transform
+ );
+ HRESULT DrawImage(
+ [in] ID2D1Image *image,
+ [in] const D2D1_POINT_2F *target_offset,
+ [in] const D2D1_POINT_2F *image_rect,
+ [in] D2D1_INTERPOLATION_MODE interpolation_mode,
+ [in] D2D1_COMPOSITE_MODE composite_mode
+ );
+ HRESULT DrawGdiMetafile(
+ [in] ID2D1GdiMetafile *metafile,
+ [in] const D2D1_POINT_2F *target_offset
+ );
+ HRESULT FillMesh(
+ [in] ID2D1Mesh *mesh,
+ [in] ID2D1Brush *brush
+ );
+ HRESULT FillOpacityMask(
+ [in] ID2D1Bitmap *bitmap,
+ [in] ID2D1Brush *brush,
+ [in] const D2D1_RECT_F *dst_rect,
+ [in] const D2D1_RECT_F *src_rect
+ );
+ HRESULT FillGeometry(
+ [in] ID2D1Geometry *geometry,
+ [in] ID2D1Brush *brush,
+ [in] ID2D1Brush *opacity_brush
+ );
+ HRESULT FillRectangle(
+ [in] const D2D1_RECT_F *rect,
+ [in] ID2D1Brush *brush
+ );
+ HRESULT PushAxisAlignedClip(
+ [in] const D2D1_RECT_F *clip_rect,
+ [in] D2D1_ANTIALIAS_MODE antialias_mode
+ );
+ HRESULT PushLayer(
+ [in] const D2D1_LAYER_PARAMETERS1 *layer_parameters,
+ [in] ID2D1Layer *layer
+ );
+ HRESULT PopAxisAlignedClip();
+ HRESULT PopLayer();
+}
+
+[
+ object,
+ uuid(b4f34a19-2383-4d76-94f6-ec343657c3dc),
+ local,
+]
+interface ID2D1CommandList : ID2D1Image
+{
+ HRESULT Stream(
+ [in] ID2D1CommandSink *sink
+ );
+ HRESULT Close();
+}
+
[
object,
uuid(e8f7fe7a-191c-466d-ad95-975678bda998),
--
2.19.0
3
8
Signed-off-by: Andrew Wesie <awesie(a)gmail.com>
---
dlls/wined3d/surface.c | 233 +-------------------------
dlls/wined3d/texture.c | 359 +++++++++++++++++++++++++++++++++--------
dlls/wined3d/wined3d_private.h | 2 +
3 files changed, 295 insertions(+), 299 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 8b69720..4942177 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -342,235 +342,6 @@ static BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct win
return TRUE;
}
-/* This call just downloads data, the caller is responsible for binding the
- * correct texture. */
-/* Context activation is done by the caller. */
-static void texture2d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- const struct wined3d_context *context, DWORD dst_location)
-{
- const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_texture_sub_resource *sub_resource;
- unsigned int dst_row_pitch, dst_slice_pitch;
- unsigned int src_row_pitch, src_slice_pitch;
- const struct wined3d_format_gl *format_gl;
- struct wined3d_bo_address data;
- BYTE *temporary_mem = NULL;
- unsigned int level;
- GLenum target;
- void *mem;
-
- format_gl = wined3d_format_gl(texture->resource.format);
-
- /* Only support read back of converted P8 textures. */
- if (texture->flags & WINED3D_TEXTURE_CONVERTED && format_gl->f.id != WINED3DFMT_P8_UINT && !format_gl->f.download)
- {
- ERR("Trying to read back converted texture %p, %u with format %s.\n",
- texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
- return;
- }
-
- sub_resource = &texture->sub_resources[sub_resource_idx];
- target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx);
- level = sub_resource_idx % texture->level_count;
-
- if (target == GL_TEXTURE_2D_ARRAY)
- {
- if (format_gl->f.download)
- {
- FIXME("Reading back converted array texture %p is not supported.\n", texture);
- return;
- }
-
- /* NP2 emulation is not allowed on array textures. */
- if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
- ERR("Array texture %p uses NP2 emulation.\n", texture);
-
- WARN_(d3d_perf)("Downloading all miplevel layers to get the data for a single sub-resource.\n");
-
- if (!(temporary_mem = heap_calloc(texture->layer_count, sub_resource->size)))
- {
- ERR("Out of memory.\n");
- return;
- }
- }
-
- wined3d_texture_get_memory(texture, sub_resource_idx, &data, dst_location);
-
- if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
- {
- if (format_gl->f.download)
- {
- FIXME("Reading back converted texture %p with NP2 emulation is not supported.\n", texture);
- return;
- }
-
- wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
- wined3d_format_calculate_pitch(&format_gl->f, texture->resource.device->surface_alignment,
- wined3d_texture_get_level_pow2_width(texture, level),
- wined3d_texture_get_level_pow2_height(texture, level),
- &src_row_pitch, &src_slice_pitch);
- if (!(temporary_mem = heap_alloc(src_slice_pitch)))
- {
- ERR("Out of memory.\n");
- return;
- }
-
- if (data.buffer_object)
- ERR("NP2 emulated texture uses PBO unexpectedly.\n");
- if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
- ERR("Unexpected compressed format for NP2 emulated texture.\n");
- }
-
- if (format_gl->f.download)
- {
- struct wined3d_format f;
-
- if (data.buffer_object)
- ERR("Converted texture %p uses PBO unexpectedly.\n", texture);
-
- WARN_(d3d_perf)("Downloading converted texture %p, %u with format %s.\n",
- texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
-
- f = format_gl->f;
- f.byte_count = format_gl->f.conv_byte_count;
- wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
- wined3d_format_calculate_pitch(&f, texture->resource.device->surface_alignment,
- wined3d_texture_get_level_width(texture, level),
- wined3d_texture_get_level_height(texture, level),
- &src_row_pitch, &src_slice_pitch);
-
- if (!(temporary_mem = heap_alloc(src_slice_pitch)))
- {
- ERR("Failed to allocate memory.\n");
- return;
- }
- }
-
- if (temporary_mem)
- {
- mem = temporary_mem;
- }
- else if (data.buffer_object)
- {
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data.buffer_object));
- checkGLcall("glBindBuffer");
- mem = data.addr;
- }
- else
- {
- mem = data.addr;
- }
-
- if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
- {
- TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
-
- GL_EXTCALL(glGetCompressedTexImage(target, level, mem));
- checkGLcall("glGetCompressedTexImage");
- }
- else
- {
- TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
-
- gl_info->gl_ops.gl.p_glGetTexImage(target, level, format_gl->format, format_gl->type, mem);
- checkGLcall("glGetTexImage");
- }
-
- if (format_gl->f.download)
- {
- format_gl->f.download(mem, data.addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
- wined3d_texture_get_level_width(texture, level),
- wined3d_texture_get_level_height(texture, level), 1);
- }
- else if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
- {
- const BYTE *src_data;
- unsigned int h, y;
- BYTE *dst_data;
- /*
- * Some games (e.g. warhammer 40k) don't work properly with the odd pitches, preventing
- * the surface pitch from being used to box non-power2 textures. Instead we have to use a hack to
- * repack the texture so that the bpp * width pitch can be used instead of bpp * pow2width.
- *
- * We're doing this...
- *
- * instead of boxing the texture :
- * |<-texture width ->| -->pow2width| /\
- * |111111111111111111| | |
- * |222 Texture 222222| boxed empty | texture height
- * |3333 Data 33333333| | |
- * |444444444444444444| | \/
- * ----------------------------------- |
- * | boxed empty | boxed empty | pow2height
- * | | | \/
- * -----------------------------------
- *
- *
- * we're repacking the data to the expected texture width
- *
- * |<-texture width ->| -->pow2width| /\
- * |111111111111111111222222222222222| |
- * |222333333333333333333444444444444| texture height
- * |444444 | |
- * | | \/
- * | | |
- * | empty | pow2height
- * | | \/
- * -----------------------------------
- *
- * == is the same as
- *
- * |<-texture width ->| /\
- * |111111111111111111|
- * |222222222222222222|texture height
- * |333333333333333333|
- * |444444444444444444| \/
- * --------------------
- *
- * This also means that any references to surface memory should work with the data as if it were a
- * standard texture with a non-power2 width instead of a texture boxed up to be a power2 texture.
- *
- * internally the texture is still stored in a boxed format so any references to textureName will
- * get a boxed texture with width pow2width and not a texture of width resource.width. */
- src_data = mem;
- dst_data = data.addr;
- TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
- h = wined3d_texture_get_level_height(texture, level);
- for (y = 0; y < h; ++y)
- {
- memcpy(dst_data, src_data, dst_row_pitch);
- src_data += src_row_pitch;
- dst_data += dst_row_pitch;
- }
- }
- else if (temporary_mem)
- {
- unsigned int layer = sub_resource_idx / texture->level_count;
- void *src_data = temporary_mem + layer * sub_resource->size;
- if (data.buffer_object)
- {
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data.buffer_object));
- checkGLcall("glBindBuffer");
- GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER, 0, sub_resource->size, src_data));
- checkGLcall("glBufferSubData");
- }
- else
- {
- memcpy(data.addr, src_data, sub_resource->size);
- }
- }
-
- if (data.buffer_object)
- {
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
- checkGLcall("glBindBuffer");
- }
-
- heap_free(temporary_mem);
-}
-
/* See also float_16_to_32() in wined3d_private.h */
static inline unsigned short float_32_to_16(const float *in)
{
@@ -1666,9 +1437,11 @@ BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_res
/* Download the sub-resource to system memory. */
if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
{
+ struct wined3d_bo_address data;
wined3d_texture_bind_and_dirtify(texture, context,
!(sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB));
- texture2d_download_data(texture, sub_resource_idx, context, dst_location);
+ wined3d_texture_get_memory(texture, sub_resource_idx, &data, dst_location);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
++texture->download_count;
return TRUE;
}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 9589e49..29bbdd7 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2136,6 +2136,291 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
}
}
+static void texture2d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, const struct wined3d_bo_address *data)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ struct wined3d_texture_sub_resource *sub_resource;
+ unsigned int dst_row_pitch, dst_slice_pitch;
+ unsigned int src_row_pitch, src_slice_pitch;
+ const struct wined3d_format_gl *format_gl;
+ BYTE *temporary_mem = NULL;
+ unsigned int level;
+ GLenum target;
+ void *mem;
+
+ format_gl = wined3d_format_gl(texture->resource.format);
+
+ /* Only support read back of converted P8 textures. */
+ if (texture->flags & WINED3D_TEXTURE_CONVERTED && format_gl->f.id != WINED3DFMT_P8_UINT && !format_gl->f.download)
+ {
+ ERR("Trying to read back converted texture %p, %u with format %s.\n",
+ texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
+ return;
+ }
+
+ sub_resource = &texture->sub_resources[sub_resource_idx];
+ target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx);
+ level = sub_resource_idx % texture->level_count;
+
+ if (target == GL_TEXTURE_2D_ARRAY)
+ {
+ if (format_gl->f.download)
+ {
+ FIXME("Reading back converted array texture %p is not supported.\n", texture);
+ return;
+ }
+
+ /* NP2 emulation is not allowed on array textures. */
+ if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+ ERR("Array texture %p uses NP2 emulation.\n", texture);
+
+ WARN_(d3d_perf)("Downloading all miplevel layers to get the data for a single sub-resource.\n");
+
+ if (!(temporary_mem = heap_calloc(texture->layer_count, sub_resource->size)))
+ {
+ ERR("Out of memory.\n");
+ return;
+ }
+ }
+
+ if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+ {
+ if (format_gl->f.download)
+ {
+ FIXME("Reading back converted texture %p with NP2 emulation is not supported.\n", texture);
+ return;
+ }
+
+ wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
+ wined3d_format_calculate_pitch(&format_gl->f, texture->resource.device->surface_alignment,
+ wined3d_texture_get_level_pow2_width(texture, level),
+ wined3d_texture_get_level_pow2_height(texture, level),
+ &src_row_pitch, &src_slice_pitch);
+ if (!(temporary_mem = heap_alloc(src_slice_pitch)))
+ {
+ ERR("Out of memory.\n");
+ return;
+ }
+
+ if (data->buffer_object)
+ ERR("NP2 emulated texture uses PBO unexpectedly.\n");
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+ ERR("Unexpected compressed format for NP2 emulated texture.\n");
+ }
+
+ if (format_gl->f.download)
+ {
+ struct wined3d_format f;
+
+ if (data->buffer_object)
+ ERR("Converted texture %p uses PBO unexpectedly.\n", texture);
+
+ WARN_(d3d_perf)("Downloading converted texture %p, %u with format %s.\n",
+ texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
+
+ f = format_gl->f;
+ f.byte_count = format_gl->f.conv_byte_count;
+ wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
+ wined3d_format_calculate_pitch(&f, texture->resource.device->surface_alignment,
+ wined3d_texture_get_level_width(texture, level),
+ wined3d_texture_get_level_height(texture, level),
+ &src_row_pitch, &src_slice_pitch);
+
+ if (!(temporary_mem = heap_alloc(src_slice_pitch)))
+ {
+ ERR("Failed to allocate memory.\n");
+ return;
+ }
+ }
+
+ if (temporary_mem)
+ {
+ mem = temporary_mem;
+ }
+ else if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
+ checkGLcall("glBindBuffer");
+ mem = data->addr;
+ }
+ else
+ {
+ mem = data->addr;
+ }
+
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+ {
+ TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
+
+ GL_EXTCALL(glGetCompressedTexImage(target, level, mem));
+ checkGLcall("glGetCompressedTexImage");
+ }
+ else
+ {
+ TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
+
+ gl_info->gl_ops.gl.p_glGetTexImage(target, level, format_gl->format, format_gl->type, mem);
+ checkGLcall("glGetTexImage");
+ }
+
+ if (format_gl->f.download)
+ {
+ format_gl->f.download(mem, data->addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
+ wined3d_texture_get_level_width(texture, level),
+ wined3d_texture_get_level_height(texture, level), 1);
+ }
+ else if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+ {
+ const BYTE *src_data;
+ unsigned int h, y;
+ BYTE *dst_data;
+ /*
+ * Some games (e.g. warhammer 40k) don't work properly with the odd pitches, preventing
+ * the surface pitch from being used to box non-power2 textures. Instead we have to use a hack to
+ * repack the texture so that the bpp * width pitch can be used instead of bpp * pow2width.
+ *
+ * We're doing this...
+ *
+ * instead of boxing the texture :
+ * |<-texture width ->| -->pow2width| /\
+ * |111111111111111111| | |
+ * |222 Texture 222222| boxed empty | texture height
+ * |3333 Data 33333333| | |
+ * |444444444444444444| | \/
+ * ----------------------------------- |
+ * | boxed empty | boxed empty | pow2height
+ * | | | \/
+ * -----------------------------------
+ *
+ *
+ * we're repacking the data to the expected texture width
+ *
+ * |<-texture width ->| -->pow2width| /\
+ * |111111111111111111222222222222222| |
+ * |222333333333333333333444444444444| texture height
+ * |444444 | |
+ * | | \/
+ * | | |
+ * | empty | pow2height
+ * | | \/
+ * -----------------------------------
+ *
+ * == is the same as
+ *
+ * |<-texture width ->| /\
+ * |111111111111111111|
+ * |222222222222222222|texture height
+ * |333333333333333333|
+ * |444444444444444444| \/
+ * --------------------
+ *
+ * This also means that any references to surface memory should work with the data as if it were a
+ * standard texture with a non-power2 width instead of a texture boxed up to be a power2 texture.
+ *
+ * internally the texture is still stored in a boxed format so any references to textureName will
+ * get a boxed texture with width pow2width and not a texture of width resource.width. */
+ src_data = mem;
+ dst_data = data->addr;
+ TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
+ h = wined3d_texture_get_level_height(texture, level);
+ for (y = 0; y < h; ++y)
+ {
+ memcpy(dst_data, src_data, dst_row_pitch);
+ src_data += src_row_pitch;
+ dst_data += dst_row_pitch;
+ }
+ }
+ else if (temporary_mem)
+ {
+ unsigned int layer = sub_resource_idx / texture->level_count;
+ void *src_data = temporary_mem + layer * sub_resource->size;
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
+ checkGLcall("glBindBuffer");
+ GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER, 0, sub_resource->size, src_data));
+ checkGLcall("glBufferSubData");
+ }
+ else
+ {
+ memcpy(data->addr, src_data, sub_resource->size);
+ }
+ }
+
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
+ checkGLcall("glBindBuffer");
+ }
+
+ heap_free(temporary_mem);
+}
+
+/* This call just downloads data, the caller is responsible for binding the
+ * correct texture. Partial downloads are not supported. */
+/* Context activation is done by the caller. */
+void wined3d_texture_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, const struct wined3d_bo_address *data)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_format_gl *format_gl;
+ unsigned int level;
+ GLenum target;
+
+ format_gl = wined3d_format_gl(texture->resource.format);
+ target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx);
+ level = sub_resource_idx % texture->level_count;
+
+ if (texture->resource.type == WINED3D_RTYPE_TEXTURE_2D
+ && (target == GL_TEXTURE_2D_ARRAY || format_gl->f.conv_byte_count
+ || texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED))
+ {
+ /* 2D-specific special cases. */
+ texture2d_download_data(texture, sub_resource_idx, context, data);
+ return;
+ }
+
+ if (format_gl->f.conv_byte_count)
+ {
+ FIXME("Attempting to download a converted texture, type %s format %s.\n",
+ debug_d3dresourcetype(texture->resource.type),
+ debug_d3dformat(format_gl->f.id));
+ return;
+ }
+
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
+ checkGLcall("glBindBuffer");
+ }
+
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+ {
+ TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, data->addr);
+
+ GL_EXTCALL(glGetCompressedTexImage(target, level, data->addr));
+ checkGLcall("glGetCompressedTexImage");
+ }
+ else
+ {
+ TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, data->addr);
+
+ gl_info->gl_ops.gl.p_glGetTexImage(target, level, format_gl->format, format_gl->type, 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. Context may be NULL in ddraw-only mode. */
static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location)
@@ -2441,38 +2726,6 @@ static const struct wined3d_resource_ops texture_resource_ops =
};
/* 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_gl_info *gl_info = context->gl_info;
- const struct wined3d_format_gl *format_gl;
-
- format_gl = wined3d_format_gl(texture->resource.format);
- if (format_gl->f.conv_byte_count)
- {
- FIXME("Attempting to download a converted texture, format %s.\n",
- debug_d3dformat(format_gl->f.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(texture->target, sub_resource_idx,
- format_gl->format, format_gl->type, 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 BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location)
{
@@ -2532,7 +2785,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture1d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
++texture->download_count;
}
else
@@ -2553,7 +2806,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture1d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
}
else
{
@@ -2914,38 +3167,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
}
/* Context activation is done by the caller. */
-static void texture3d_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_gl_info *gl_info = context->gl_info;
- const struct wined3d_format_gl *format_gl;
-
- format_gl = wined3d_format_gl(texture->resource.format);
- if (format_gl->f.conv_byte_count)
- {
- FIXME("Attempting to download a converted volume, format %s.\n",
- debug_d3dformat(format_gl->f.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_3D, sub_resource_idx,
- format_gl->format, format_gl->type, 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 texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, BOOL dest_is_srgb)
{
@@ -2968,7 +3189,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box);
wined3d_texture_bind_and_dirtify(texture, context, !dest_is_srgb);
- texture3d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb);
wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format,
&src_box, wined3d_const_bo_address(&data), row_pitch, slice_pitch, 0, 0, 0, FALSE);
@@ -3041,7 +3262,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture3d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
++texture->download_count;
}
else
@@ -3062,7 +3283,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture3d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
}
else
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8cfa4c3..7d35e55 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3348,6 +3348,8 @@ void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
+void wined3d_texture_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, const struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
--
2.7.4
3
8
fix https://bugs.winehq.org/show_bug.cgi?id=45928
Signed-off-by: Louis Lenders <xerox.xerox2000x(a)gmail.com>
---
dlls/ucrtbase/Makefile.in | 2 ++
dlls/ucrtbase/version.rc | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 dlls/ucrtbase/version.rc
diff --git a/dlls/ucrtbase/Makefile.in b/dlls/ucrtbase/Makefile.in
index d44b17a2dd..23d8292a53 100644
--- a/dlls/ucrtbase/Makefile.in
+++ b/dlls/ucrtbase/Makefile.in
@@ -33,3 +33,5 @@ C_SRCS = \
time.c \
undname.c \
wcs.c
+
+RC_SRCS = version.rc
diff --git a/dlls/ucrtbase/version.rc b/dlls/ucrtbase/version.rc
new file mode 100644
index 0000000000..f034bc39ef
--- /dev/null
+++ b/dlls/ucrtbase/version.rc
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018 Louis Lenders
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine runtime library"
+#define WINE_FILENAME_STR "ucrtbase.dll"
+#define WINE_FILEVERSION 10,0,14393,2247
+#define WINE_FILEVERSION_STR "10.0.14393.2247"
+#define WINE_PRODUCTVERSION 10,0,14393,2247
+#define WINE_PRODUCTVERSION_STR "10.0.14393.2247"
+
+#include "wine/wine_common_ver.rc"
--
2.17.1
2
1
From: Andrew Wesie <awesie(a)gmail.com>
Signed-off-by: Andrew Wesie <awesie(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/surface.c | 233 +-------------------------
dlls/wined3d/texture.c | 363 +++++++++++++++++++++++++++++++++--------
dlls/wined3d/wined3d_private.h | 2 +
3 files changed, 299 insertions(+), 299 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 8b69720693e..494217726a5 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -342,235 +342,6 @@ static BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct win
return TRUE;
}
-/* This call just downloads data, the caller is responsible for binding the
- * correct texture. */
-/* Context activation is done by the caller. */
-static void texture2d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
- const struct wined3d_context *context, DWORD dst_location)
-{
- const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_texture_sub_resource *sub_resource;
- unsigned int dst_row_pitch, dst_slice_pitch;
- unsigned int src_row_pitch, src_slice_pitch;
- const struct wined3d_format_gl *format_gl;
- struct wined3d_bo_address data;
- BYTE *temporary_mem = NULL;
- unsigned int level;
- GLenum target;
- void *mem;
-
- format_gl = wined3d_format_gl(texture->resource.format);
-
- /* Only support read back of converted P8 textures. */
- if (texture->flags & WINED3D_TEXTURE_CONVERTED && format_gl->f.id != WINED3DFMT_P8_UINT && !format_gl->f.download)
- {
- ERR("Trying to read back converted texture %p, %u with format %s.\n",
- texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
- return;
- }
-
- sub_resource = &texture->sub_resources[sub_resource_idx];
- target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx);
- level = sub_resource_idx % texture->level_count;
-
- if (target == GL_TEXTURE_2D_ARRAY)
- {
- if (format_gl->f.download)
- {
- FIXME("Reading back converted array texture %p is not supported.\n", texture);
- return;
- }
-
- /* NP2 emulation is not allowed on array textures. */
- if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
- ERR("Array texture %p uses NP2 emulation.\n", texture);
-
- WARN_(d3d_perf)("Downloading all miplevel layers to get the data for a single sub-resource.\n");
-
- if (!(temporary_mem = heap_calloc(texture->layer_count, sub_resource->size)))
- {
- ERR("Out of memory.\n");
- return;
- }
- }
-
- wined3d_texture_get_memory(texture, sub_resource_idx, &data, dst_location);
-
- if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
- {
- if (format_gl->f.download)
- {
- FIXME("Reading back converted texture %p with NP2 emulation is not supported.\n", texture);
- return;
- }
-
- wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
- wined3d_format_calculate_pitch(&format_gl->f, texture->resource.device->surface_alignment,
- wined3d_texture_get_level_pow2_width(texture, level),
- wined3d_texture_get_level_pow2_height(texture, level),
- &src_row_pitch, &src_slice_pitch);
- if (!(temporary_mem = heap_alloc(src_slice_pitch)))
- {
- ERR("Out of memory.\n");
- return;
- }
-
- if (data.buffer_object)
- ERR("NP2 emulated texture uses PBO unexpectedly.\n");
- if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
- ERR("Unexpected compressed format for NP2 emulated texture.\n");
- }
-
- if (format_gl->f.download)
- {
- struct wined3d_format f;
-
- if (data.buffer_object)
- ERR("Converted texture %p uses PBO unexpectedly.\n", texture);
-
- WARN_(d3d_perf)("Downloading converted texture %p, %u with format %s.\n",
- texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
-
- f = format_gl->f;
- f.byte_count = format_gl->f.conv_byte_count;
- wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
- wined3d_format_calculate_pitch(&f, texture->resource.device->surface_alignment,
- wined3d_texture_get_level_width(texture, level),
- wined3d_texture_get_level_height(texture, level),
- &src_row_pitch, &src_slice_pitch);
-
- if (!(temporary_mem = heap_alloc(src_slice_pitch)))
- {
- ERR("Failed to allocate memory.\n");
- return;
- }
- }
-
- if (temporary_mem)
- {
- mem = temporary_mem;
- }
- else if (data.buffer_object)
- {
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data.buffer_object));
- checkGLcall("glBindBuffer");
- mem = data.addr;
- }
- else
- {
- mem = data.addr;
- }
-
- if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
- {
- TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
-
- GL_EXTCALL(glGetCompressedTexImage(target, level, mem));
- checkGLcall("glGetCompressedTexImage");
- }
- else
- {
- TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
-
- gl_info->gl_ops.gl.p_glGetTexImage(target, level, format_gl->format, format_gl->type, mem);
- checkGLcall("glGetTexImage");
- }
-
- if (format_gl->f.download)
- {
- format_gl->f.download(mem, data.addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
- wined3d_texture_get_level_width(texture, level),
- wined3d_texture_get_level_height(texture, level), 1);
- }
- else if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
- {
- const BYTE *src_data;
- unsigned int h, y;
- BYTE *dst_data;
- /*
- * Some games (e.g. warhammer 40k) don't work properly with the odd pitches, preventing
- * the surface pitch from being used to box non-power2 textures. Instead we have to use a hack to
- * repack the texture so that the bpp * width pitch can be used instead of bpp * pow2width.
- *
- * We're doing this...
- *
- * instead of boxing the texture :
- * |<-texture width ->| -->pow2width| /\
- * |111111111111111111| | |
- * |222 Texture 222222| boxed empty | texture height
- * |3333 Data 33333333| | |
- * |444444444444444444| | \/
- * ----------------------------------- |
- * | boxed empty | boxed empty | pow2height
- * | | | \/
- * -----------------------------------
- *
- *
- * we're repacking the data to the expected texture width
- *
- * |<-texture width ->| -->pow2width| /\
- * |111111111111111111222222222222222| |
- * |222333333333333333333444444444444| texture height
- * |444444 | |
- * | | \/
- * | | |
- * | empty | pow2height
- * | | \/
- * -----------------------------------
- *
- * == is the same as
- *
- * |<-texture width ->| /\
- * |111111111111111111|
- * |222222222222222222|texture height
- * |333333333333333333|
- * |444444444444444444| \/
- * --------------------
- *
- * This also means that any references to surface memory should work with the data as if it were a
- * standard texture with a non-power2 width instead of a texture boxed up to be a power2 texture.
- *
- * internally the texture is still stored in a boxed format so any references to textureName will
- * get a boxed texture with width pow2width and not a texture of width resource.width. */
- src_data = mem;
- dst_data = data.addr;
- TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
- h = wined3d_texture_get_level_height(texture, level);
- for (y = 0; y < h; ++y)
- {
- memcpy(dst_data, src_data, dst_row_pitch);
- src_data += src_row_pitch;
- dst_data += dst_row_pitch;
- }
- }
- else if (temporary_mem)
- {
- unsigned int layer = sub_resource_idx / texture->level_count;
- void *src_data = temporary_mem + layer * sub_resource->size;
- if (data.buffer_object)
- {
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data.buffer_object));
- checkGLcall("glBindBuffer");
- GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER, 0, sub_resource->size, src_data));
- checkGLcall("glBufferSubData");
- }
- else
- {
- memcpy(data.addr, src_data, sub_resource->size);
- }
- }
-
- if (data.buffer_object)
- {
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
- checkGLcall("glBindBuffer");
- }
-
- heap_free(temporary_mem);
-}
-
/* See also float_16_to_32() in wined3d_private.h */
static inline unsigned short float_32_to_16(const float *in)
{
@@ -1666,9 +1437,11 @@ BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_res
/* Download the sub-resource to system memory. */
if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
{
+ struct wined3d_bo_address data;
wined3d_texture_bind_and_dirtify(texture, context,
!(sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB));
- texture2d_download_data(texture, sub_resource_idx, context, dst_location);
+ wined3d_texture_get_memory(texture, sub_resource_idx, &data, dst_location);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
++texture->download_count;
return TRUE;
}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 282c428c071..0b11c94d5b5 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2140,6 +2140,295 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
}
}
+static void texture2d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, const struct wined3d_bo_address *data)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ struct wined3d_texture_sub_resource *sub_resource;
+ unsigned int dst_row_pitch, dst_slice_pitch;
+ unsigned int src_row_pitch, src_slice_pitch;
+ const struct wined3d_format_gl *format_gl;
+ BYTE *temporary_mem = NULL;
+ unsigned int level;
+ GLenum target;
+ void *mem;
+
+ format_gl = wined3d_format_gl(texture->resource.format);
+
+ /* Only support read back of converted P8 textures. */
+ if (texture->flags & WINED3D_TEXTURE_CONVERTED && format_gl->f.id != WINED3DFMT_P8_UINT && !format_gl->f.download)
+ {
+ ERR("Trying to read back converted texture %p, %u with format %s.\n",
+ texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
+ return;
+ }
+
+ sub_resource = &texture->sub_resources[sub_resource_idx];
+ target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx);
+ level = sub_resource_idx % texture->level_count;
+
+ if (target == GL_TEXTURE_2D_ARRAY)
+ {
+ if (format_gl->f.download)
+ {
+ FIXME("Reading back converted array texture %p is not supported.\n", texture);
+ return;
+ }
+
+ /* NP2 emulation is not allowed on array textures. */
+ if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+ ERR("Array texture %p uses NP2 emulation.\n", texture);
+
+ WARN_(d3d_perf)("Downloading all miplevel layers to get the data for a single sub-resource.\n");
+
+ if (!(temporary_mem = heap_calloc(texture->layer_count, sub_resource->size)))
+ {
+ ERR("Out of memory.\n");
+ return;
+ }
+ }
+
+ if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+ {
+ if (format_gl->f.download)
+ {
+ FIXME("Reading back converted texture %p with NP2 emulation is not supported.\n", texture);
+ return;
+ }
+
+ wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
+ wined3d_format_calculate_pitch(&format_gl->f, texture->resource.device->surface_alignment,
+ wined3d_texture_get_level_pow2_width(texture, level),
+ wined3d_texture_get_level_pow2_height(texture, level),
+ &src_row_pitch, &src_slice_pitch);
+ if (!(temporary_mem = heap_alloc(src_slice_pitch)))
+ {
+ ERR("Out of memory.\n");
+ return;
+ }
+
+ if (data->buffer_object)
+ ERR("NP2 emulated texture uses PBO unexpectedly.\n");
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+ ERR("Unexpected compressed format for NP2 emulated texture.\n");
+ }
+
+ if (format_gl->f.download)
+ {
+ struct wined3d_format f;
+
+ if (data->buffer_object)
+ ERR("Converted texture %p uses PBO unexpectedly.\n", texture);
+
+ WARN_(d3d_perf)("Downloading converted texture %p, %u with format %s.\n",
+ texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
+
+ f = format_gl->f;
+ f.byte_count = format_gl->f.conv_byte_count;
+ wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
+ wined3d_format_calculate_pitch(&f, texture->resource.device->surface_alignment,
+ wined3d_texture_get_level_width(texture, level),
+ wined3d_texture_get_level_height(texture, level),
+ &src_row_pitch, &src_slice_pitch);
+
+ if (!(temporary_mem = heap_alloc(src_slice_pitch)))
+ {
+ ERR("Failed to allocate memory.\n");
+ return;
+ }
+ }
+
+ if (temporary_mem)
+ {
+ mem = temporary_mem;
+ }
+ else if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
+ checkGLcall("glBindBuffer");
+ mem = data->addr;
+ }
+ else
+ {
+ mem = data->addr;
+ }
+
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+ {
+ TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
+
+ GL_EXTCALL(glGetCompressedTexImage(target, level, mem));
+ checkGLcall("glGetCompressedTexImage");
+ }
+ else
+ {
+ TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
+
+ gl_info->gl_ops.gl.p_glGetTexImage(target, level, format_gl->format, format_gl->type, mem);
+ checkGLcall("glGetTexImage");
+ }
+
+ if (format_gl->f.download)
+ {
+ format_gl->f.download(mem, data->addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
+ wined3d_texture_get_level_width(texture, level),
+ wined3d_texture_get_level_height(texture, level), 1);
+ }
+ else if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
+ {
+ const BYTE *src_data;
+ unsigned int h, y;
+ BYTE *dst_data;
+ /* Some games (e.g. Warhammer 40,000) don't properly handle texture
+ * pitches, preventing us from using the texture pitch to box NPOT
+ * textures. Instead, we repack the texture's CPU copy so that its
+ * pitch equals bpp * width instead of bpp * pow2width.
+ *
+ * Instead of boxing the texture:
+ *
+ * │<── texture width ──>│ pow2 width ──>│
+ * ├─────────────────────┼───────────────┼─
+ * │111111111111111111111│ │ʌ
+ * │222222222222222222222│ ││
+ * │333333333333333333333│ padding │texture height
+ * │444444444444444444444│ ││
+ * │555555555555555555555│ │v
+ * ├─────────────────────┘ ├─
+ * │ │pow2 height
+ * │ padding padding ││
+ * │ │v
+ * └─────────────────────────────────────┴─
+ *
+ * we're repacking the data to the expected texture width
+ *
+ * │<── texture width ──>│ pow2 width ──>│
+ * ├─────────────────────┴───────────────┼─
+ * │1111111111111111111112222222222222222│ʌ
+ * │2222233333333333333333333344444444444││
+ * │4444444444555555555555555555555 │texture height
+ * │ ││
+ * │ padding padding │v
+ * │ ├─
+ * │ │pow2 height
+ * │ padding padding ││
+ * │ │v
+ * └─────────────────────────────────────┴─
+ *
+ * == is the same as
+ *
+ * │<── texture width ──>│
+ * ├─────────────────────┼─
+ * │111111111111111111111│ʌ
+ * │222222222222222222222││
+ * │333333333333333333333│texture height
+ * │444444444444444444444││
+ * │555555555555555555555│v
+ * └─────────────────────┴─
+ *
+ * This also means that any references to surface memory should work
+ * with the data as if it were a standard texture with a NPOT width
+ * instead of a texture boxed up to be a power-of-two texture. */
+ src_data = mem;
+ dst_data = data->addr;
+ TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
+ h = wined3d_texture_get_level_height(texture, level);
+ for (y = 0; y < h; ++y)
+ {
+ memcpy(dst_data, src_data, dst_row_pitch);
+ src_data += src_row_pitch;
+ dst_data += dst_row_pitch;
+ }
+ }
+ else if (temporary_mem)
+ {
+ unsigned int layer = sub_resource_idx / texture->level_count;
+ void *src_data = temporary_mem + layer * sub_resource->size;
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
+ checkGLcall("glBindBuffer");
+ GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER, 0, sub_resource->size, src_data));
+ checkGLcall("glBufferSubData");
+ }
+ else
+ {
+ memcpy(data->addr, src_data, sub_resource->size);
+ }
+ }
+
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
+ checkGLcall("glBindBuffer");
+ }
+
+ heap_free(temporary_mem);
+}
+
+/* This call just downloads data, the caller is responsible for binding the
+ * correct texture. Partial downloads are not supported. */
+/* Context activation is done by the caller. */
+void wined3d_texture_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, const struct wined3d_bo_address *data)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_format_gl *format_gl;
+ unsigned int level;
+ GLenum target;
+
+ format_gl = wined3d_format_gl(texture->resource.format);
+ target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx);
+ level = sub_resource_idx % texture->level_count;
+
+ if (texture->resource.type == WINED3D_RTYPE_TEXTURE_2D
+ && (target == GL_TEXTURE_2D_ARRAY || format_gl->f.conv_byte_count
+ || texture->flags & (WINED3D_TEXTURE_CONVERTED | WINED3D_TEXTURE_COND_NP2_EMULATED)))
+ {
+ /* 2D-specific special cases. */
+ texture2d_download_data(texture, sub_resource_idx, context, data);
+ return;
+ }
+
+ if (format_gl->f.conv_byte_count)
+ {
+ FIXME("Attempting to download a converted texture, type %s format %s.\n",
+ debug_d3dresourcetype(texture->resource.type),
+ debug_d3dformat(format_gl->f.id));
+ return;
+ }
+
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
+ checkGLcall("glBindBuffer");
+ }
+
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
+ {
+ TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, data->addr);
+
+ GL_EXTCALL(glGetCompressedTexImage(target, level, data->addr));
+ checkGLcall("glGetCompressedTexImage");
+ }
+ else
+ {
+ TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, data->addr);
+
+ gl_info->gl_ops.gl.p_glGetTexImage(target, level, format_gl->format, format_gl->type, 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. Context may be NULL in ddraw-only mode. */
static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location)
@@ -2445,38 +2734,6 @@ static const struct wined3d_resource_ops texture_resource_ops =
};
/* 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_gl_info *gl_info = context->gl_info;
- const struct wined3d_format_gl *format_gl;
-
- format_gl = wined3d_format_gl(texture->resource.format);
- if (format_gl->f.conv_byte_count)
- {
- FIXME("Attempting to download a converted texture, format %s.\n",
- debug_d3dformat(format_gl->f.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(texture->target, sub_resource_idx,
- format_gl->format, format_gl->type, 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 BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location)
{
@@ -2536,7 +2793,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture1d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
++texture->download_count;
}
else
@@ -2557,7 +2814,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture1d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
}
else
{
@@ -2918,38 +3175,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
}
/* Context activation is done by the caller. */
-static void texture3d_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_gl_info *gl_info = context->gl_info;
- const struct wined3d_format_gl *format_gl;
-
- format_gl = wined3d_format_gl(texture->resource.format);
- if (format_gl->f.conv_byte_count)
- {
- FIXME("Attempting to download a converted volume, format %s.\n",
- debug_d3dformat(format_gl->f.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_3D, sub_resource_idx,
- format_gl->format, format_gl->type, 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 texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, BOOL dest_is_srgb)
{
@@ -2972,7 +3197,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box);
wined3d_texture_bind_and_dirtify(texture, context, !dest_is_srgb);
- texture3d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb);
wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format,
&src_box, wined3d_const_bo_address(&data), row_pitch, slice_pitch, 0, 0, 0, FALSE);
@@ -3045,7 +3270,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture3d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
++texture->download_count;
}
else
@@ -3066,7 +3291,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
- texture3d_download_data(texture, sub_resource_idx, context, &data);
+ wined3d_texture_download_data(texture, sub_resource_idx, context, &data);
}
else
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5f7f6fd3979..a2dcbb06fd7 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3350,6 +3350,8 @@ void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
+void wined3d_texture_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ struct wined3d_context *context, const struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
--
2.11.0
1
0
Oct. 3, 2018
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/shader.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 60e817485b8b..a5b148648ed9 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -3390,6 +3390,8 @@ static HRESULT shader_set_function(struct wined3d_shader *shader,
return WINED3DERR_INVALIDCALL;
}
+ shader->load_local_constsF = shader->lconst_inf_or_nan;
+
return WINED3D_OK;
}
@@ -3787,8 +3789,6 @@ static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device
}
}
- shader->load_local_constsF = shader->lconst_inf_or_nan;
-
return hr;
}
--
2.16.4
2
1
[PATCH 4/8] wined3d: Call shader_set_function() separately from shader_init().
by Józef Kucia Oct. 3, 2018
by Józef Kucia Oct. 3, 2018
Oct. 3, 2018
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/shader.c | 96 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 65 insertions(+), 31 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 38377c0b9857..edaa35ea65cb 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -3700,8 +3700,7 @@ static HRESULT shader_copy_signatures_from_shader_desc(struct wined3d_shader *sh
}
static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
- const struct wined3d_shader_desc *desc, DWORD float_const_count, enum wined3d_shader_type type,
- void *parent, const struct wined3d_parent_ops *parent_ops)
+ const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
size_t byte_code_size;
HRESULT hr;
@@ -3765,26 +3764,6 @@ static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device
}
memcpy(shader->function, desc->byte_code, byte_code_size);
shader->functionLength = byte_code_size;
-
- if (FAILED(hr = shader_set_function(shader, device, type, float_const_count)))
- {
- WARN("Failed to set function, hr %#x.\n", hr);
- shader_cleanup(shader);
- return hr;
- }
- }
- else
- {
- shader->reg_maps.shader_version.type = type;
- shader->reg_maps.shader_version.major = 4;
- shader->reg_maps.shader_version.minor = 0;
- shader_set_limits(shader);
-
- if (FAILED(hr = shader_scan_output_signature(shader)))
- {
- shader_cleanup(shader);
- return hr;
- }
}
return hr;
@@ -3797,10 +3776,16 @@ static HRESULT vertex_shader_init(struct wined3d_shader *shader, struct wined3d_
unsigned int i;
HRESULT hr;
- if (FAILED(hr = shader_init(shader, device, desc, device->adapter->d3d_info.limits.vs_uniform_count,
- WINED3D_SHADER_TYPE_VERTEX, parent, parent_ops)))
+ if (FAILED(hr = shader_init(shader, device, desc, parent, parent_ops)))
return hr;
+ if (FAILED(hr = shader_set_function(shader, device,
+ WINED3D_SHADER_TYPE_VERTEX, device->adapter->d3d_info.limits.vs_uniform_count)))
+ {
+ shader_cleanup(shader);
+ return hr;
+ }
+
for (i = 0; i < shader->input_signature.element_count; ++i)
{
const struct wined3d_shader_signature_element *input = &shader->input_signature.elements[i];
@@ -3845,10 +3830,32 @@ static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3
}
}
- if (FAILED(hr = shader_init(shader, device, &shader_desc, 0,
- WINED3D_SHADER_TYPE_GEOMETRY, parent, parent_ops)))
+ if (FAILED(hr = shader_init(shader, device, &shader_desc, parent, parent_ops)))
return hr;
+ if (shader_desc.byte_code)
+ {
+ if (FAILED(hr = shader_set_function(shader, device, WINED3D_SHADER_TYPE_GEOMETRY, 0)))
+ {
+ WARN("Failed to set function, hr %#x.\n", hr);
+ shader_cleanup(shader);
+ return hr;
+ }
+ }
+ else
+ {
+ shader->reg_maps.shader_version.type = WINED3D_SHADER_TYPE_GEOMETRY;
+ shader->reg_maps.shader_version.major = 4;
+ shader->reg_maps.shader_version.minor = 0;
+ shader_set_limits(shader);
+
+ if (FAILED(hr = shader_scan_output_signature(shader)))
+ {
+ shader_cleanup(shader);
+ return hr;
+ }
+ }
+
if (so_desc)
{
if (!(elements = heap_calloc(so_desc->element_count, sizeof(*elements))))
@@ -4152,10 +4159,16 @@ static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_d
unsigned int i, highest_reg_used = 0, num_regs_used = 0;
HRESULT hr;
- if (FAILED(hr = shader_init(shader, device, desc, device->adapter->d3d_info.limits.ps_uniform_count,
- WINED3D_SHADER_TYPE_PIXEL, parent, parent_ops)))
+ if (FAILED(hr = shader_init(shader, device, desc, parent, parent_ops)))
return hr;
+ if (FAILED(hr = shader_set_function(shader, device,
+ WINED3D_SHADER_TYPE_PIXEL, device->adapter->d3d_info.limits.ps_uniform_count)))
+ {
+ shader_cleanup(shader);
+ return hr;
+ }
+
for (i = 0; i < MAX_REG_INPUT; ++i)
{
if (shader->u.ps.input_reg_used & (1u << i))
@@ -4246,13 +4259,20 @@ HRESULT CDECL wined3d_shader_create_cs(struct wined3d_device *device, const stru
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
- if (FAILED(hr = shader_init(object, device, desc, 0, WINED3D_SHADER_TYPE_COMPUTE, parent, parent_ops)))
+ if (FAILED(hr = shader_init(object, device, desc, parent, parent_ops)))
{
WARN("Failed to initialize compute shader, hr %#x.\n", hr);
heap_free(object);
return hr;
}
+ if (FAILED(hr = shader_set_function(object, device, WINED3D_SHADER_TYPE_COMPUTE, 0)))
+ {
+ shader_cleanup(object);
+ heap_free(object);
+ return hr;
+ }
+
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
TRACE("Created compute shader %p.\n", object);
@@ -4276,13 +4296,20 @@ HRESULT CDECL wined3d_shader_create_ds(struct wined3d_device *device, const stru
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
- if (FAILED(hr = shader_init(object, device, desc, 0, WINED3D_SHADER_TYPE_DOMAIN, parent, parent_ops)))
+ if (FAILED(hr = shader_init(object, device, desc, parent, parent_ops)))
{
WARN("Failed to initialize domain shader, hr %#x.\n", hr);
heap_free(object);
return hr;
}
+ if (FAILED(hr = shader_set_function(object, device, WINED3D_SHADER_TYPE_DOMAIN, 0)))
+ {
+ shader_cleanup(object);
+ heap_free(object);
+ return hr;
+ }
+
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
TRACE("Created domain shader %p.\n", object);
@@ -4337,13 +4364,20 @@ HRESULT CDECL wined3d_shader_create_hs(struct wined3d_device *device, const stru
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
- if (FAILED(hr = shader_init(object, device, desc, 0, WINED3D_SHADER_TYPE_HULL, parent, parent_ops)))
+ if (FAILED(hr = shader_init(object, device, desc, parent, parent_ops)))
{
WARN("Failed to initialize hull shader, hr %#x.\n", hr);
heap_free(object);
return hr;
}
+ if (FAILED(hr = shader_set_function(object, device, WINED3D_SHADER_TYPE_HULL, 0)))
+ {
+ shader_cleanup(object);
+ heap_free(object);
+ return hr;
+ }
+
wined3d_cs_init_object(device->cs, wined3d_shader_init_object, object);
TRACE("Created hull shader %p.\n", object);
--
2.16.4
2
1
Use the shader frontend to get the shader type.
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/shader.c | 124 +++++++++++++++++++++--------------------
dlls/wined3d/shader_sm4.c | 2 +-
dlls/wined3d/wined3d_private.h | 3 -
3 files changed, 64 insertions(+), 65 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index edaa35ea65cb..32261a9a9d79 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -419,15 +419,6 @@ static const struct wined3d_shader_frontend *shader_select_frontend(enum wined3d
}
}
-static enum wined3d_shader_type shader_get_shader_type(const struct wined3d_shader_desc *desc)
-{
- if (desc->format == WINED3D_SHADER_BYTE_CODE_FORMAT_SM4)
- return wined3d_get_sm4_shader_type(desc->byte_code, desc->byte_code_size);
-
- FIXME("Could not get shader type for byte code format %#x.\n", desc->format);
- return WINED3D_SHADER_TYPE_INVALID;
-}
-
void string_buffer_clear(struct wined3d_string_buffer *buffer)
{
buffer->buffer[0] = '\0';
@@ -3755,16 +3746,13 @@ static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device
byte_code_size = (ptr - desc->byte_code) * sizeof(*ptr);
}
- if (desc->byte_code && byte_code_size)
+ if (!(shader->function = heap_alloc(byte_code_size)))
{
- if (!(shader->function = heap_alloc(byte_code_size)))
- {
- shader_cleanup(shader);
- return E_OUTOFMEMORY;
- }
- memcpy(shader->function, desc->byte_code, byte_code_size);
- shader->functionLength = byte_code_size;
+ shader_cleanup(shader);
+ return E_OUTOFMEMORY;
}
+ memcpy(shader->function, desc->byte_code, byte_code_size);
+ shader->functionLength = byte_code_size;
return hr;
}
@@ -3804,43 +3792,69 @@ static HRESULT vertex_shader_init(struct wined3d_shader *shader, struct wined3d_
return WINED3D_OK;
}
-static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
- const struct wined3d_shader_desc *desc, const struct wined3d_stream_output_desc *so_desc,
- void *parent, const struct wined3d_parent_ops *parent_ops)
+static HRESULT geometry_shader_init_stream_output(struct wined3d_shader *shader,
+ const struct wined3d_stream_output_desc *so_desc)
{
- struct wined3d_shader_desc shader_desc = *desc;
+ const struct wined3d_shader_frontend *fe = shader->frontend;
struct wined3d_stream_output_element *elements;
- enum wined3d_shader_type shader_type;
- HRESULT hr;
+ struct wined3d_shader_version shader_version;
+ const DWORD *ptr;
+ void *fe_data;
- if (so_desc)
+ if (!so_desc)
+ return WINED3D_OK;
+
+ if (!(fe_data = fe->shader_init(shader->function, shader->functionLength, &shader->output_signature)))
{
- shader_type = shader_get_shader_type(desc);
- switch (shader_type)
- {
- case WINED3D_SHADER_TYPE_VERTEX:
- shader_desc.byte_code = NULL;
- shader_desc.byte_code_size = 0;
- break;
- case WINED3D_SHADER_TYPE_DOMAIN:
- FIXME("Stream output not supported for %s.\n", debug_shader_type(shader_type));
- return E_NOTIMPL;
- default:
- break;
- }
+ WARN("Failed to initialise frontend data.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+ fe->shader_read_header(fe_data, &ptr, &shader_version);
+ fe->shader_free(fe_data);
+
+ switch (shader_version.type)
+ {
+ case WINED3D_SHADER_TYPE_VERTEX:
+ heap_free(shader->function);
+ shader->function = NULL;
+ shader->functionLength = 0;
+ break;
+ case WINED3D_SHADER_TYPE_DOMAIN:
+ FIXME("Stream output not supported for %s.\n", debug_shader_type(shader_version.type));
+ return E_NOTIMPL;
+ case WINED3D_SHADER_TYPE_GEOMETRY:
+ break;
+ default:
+ WARN("Wrong shader type %s.\n", debug_shader_type(shader_version.type));
+ return E_INVALIDARG;
}
- if (FAILED(hr = shader_init(shader, device, &shader_desc, parent, parent_ops)))
+ if (!(elements = heap_calloc(so_desc->element_count, sizeof(*elements))))
+ return E_OUTOFMEMORY;
+
+ shader->u.gs.so_desc = *so_desc;
+ shader->u.gs.so_desc.elements = elements;
+ memcpy(elements, so_desc->elements, so_desc->element_count * sizeof(*elements));
+
+ return WINED3D_OK;
+}
+
+static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
+ const struct wined3d_shader_desc *desc, const struct wined3d_stream_output_desc *so_desc,
+ void *parent, const struct wined3d_parent_ops *parent_ops)
+{
+ HRESULT hr;
+
+ if (FAILED(hr = shader_init(shader, device, desc, parent, parent_ops)))
return hr;
- if (shader_desc.byte_code)
+ if (FAILED(hr = geometry_shader_init_stream_output(shader, so_desc)))
+ goto fail;
+
+ if (shader->function)
{
if (FAILED(hr = shader_set_function(shader, device, WINED3D_SHADER_TYPE_GEOMETRY, 0)))
- {
- WARN("Failed to set function, hr %#x.\n", hr);
- shader_cleanup(shader);
- return hr;
- }
+ goto fail;
}
else
{
@@ -3850,26 +3864,14 @@ static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3
shader_set_limits(shader);
if (FAILED(hr = shader_scan_output_signature(shader)))
- {
- shader_cleanup(shader);
- return hr;
- }
- }
-
- if (so_desc)
- {
- if (!(elements = heap_calloc(so_desc->element_count, sizeof(*elements))))
- {
- shader_cleanup(shader);
- return E_OUTOFMEMORY;
- }
-
- shader->u.gs.so_desc = *so_desc;
- shader->u.gs.so_desc.elements = elements;
- memcpy(elements, so_desc->elements, so_desc->element_count * sizeof(*elements));
+ goto fail;
}
return WINED3D_OK;
+
+fail:
+ shader_cleanup(shader);
+ return hr;
}
void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index b119e8feaa80..7841686b8b4b 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -1222,7 +1222,7 @@ static enum wined3d_data_type map_data_type(char t)
}
}
-enum wined3d_shader_type wined3d_get_sm4_shader_type(const DWORD *byte_code, size_t byte_code_size)
+static enum wined3d_shader_type wined3d_get_sm4_shader_type(const DWORD *byte_code, size_t byte_code_size)
{
DWORD shader_type;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5f7f6fd39795..340bfe64801c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1253,9 +1253,6 @@ struct wined3d_shader_frontend
extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
-enum wined3d_shader_type wined3d_get_sm4_shader_type(const DWORD *byte_code,
- size_t byte_code_size) DECLSPEC_HIDDEN;
-
typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
#define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001
--
2.16.4
2
1
Oct. 3, 2018
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/shader.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 32261a9a9d79..8e857b51351c 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -3815,13 +3815,11 @@ static HRESULT geometry_shader_init_stream_output(struct wined3d_shader *shader,
switch (shader_version.type)
{
case WINED3D_SHADER_TYPE_VERTEX:
+ case WINED3D_SHADER_TYPE_DOMAIN:
heap_free(shader->function);
shader->function = NULL;
shader->functionLength = 0;
break;
- case WINED3D_SHADER_TYPE_DOMAIN:
- FIXME("Stream output not supported for %s.\n", debug_shader_type(shader_version.type));
- return E_NOTIMPL;
case WINED3D_SHADER_TYPE_GEOMETRY:
break;
default:
--
2.16.4
2
1
[PATCH 7/8] wined3d: Use version from byte code for pass-through geometry shaders.
by Józef Kucia Oct. 3, 2018
by Józef Kucia Oct. 3, 2018
Oct. 3, 2018
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/shader.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 8e857b51351c..438af50d8410 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -3800,6 +3800,7 @@ static HRESULT geometry_shader_init_stream_output(struct wined3d_shader *shader,
struct wined3d_shader_version shader_version;
const DWORD *ptr;
void *fe_data;
+ HRESULT hr;
if (!so_desc)
return WINED3D_OK;
@@ -3827,6 +3828,15 @@ static HRESULT geometry_shader_init_stream_output(struct wined3d_shader *shader,
return E_INVALIDARG;
}
+ if (!shader->function)
+ {
+ shader->reg_maps.shader_version = shader_version;
+ shader->reg_maps.shader_version.type = WINED3D_SHADER_TYPE_GEOMETRY;
+ shader_set_limits(shader);
+ if (FAILED(hr = shader_scan_output_signature(shader)))
+ return hr;
+ }
+
if (!(elements = heap_calloc(so_desc->element_count, sizeof(*elements))))
return E_OUTOFMEMORY;
@@ -3849,21 +3859,9 @@ static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3
if (FAILED(hr = geometry_shader_init_stream_output(shader, so_desc)))
goto fail;
- if (shader->function)
- {
- if (FAILED(hr = shader_set_function(shader, device, WINED3D_SHADER_TYPE_GEOMETRY, 0)))
- goto fail;
- }
- else
- {
- shader->reg_maps.shader_version.type = WINED3D_SHADER_TYPE_GEOMETRY;
- shader->reg_maps.shader_version.major = 4;
- shader->reg_maps.shader_version.minor = 0;
- shader_set_limits(shader);
-
- if (FAILED(hr = shader_scan_output_signature(shader)))
- goto fail;
- }
+ if (shader->function
+ && FAILED(hr = shader_set_function(shader, device, WINED3D_SHADER_TYPE_GEOMETRY, 0)))
+ goto fail;
return WINED3D_OK;
--
2.16.4
2
1