Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- 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
December 2020
- 68 participants
- 931 messages
[PATCH 1/4] wined3d: Use the "bo user" mechanism to invalidate existing bindings in wined3d_buffer_gl_destroy_buffer_object().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/adapter_vk.c | 6 ++---
dlls/wined3d/buffer.c | 47 +++++++++-------------------------
dlls/wined3d/context_gl.c | 20 ++++++++++++---
dlls/wined3d/state.c | 36 ++++++++++++++++++--------
dlls/wined3d/wined3d_private.h | 8 +++---
5 files changed, 62 insertions(+), 55 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index 3fb9e4ce4b4..3da1615b1b5 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -860,10 +860,10 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
{
struct wined3d_context_vk *context_vk = wined3d_context_vk(context);
const struct wined3d_vk_info *vk_info;
- struct wined3d_bo_user_vk *bo_user_vk;
struct wined3d_device_vk *device_vk;
VkCommandBuffer vk_command_buffer;
VkBufferMemoryBarrier vk_barrier;
+ struct wined3d_bo_user *bo_user;
struct wined3d_bo_vk *bo, tmp;
VkMappedMemoryRange range;
void *map_ptr;
@@ -886,9 +886,9 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
*bo = tmp;
list_init(&bo->users);
list_move_head(&bo->users, &tmp.users);
- LIST_FOR_EACH_ENTRY(bo_user_vk, &bo->users, struct wined3d_bo_user_vk, entry)
+ LIST_FOR_EACH_ENTRY(bo_user, &bo->users, struct wined3d_bo_user, entry)
{
- bo_user_vk->valid = false;
+ bo_user->valid = false;
}
goto map;
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 5dbc66449f4..e179f202cb8 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -143,47 +143,22 @@ static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *bu
struct wined3d_context_gl *context_gl)
{
struct wined3d_resource *resource = &buffer_gl->b.resource;
- struct wined3d_buffer *buffer = &buffer_gl->b;
- struct wined3d_cs *cs = resource->device->cs;
if (!buffer_gl->b.buffer_object)
return;
- /* The stream source state handler might have read the memory of the
- * vertex buffer already and got the memory in the vbo which is not
- * valid any longer. Dirtify the stream source to force a reload. This
- * happens only once per changed vertexbuffer and should occur rather
- * rarely. */
- if (resource->bind_count)
- {
- if (resource->bind_flags & WINED3D_BIND_VERTEX_BUFFER)
- device_invalidate_state(resource->device, STATE_STREAMSRC);
- if (resource->bind_flags & WINED3D_BIND_INDEX_BUFFER
- && cs->state.index_buffer == buffer)
- device_invalidate_state(resource->device, STATE_INDEXBUFFER);
- if (resource->bind_flags & WINED3D_BIND_CONSTANT_BUFFER)
- {
- device_invalidate_state(resource->device, STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX));
- device_invalidate_state(resource->device, STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL));
- device_invalidate_state(resource->device, STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN));
- device_invalidate_state(resource->device, STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY));
- device_invalidate_state(resource->device, STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL));
- device_invalidate_state(resource->device, STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE));
- }
- if (resource->bind_flags & WINED3D_BIND_STREAM_OUTPUT)
- {
- device_invalidate_state(resource->device, STATE_STREAM_OUTPUT);
- if (context_gl->c.transform_feedback_active)
- {
- /* We have to make sure that transform feedback is not active
- * when deleting a potentially bound transform feedback buffer.
- * This may happen when the device is being destroyed. */
- WARN("Deleting buffer object for buffer %p, disabling transform feedback.\n", buffer_gl);
- wined3d_context_gl_end_transform_feedback(context_gl);
- }
- }
+ if (context_gl->c.transform_feedback_active && resource->bind_count
+ && resource->bind_flags & WINED3D_BIND_STREAM_OUTPUT)
+ {
+ /* We have to make sure that transform feedback is not active
+ * when deleting a potentially bound transform feedback buffer.
+ * This may happen when the device is being destroyed. */
+ WARN("Deleting buffer object for buffer %p, disabling transform feedback.\n", buffer_gl);
+ wined3d_context_gl_end_transform_feedback(context_gl);
}
+ buffer_gl->bo_user.valid = false;
+ list_remove(&buffer_gl->bo_user.entry);
wined3d_context_gl_destroy_bo(context_gl, &buffer_gl->bo);
buffer_gl->b.buffer_object = 0;
@@ -225,6 +200,8 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf
if (!coherent && gl_info->supported[APPLE_FLUSH_BUFFER_RANGE])
buffer_gl->b.flags |= WINED3D_BUFFER_APPLESYNC;
+ list_init(&buffer_gl->bo_user.entry);
+ list_add_head(&buffer_gl->bo.users, &buffer_gl->bo_user.entry);
buffer_gl->b.buffer_object = (uintptr_t)bo;
buffer_invalidate_bo_range(&buffer_gl->b, 0, 0);
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index 406b325cda8..305ca0507ff 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -2823,6 +2823,7 @@ bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizei
bo->id = id;
bo->binding = binding;
bo->usage = usage;
+ list_init(&bo->users);
bo->command_fence_id = 0;
return true;
@@ -3718,6 +3719,8 @@ static void context_gl_load_shader_resources(struct wined3d_context_gl *context_
buffer_gl = wined3d_buffer_gl(state->cb[i][j]);
wined3d_buffer_load(&buffer_gl->b, &context_gl->c, state);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
+ if (!buffer_gl->bo_user.valid)
+ device_invalidate_state(context_gl->c.device, STATE_CONSTANT_BUFFER(i));
}
for (j = 0; j < shader->reg_maps.sampler_map.count; ++j)
@@ -3793,6 +3796,8 @@ static void context_gl_load_stream_output_buffers(struct wined3d_context_gl *con
wined3d_buffer_load(&buffer_gl->b, &context_gl->c, state);
wined3d_buffer_invalidate_location(&buffer_gl->b, ~WINED3D_LOCATION_BUFFER);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
+ if (!buffer_gl->bo_user.valid)
+ device_invalidate_state(context_gl->c.device, STATE_STREAM_OUTPUT);
}
}
@@ -3848,7 +3853,10 @@ static BOOL context_apply_draw_state(struct wined3d_context *context,
e = &context->stream_info.elements[wined3d_bit_scan(&map)];
buffer_gl = wined3d_buffer_gl(state->streams[e->stream_idx].buffer);
- wined3d_buffer_load(&buffer_gl->b, context, state);
+ if (!buffer_gl->bo_user.valid)
+ device_invalidate_state(device, STATE_STREAMSRC);
+ else
+ wined3d_buffer_load(&buffer_gl->b, context, state);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
}
/* Loading the buffers above may have invalidated the stream info. */
@@ -3862,6 +3870,8 @@ static BOOL context_apply_draw_state(struct wined3d_context *context,
if (context->stream_info.all_vbo)
{
wined3d_buffer_load(&buffer_gl->b, context, state);
+ if (!buffer_gl->bo_user.valid)
+ device_invalidate_state(device, STATE_INDEXBUFFER);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
}
else
@@ -4989,6 +4999,7 @@ void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context
gl_info->gl_ops.gl.p_glTexCoordPointer(format_gl->vtx_format, format_gl->vtx_type, e->stride,
e->data.addr + state->load_base_vertex_index * e->stride);
gl_info->gl_ops.gl.p_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
}
else
{
@@ -5077,6 +5088,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
checkGLcall("glVertexPointer(...)");
gl_info->gl_ops.gl.p_glEnableClientState(GL_VERTEX_ARRAY);
checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
+ wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
}
/* Normals */
@@ -5100,7 +5112,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
checkGLcall("glNormalPointer(...)");
gl_info->gl_ops.gl.p_glEnableClientState(GL_NORMAL_ARRAY);
checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
-
+ wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
}
else
{
@@ -5130,7 +5142,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
gl_info->gl_ops.gl.p_glEnableClientState(GL_COLOR_ARRAY);
checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
-
+ wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
}
else
{
@@ -5199,6 +5211,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte
}
gl_info->gl_ops.gl.p_glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
+ wined3d_buffer_gl(state->streams[e->stream_idx].buffer)->bo_user.valid = true;
}
else
{
@@ -5292,6 +5305,7 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c
format_gl = wined3d_format_gl(element->format);
stream = &state->streams[element->stream_idx];
+ wined3d_buffer_gl(stream->buffer)->bo_user.valid = true;
if ((stream->flags & WINED3DSTREAMSOURCE_INSTANCEDATA) && !context->instance_count)
context->instance_count = state->streams[0].frequency;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 71f7ac53a2f..e40c23daf03 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4452,12 +4452,17 @@ static void indexbuffer(struct wined3d_context *context, const struct wined3d_st
{
const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
const struct wined3d_stream_info *stream_info = &context->stream_info;
- const struct wined3d_buffer *ib = state->index_buffer;
+ struct wined3d_buffer_gl *buffer_gl;
- if (!ib || !stream_info->all_vbo)
+ if (!state->index_buffer || !stream_info->all_vbo)
+ {
GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
- else
- GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, wined3d_buffer_gl_const(ib)->bo.id));
+ return;
+ }
+
+ buffer_gl = wined3d_buffer_gl(state->index_buffer);
+ GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer_gl->bo.id));
+ buffer_gl->bo_user.valid = true;
}
static void depth_clip(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info)
@@ -4550,7 +4555,7 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
{
const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
enum wined3d_shader_type shader_type;
- struct wined3d_buffer *buffer;
+ struct wined3d_buffer_gl *buffer_gl;
unsigned int i, base, count;
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
@@ -4563,8 +4568,15 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
wined3d_gl_limits_get_uniform_block_range(&gl_info->limits, shader_type, &base, &count);
for (i = 0; i < count; ++i)
{
- buffer = state->cb[shader_type][i];
- GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + i, buffer ? wined3d_buffer_gl(buffer)->bo.id : 0));
+ if (!state->cb[shader_type][i])
+ {
+ GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + i, 0));
+ continue;
+ }
+
+ buffer_gl = wined3d_buffer_gl(state->cb[shader_type][i]);
+ GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + i, buffer_gl->bo.id));
+ buffer_gl->bo_user.valid = true;
}
checkGLcall("bind constant buffers");
}
@@ -4614,7 +4626,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
- struct wined3d_buffer *buffer;
+ struct wined3d_buffer_gl *buffer_gl;
unsigned int offset, size, i;
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
@@ -4623,20 +4635,22 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
{
- if (!(buffer = state->stream_output[i].buffer))
+ if (!state->stream_output[i].buffer)
{
GL_EXTCALL(glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, i, 0));
continue;
}
+ buffer_gl = wined3d_buffer_gl(state->stream_output[i].buffer);
offset = state->stream_output[i].offset;
if (offset == ~0u)
{
FIXME("Appending to stream output buffers not implemented.\n");
offset = 0;
}
- size = buffer->resource.size - offset;
- GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, wined3d_buffer_gl(buffer)->bo.id, offset, size));
+ size = buffer_gl->b.resource.size - offset;
+ GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, buffer_gl->bo.id, offset, size));
+ buffer_gl->bo_user.valid = true;
}
checkGLcall("bind transform feedback buffers");
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 67caf98ead7..67a55c4dedd 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1575,6 +1575,7 @@ struct wined3d_bo_gl
GLenum binding;
GLenum usage;
+ struct list users;
uint64_t command_fence_id;
};
@@ -1583,7 +1584,7 @@ static inline GLuint wined3d_bo_gl_id(uintptr_t bo)
return bo ? ((struct wined3d_bo_gl *)bo)->id : 0;
}
-struct wined3d_bo_user_vk
+struct wined3d_bo_user
{
struct list entry;
bool valid;
@@ -4875,6 +4876,7 @@ struct wined3d_buffer_gl
struct wined3d_buffer b;
struct wined3d_bo_gl bo;
+ struct wined3d_bo_user bo_user;
};
static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
@@ -4898,7 +4900,7 @@ struct wined3d_buffer_vk
struct wined3d_buffer b;
struct wined3d_bo_vk bo;
- struct wined3d_bo_user_vk bo_user;
+ struct wined3d_bo_user bo_user;
VkDescriptorBufferInfo buffer_info;
};
@@ -5029,7 +5031,7 @@ HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view
struct wined3d_view_vk
{
- struct wined3d_bo_user_vk bo_user;
+ struct wined3d_bo_user bo_user;
union
{
VkBufferView vk_buffer_view;
--
2.20.1
Dec. 4, 2020
Re: Wine staging 5.19 release
by Gerald Pfeifer
On Sat, 24 Oct 2020, Gerald Pfeifer wrote:
> Here is a patch on top (of the Wine Staging patchset) that is required.
>
> Can you please include that? Thank you!
Thanks to (I believe Zebediah) for addressing those issues!
I have to confess there is one snippet I missed. With the additional
patch below Wine 5.22 + Staging patchset builds on FreeBSD 11 out of
the box.
Thank you for considering that; for now I'm carrying it as part of
the FreeBSD emulators/wine-devel port.
Gerald
--- dlls/ntdll/unix/file.c.orig 2020-11-07 09:33:27.083812000 +0000
+++ dlls/ntdll/unix/file.c 2020-11-07 09:53:55.641522000 +0000
@@ -394,6 +394,18 @@
#define XATTR_USER_PREFIX_LEN (sizeof(XATTR_USER_PREFIX) - 1)
#endif
+#ifdef HAVE_SYS_EXTATTR_H
+static inline int xattr_valid_namespace( const char *name )
+{
+ if (strncmp( XATTR_USER_PREFIX, name, XATTR_USER_PREFIX_LEN ) != 0)
+ {
+ errno = EPERM;
+ return 0;
+ }
+ return 1;
+}
+#endif
+
static int xattr_fremove( int filedes, const char *name )
{
#if defined(XATTR_ADDITIONAL_OPTIONS)
Dec. 4, 2020
[PATCH] bcrypt: Add initial support for asymmetric keys in BCryptDecrypt().
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/bcrypt/bcrypt_internal.h | 1 +
dlls/bcrypt/bcrypt_main.c | 22 ++++++++++++++++--
dlls/bcrypt/gnutls.c | 43 +++++++++++++++++++++++++++++++++++
dlls/bcrypt/macos.c | 8 +++++++
4 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h
index e1777ed130b..eb136111509 100644
--- a/dlls/bcrypt/bcrypt_internal.h
+++ b/dlls/bcrypt/bcrypt_internal.h
@@ -206,6 +206,7 @@ struct key_funcs
void (CDECL *key_symmetric_destroy)( struct key * );
NTSTATUS (CDECL *key_asymmetric_init)( struct key * );
NTSTATUS (CDECL *key_asymmetric_generate)( struct key * );
+ NTSTATUS (CDECL *key_asymmetric_decrypt)( struct key *, UCHAR *, ULONG, UCHAR *, ULONG * );
NTSTATUS (CDECL *key_asymmetric_duplicate)( struct key *, struct key * );
NTSTATUS (CDECL *key_asymmetric_sign)( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG *, ULONG );
NTSTATUS (CDECL *key_asymmetric_verify)( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, DWORD );
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 591c01c710c..a1423dcd836 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -1160,8 +1160,8 @@ static NTSTATUS key_encrypt( struct key *key, UCHAR *input, ULONG input_len, vo
return status;
}
-static NTSTATUS key_decrypt( struct key *key, UCHAR *input, ULONG input_len, void *padding, UCHAR *iv,
- ULONG iv_len, UCHAR *output, ULONG output_len, ULONG *ret_len, ULONG flags )
+static NTSTATUS key_symmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len, void *padding, UCHAR *iv,
+ ULONG iv_len, UCHAR *output, ULONG output_len, ULONG *ret_len, ULONG flags )
{
ULONG bytes_left = input_len;
UCHAR *buf, *src, *dst;
@@ -1240,6 +1240,24 @@ static NTSTATUS key_decrypt( struct key *key, UCHAR *input, ULONG input_len, voi
return status;
}
+static NTSTATUS key_asymmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len, UCHAR *output,
+ ULONG output_len, ULONG *ret_len )
+{
+ NTSTATUS status;
+
+ if (!(status = key_funcs->key_asymmetric_decrypt( key, input, input_len, output, &output_len )))
+ *ret_len = output_len;
+
+ return status;
+}
+
+static NTSTATUS key_decrypt( struct key *key, UCHAR *input, ULONG input_len, void *padding, UCHAR *iv,
+ ULONG iv_len, UCHAR *output, ULONG output_len, ULONG *ret_len, ULONG flags )
+{
+ return key_is_symmetric( key ) ? key_symmetric_decrypt( key, input, input_len, padding, iv, iv_len,
+ output, output_len, ret_len, flags ) : key_asymmetric_decrypt( key, input, input_len, output, output_len, ret_len );
+}
+
static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYPT_KEY_HANDLE *ret_key, UCHAR *input,
ULONG input_len )
{
diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c
index 162ac9ea732..c065ac31fba 100644
--- a/dlls/bcrypt/gnutls.c
+++ b/dlls/bcrypt/gnutls.c
@@ -109,6 +109,7 @@ static int (*pgnutls_privkey_generate)(gnutls_privkey_t, gnutls_pk_algorithm_t,
static int (*pgnutls_privkey_import_rsa_raw)(gnutls_privkey_t, const gnutls_datum_t *, const gnutls_datum_t *,
const gnutls_datum_t *, const gnutls_datum_t *, const gnutls_datum_t *,
const gnutls_datum_t *, const gnutls_datum_t *, const gnutls_datum_t *);
+static int (*pgnutls_privkey_decrypt_data)(gnutls_privkey_t, unsigned int flags, const gnutls_datum_t *, gnutls_datum_t *);
/* Not present in gnutls version < 3.6.0 */
static int (*pgnutls_decode_rs_value)(const gnutls_datum_t *, gnutls_datum_t *, gnutls_datum_t *);
@@ -124,6 +125,7 @@ MAKE_FUNCPTR(gnutls_global_init);
MAKE_FUNCPTR(gnutls_global_set_log_function);
MAKE_FUNCPTR(gnutls_global_set_log_level);
MAKE_FUNCPTR(gnutls_perror);
+MAKE_FUNCPTR(gnutls_privkey_decrypt_data);
MAKE_FUNCPTR(gnutls_privkey_deinit);
MAKE_FUNCPTR(gnutls_privkey_import_dsa_raw);
MAKE_FUNCPTR(gnutls_privkey_init);
@@ -215,6 +217,12 @@ static int compat_gnutls_privkey_import_rsa_raw(gnutls_privkey_t key, const gnut
return GNUTLS_E_UNKNOWN_PK_ALGORITHM;
}
+static int compat_gnutls_privkey_decrypt_data(gnutls_privkey_t key, unsigned int flags, const gnutls_datum_t *cipher_text,
+ gnutls_datum_t *plain_text)
+{
+ return GNUTLS_E_UNKNOWN_PK_ALGORITHM;
+}
+
static void gnutls_log( int level, const char *msg )
{
TRACE( "<%d> %s", level, msg );
@@ -341,6 +349,11 @@ static BOOL gnutls_initialize(void)
WARN("gnutls_privkey_import_rsa_raw not found\n");
pgnutls_privkey_import_rsa_raw = compat_gnutls_privkey_import_rsa_raw;
}
+ if (!(pgnutls_privkey_decrypt_data = dlsym( libgnutls_handle, "gnutls_privkey_decrypt_data" )))
+ {
+ WARN("gnutls_privkey_decrypt_data not found\n");
+ pgnutls_privkey_decrypt_data = compat_gnutls_privkey_decrypt_data;
+ }
if (TRACE_ON( bcrypt ))
{
@@ -1883,6 +1896,35 @@ static NTSTATUS CDECL key_asymmetric_duplicate( struct key *key_orig, struct key
return STATUS_SUCCESS;
}
+static NTSTATUS CDECL key_asymmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len,
+ UCHAR *output, ULONG *output_len )
+{
+ gnutls_datum_t e, d = { 0 };
+ NTSTATUS status = STATUS_SUCCESS;
+ int ret;
+
+ e.data = (unsigned char *)input;
+ e.size = input_len;
+
+ if ((ret = pgnutls_privkey_decrypt_data( key_data(key)->privkey, 0, &e, &d )))
+ {
+ pgnutls_perror( ret );
+ return STATUS_INTERNAL_ERROR;
+ }
+
+ if (*output_len >= d.size)
+ {
+ *output_len = d.size;
+ memcpy( output, d.data, *output_len );
+ }
+ else
+ status = STATUS_BUFFER_TOO_SMALL;
+
+ free( d.data );
+
+ return status;
+}
+
static const struct key_funcs key_funcs =
{
key_set_property,
@@ -1895,6 +1937,7 @@ static const struct key_funcs key_funcs =
key_symmetric_destroy,
key_asymmetric_init,
key_asymmetric_generate,
+ key_asymmetric_decrypt,
key_asymmetric_duplicate,
key_asymmetric_sign,
key_asymmetric_verify,
diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c
index 57edc3e262b..44906519cef 100644
--- a/dlls/bcrypt/macos.c
+++ b/dlls/bcrypt/macos.c
@@ -271,6 +271,13 @@ static NTSTATUS CDECL key_asymmetric_duplicate( struct key *key_orig, struct key
return STATUS_NOT_IMPLEMENTED;
}
+static NTSTATUS CDECL key_asymmetric_decrypt( struct key *key, UCHAR *input, ULONG input_len,
+ UCHAR *output, ULONG *output_len )
+{
+ FIXME( "not implemented on Mac\n" );
+ return STATUS_NOT_IMPLEMENTED;
+}
+
static const struct key_funcs key_funcs =
{
key_set_property,
@@ -283,6 +290,7 @@ static const struct key_funcs key_funcs =
key_symmetric_destroy,
key_asymmetric_init,
key_asymmetric_generate,
+ key_asymmetric_decrypt,
key_asymmetric_duplicate,
key_asymmetric_sign,
key_asymmetric_verify,
--
2.29.2
Dec. 4, 2020
[PATCH 2/2] quartz/vmr9: Allow the aspect ratio parameters to be NULL in IVMRWindowlessControl::GetNativeVideoSize().
by Akihiro Sagawa
Please refer to the commit 45789e00dad69a2609b6a104b71731fe483428b0 which
fixes IVMRWindowlessControl9::GetNativeVideoSize().
Signed-off-by: Akihiro Sagawa <sagawa.aki(a)gmail.com>
---
dlls/quartz/tests/vmr7.c | 6 +++---
dlls/quartz/vmr9.c | 24 ++++++++++++------------
2 files changed, 15 insertions(+), 15 deletions(-)
Dec. 4, 2020
[PATCH 1/2] quartz/tests: Add some tests for VMR7 windowless video size.
by Akihiro Sagawa
This is a port of VMR9 commit fd159a356345d71d96d158e9a87bd8e4ec1a699d.
Signed-off-by: Akihiro Sagawa <sagawa.aki(a)gmail.com>
---
dlls/quartz/tests/vmr7.c | 134 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 133 insertions(+), 1 deletion(-)
Dec. 4, 2020
Dec. 4, 2020
Re: [PATCH] localspl: Use wide-char string literals.
by Huw Davies
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
Dec. 4, 2020
Re: [PATCH] ntdll/sec: Add RtlDefaultNpAcl stub.
by Biswapriyo Nath
Any comment on this patch to improve?
Dec. 4, 2020
Re: [PATCH vkd3d v2 5/5] vkd3d-shader: Implement basic support for #if and #endif.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=83096
Your paranoid android.
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
Dec. 4, 2020
Re: [PATCH vkd3d v2 4/5] vkd3d-shader: Handle preprocessor parsing errors.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=83095
Your paranoid android.
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
Dec. 4, 2020
Re: [PATCH vkd3d v2 3/5] vkd3d-shader: Preserve some tokens verbatim for HLSL.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=83094
Your paranoid android.
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
Dec. 4, 2020
Re: [PATCH vkd3d v2 2/5] vkd3d-shader: Parse comments in the preprocessor.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=83093
Your paranoid android.
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
Dec. 4, 2020
Re: [PATCH vkd3d v2 1/5] vkd3d-shader: Implement an initial pass-through HLSL preprocessor.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=83092
Your paranoid android.
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: configure.ac:30
Task: Patch failed to apply
Dec. 4, 2020
[PATCH vkd3d v2 5/5] vkd3d-shader: Implement basic support for #if and #endif.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
include/private/vkd3d_memory.h | 11 +++
libs/vkd3d-shader/preproc.h | 16 ++++
libs/vkd3d-shader/preproc.l | 94 ++++++++++++++++++--
libs/vkd3d-shader/preproc.y | 106 ++++++++++++++++++++++-
libs/vkd3d-shader/vkd3d_shader_main.c | 15 ++++
libs/vkd3d-shader/vkd3d_shader_private.h | 6 ++
tests/hlsl_d3d12.c | 2 +-
7 files changed, 242 insertions(+), 8 deletions(-)
diff --git a/include/private/vkd3d_memory.h b/include/private/vkd3d_memory.h
index df93abf5..bd56d30a 100644
--- a/include/private/vkd3d_memory.h
+++ b/include/private/vkd3d_memory.h
@@ -22,6 +22,7 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <string.h>
#include "vkd3d_debug.h"
@@ -54,6 +55,16 @@ static inline void vkd3d_free(void *ptr)
free(ptr);
}
+static inline char *vkd3d_strdup(const char *string)
+{
+ size_t len = strlen(string) + 1;
+ char *ptr;
+
+ if ((ptr = vkd3d_malloc(len)))
+ memcpy(ptr, string, len);
+ return ptr;
+}
+
bool vkd3d_array_reserve(void **elements, size_t *capacity,
size_t element_count, size_t element_size) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/preproc.h b/libs/vkd3d-shader/preproc.h
index 769b8c23..29fbbd02 100644
--- a/libs/vkd3d-shader/preproc.h
+++ b/libs/vkd3d-shader/preproc.h
@@ -29,6 +29,12 @@ struct preproc_location
unsigned int first_line, first_column;
};
+struct preproc_if_state
+{
+ /* Are we currently in a "true" block? */
+ bool current_true;
+};
+
struct preproc_ctx
{
void *scanner;
@@ -38,7 +44,17 @@ struct preproc_ctx
unsigned int line, column;
const char *source_name;
+ struct preproc_if_state *if_stack;
+ size_t if_count, if_stack_size;
+
+ int current_directive;
+
+ bool last_was_newline;
+
bool error;
};
+void preproc_warning(struct preproc_ctx *ctx, const struct preproc_location *loc,
+ enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
+
#endif
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index c0c6b13a..e9a5b14a 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -50,6 +50,7 @@ static void update_location(struct preproc_ctx *ctx);
%s C_COMMENT
%s CXX_COMMENT
+NEWLINE \r?\n
WS [ \t]
IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
@@ -57,10 +58,10 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>"//" {yy_push_state(CXX_COMMENT, yyscanner);}
<INITIAL>"/*" {yy_push_state(C_COMMENT, yyscanner);}
-<CXX_COMMENT>\\\r?\n {}
+<CXX_COMMENT>\\{NEWLINE} {}
<CXX_COMMENT>\n {
yy_pop_state(yyscanner);
- return T_TEXT;
+ return T_NEWLINE;
}
<C_COMMENT>"*/" {yy_pop_state(yyscanner);}
<C_COMMENT,CXX_COMMENT><<EOF>> {yy_pop_state(yyscanner);}
@@ -68,13 +69,15 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>{IDENTIFIER} {return T_TEXT;}
+ /* We have no use for floats, but shouldn't parse them as integers. */
+
<INITIAL>[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;}
<INITIAL>[0-9]+\.([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;}
<INITIAL>[0-9]+([eE][+-]?[0-9]+)?[hHfF] {return T_TEXT;}
<INITIAL>[0-9]+[eE][+-]?[0-9]+ {return T_TEXT;}
-<INITIAL>0[xX][0-9a-fA-f]+[ul]{0,2} {return T_TEXT;}
-<INITIAL>0[0-7]*[ul]{0,2} {return T_TEXT;}
-<INITIAL>[1-9][0-9]*[ul]{0,2} {return T_TEXT;}
+<INITIAL>0[xX][0-9a-fA-f]+[ul]{0,2} {return T_INTEGER;}
+<INITIAL>0[0-7]*[ul]{0,2} {return T_INTEGER;}
+<INITIAL>[1-9][0-9]*[ul]{0,2} {return T_INTEGER;}
<INITIAL>"&&" {return T_TEXT;}
<INITIAL>"||" {return T_TEXT;}
@@ -87,6 +90,29 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
/* C strings (including escaped quotes). */
<INITIAL>\"([^"\\]|\\.)*\" {return T_TEXT;}
+<INITIAL>#{WS}*{IDENTIFIER} {
+ struct preproc_ctx *ctx = yyget_extra(yyscanner);
+ const char *p;
+
+ if (!ctx->last_was_newline)
+ return T_TEXT;
+
+ for (p = yytext + 1; strchr(" \t", *p); ++p)
+ ;
+
+ if (!strcmp(p, "endif"))
+ return T_ENDIF;
+ if (!strcmp(p, "if"))
+ return T_IF;
+
+ preproc_warning(ctx, yyget_lloc(yyscanner), VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE,
+ "Ignoring unknown directive \"%s\".", yytext);
+ return T_TEXT;
+ }
+
+<INITIAL>\\{NEWLINE} {}
+<INITIAL>{NEWLINE} {return T_NEWLINE;}
+
<INITIAL>{WS}+ {}
<INITIAL>. {return T_TEXT;}
@@ -114,6 +140,27 @@ static void update_location(struct preproc_ctx *ctx)
}
}
+static bool preproc_is_writing(struct preproc_ctx *ctx)
+{
+ if (!ctx->if_count)
+ return true;
+ return ctx->if_stack[ctx->if_count - 1].current_true;
+}
+
+static int return_token(int token, YYSTYPE *lval, const char *text)
+{
+ switch (token)
+ {
+ case T_INTEGER:
+ case T_TEXT:
+ if (!(lval->string = vkd3d_strdup(text)))
+ return PREPROC_YYerror;
+ break;
+ }
+
+ return token;
+}
+
int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
{
struct preproc_ctx *ctx = yyget_extra(scanner);
@@ -127,7 +174,32 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
return PREPROC_YYEOF;
text = yyget_text(scanner);
- TRACE("Parsing token %d, line %d, string %s.\n", token, lloc->first_line, debugstr_a(text));
+ lloc->filename = ctx->source_name;
+
+ if (ctx->last_was_newline)
+ {
+ switch (token)
+ {
+ case T_ENDIF:
+ case T_IF:
+ ctx->current_directive = token;
+ break;
+
+ default:
+ ctx->current_directive = 0;
+ }
+ }
+
+ ctx->last_was_newline = (token == T_NEWLINE);
+
+ TRACE("Parsing token %d, line %d, in directive %d, string %s.\n", token,
+ lloc->first_line, ctx->current_directive, debugstr_a(text));
+
+ if (!ctx->current_directive && !preproc_is_writing(ctx))
+ continue;
+
+ if (ctx->current_directive)
+ return return_token(token, lval, text);
vkd3d_string_buffer_printf(&ctx->buffer, "%s ", text);
}
@@ -148,12 +220,22 @@ int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info,
yylex_init_extra(&ctx, &ctx.scanner);
top_buffer = yy_scan_bytes(compile_info->source.code, compile_info->source.size, ctx.scanner);
+ ctx.last_was_newline = true;
preproc_yyparse(ctx.scanner, &ctx);
yy_delete_buffer(top_buffer, ctx.scanner);
yylex_destroy(ctx.scanner);
+ if (ctx.if_count)
+ {
+ const struct preproc_location loc = {.filename = ctx.source_name};
+
+ preproc_warning(&ctx, &loc, VKD3D_SHADER_WARNING_PP_UNTERMINATED_IF, "Unterminated #if block.");
+ }
+
+ vkd3d_free(ctx.if_stack);
+
if (ctx.error)
{
WARN("Failed to preprocess.\n");
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
index 88b855c6..4353d10c 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -72,11 +72,71 @@ static void preproc_error(struct preproc_ctx *ctx, const struct preproc_location
ctx->error = true;
}
+void preproc_warning(struct preproc_ctx *ctx, const struct preproc_location *loc,
+ enum vkd3d_shader_error error, const char *format, ...)
+{
+ va_list args;
+
+ set_location(ctx, loc);
+ va_start(args, format);
+ vkd3d_shader_vwarning(ctx->message_context, error, format, args);
+ va_end(args);
+}
+
static void yyerror(const YYLTYPE *loc, void *scanner, struct preproc_ctx *ctx, const char *string)
{
preproc_error(ctx, loc, VKD3D_SHADER_ERROR_PP_INVALID_SYNTAX, "%s", string);
}
+static bool preproc_was_writing(struct preproc_ctx *ctx)
+{
+ if (ctx->if_count < 2)
+ return true;
+ return ctx->if_stack[ctx->if_count - 2].current_true;
+}
+
+static bool preproc_push_if(struct preproc_ctx *ctx, bool condition)
+{
+ struct preproc_if_state *state;
+
+ if (!vkd3d_array_reserve((void **)&ctx->if_stack, &ctx->if_stack_size, ctx->if_count + 1, sizeof(*ctx->if_stack)))
+ return false;
+ state = &ctx->if_stack[ctx->if_count++];
+ state->current_true = condition && preproc_was_writing(ctx);
+ return true;
+}
+
+static int char_to_int(char c)
+{
+ if ('0' <= c && c <= '9')
+ return c - '0';
+ if ('A' <= c && c <= 'F')
+ return c - 'A' + 10;
+ if ('a' <= c && c <= 'f')
+ return c - 'a' + 10;
+ return -1;
+}
+
+static uint32_t preproc_parse_integer(const char *s)
+{
+ uint32_t base = 10, ret = 0;
+ int digit;
+
+ if (s[0] == '0')
+ {
+ base = 8;
+ if (s[1] == 'x' || s[1] == 'X')
+ {
+ base = 16;
+ s += 2;
+ }
+ }
+
+ while ((digit = char_to_int(*s++)) >= 0)
+ ret = ret * base + (uint32_t)digit;
+ return ret;
+}
+
}
%define api.location.type {struct preproc_location}
@@ -89,9 +149,53 @@ static void yyerror(const YYLTYPE *loc, void *scanner, struct preproc_ctx *ctx,
%parse-param {void *scanner}
%parse-param {struct preproc_ctx *ctx}
-%token T_TEXT
+%union
+{
+ char *string;
+ uint32_t integer;
+}
+
+%token <string> T_INTEGER
+%token <string> T_TEXT
+
+%token T_NEWLINE
+
+%token T_ENDIF "#endif"
+%token T_IF "#if"
+
+%type <integer> expr
%%
shader_text
: %empty
+ | shader_text directive
+ {
+ vkd3d_string_buffer_printf(&ctx->buffer, "\n");
+ }
+
+directive
+ : T_IF expr newline
+ {
+ if (!preproc_push_if(ctx, !!$2))
+ YYABORT;
+ }
+ | T_ENDIF newline
+ {
+ if (ctx->if_count)
+ --ctx->if_count;
+ else
+ preproc_warning(ctx, &@$, VKD3D_SHADER_WARNING_PP_INVALID_DIRECTIVE,
+ "Ignoring #endif without prior #if.");
+ }
+
+newline
+ : T_NEWLINE
+ | YYEOF
+
+expr
+ : T_INTEGER
+ {
+ $$ = preproc_parse_integer($1);
+ vkd3d_free($1);
+ }
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c
index eed0316c..ad456133 100644
--- a/libs/vkd3d-shader/vkd3d_shader_main.c
+++ b/libs/vkd3d-shader/vkd3d_shader_main.c
@@ -148,6 +148,21 @@ bool vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_cont
return true;
}
+void vkd3d_shader_vwarning(struct vkd3d_shader_message_context *context,
+ enum vkd3d_shader_error error, const char *format, va_list args)
+{
+ if (context->log_level < VKD3D_SHADER_LOG_WARNING)
+ return;
+
+ if (context->line)
+ vkd3d_string_buffer_printf(&context->messages, "%s:%u:%u: W%04u: ",
+ context->source_name, context->line, context->column, error);
+ else
+ vkd3d_string_buffer_printf(&context->messages, "%s: W%04u: ", context->source_name, error);
+ vkd3d_string_buffer_vprintf(&context->messages, format, args);
+ vkd3d_string_buffer_printf(&context->messages, "\n");
+}
+
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context,
enum vkd3d_shader_error error, const char *format, va_list args)
{
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h
index 5a022708..01a74ede 100644
--- a/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -81,6 +81,10 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_RS_MIXED_DESCRIPTOR_RANGE_TYPES = 3004,
VKD3D_SHADER_ERROR_PP_INVALID_SYNTAX = 4000,
+
+ VKD3D_SHADER_WARNING_PP_INVALID_DIRECTIVE = 5001,
+ VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE = 5003,
+ VKD3D_SHADER_WARNING_PP_UNTERMINATED_IF = 5005,
};
enum VKD3D_SHADER_INSTRUCTION_HANDLER
@@ -867,6 +871,8 @@ void vkd3d_shader_error(struct vkd3d_shader_message_context *context, enum vkd3d
const char *format, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context,
enum vkd3d_shader_error error, const char *format, va_list args) DECLSPEC_HIDDEN;
+void vkd3d_shader_vwarning(struct vkd3d_shader_message_context *context,
+ enum vkd3d_shader_error error, const char *format, va_list args) DECLSPEC_HIDDEN;
int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length,
struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c
index 61324fa9..77a7ea1a 100644
--- a/tests/hlsl_d3d12.c
+++ b/tests/hlsl_d3d12.c
@@ -414,7 +414,7 @@ static void test_preprocess(void)
hr = D3DPreprocess(test_include_top, strlen(test_include_top), NULL, NULL, &test_include_fail, &blob, &errors);
todo ok(hr == E_FAIL, "Got hr %#x.\n", hr);
todo ok(blob == (ID3D10Blob *)0xdeadbeef, "Expected no compiled shader blob.\n");
- todo ok(!!errors, "Expected non-NULL error blob.\n");
+ ok(!!errors, "Expected non-NULL error blob.\n");
if (errors)
{
if (vkd3d_test_state.debug_level)
--
2.29.2
Dec. 4, 2020
[PATCH vkd3d v2 4/5] vkd3d-shader: Handle preprocessor parsing errors.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/preproc.h | 11 +++++++
libs/vkd3d-shader/preproc.l | 39 +++++++++++++++++++++++-
libs/vkd3d-shader/preproc.y | 39 +++++++++++++++++++++++-
libs/vkd3d-shader/vkd3d_shader_private.h | 2 ++
4 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.h b/libs/vkd3d-shader/preproc.h
index cbd93229..769b8c23 100644
--- a/libs/vkd3d-shader/preproc.h
+++ b/libs/vkd3d-shader/preproc.h
@@ -23,11 +23,22 @@
#include "vkd3d_shader_private.h"
+struct preproc_location
+{
+ const char *filename;
+ unsigned int first_line, first_column;
+};
+
struct preproc_ctx
{
void *scanner;
+ struct vkd3d_shader_message_context *message_context;
struct vkd3d_string_buffer buffer;
+ unsigned int line, column;
+ const char *source_name;
+
+ bool error;
};
#endif
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index f931292b..c0c6b13a 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -27,6 +27,10 @@
#define YY_DECL static int preproc_lexer_lex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
+static void update_location(struct preproc_ctx *ctx);
+
+#define YY_USER_ACTION update_location(yyget_extra(yyscanner));
+
%}
%option 8bit
@@ -88,6 +92,28 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
%%
+static void update_location(struct preproc_ctx *ctx)
+{
+ unsigned int i, leng = yyget_leng(ctx->scanner);
+ const char *text = yyget_text(ctx->scanner);
+
+ /* We want to do this here, rather than before calling yylex(), because
+ * some tokens are skipped by the lexer. */
+
+ yyget_lloc(ctx->scanner)->first_line = ctx->line;
+ yyget_lloc(ctx->scanner)->first_column = ctx->column;
+
+ for (i = 0; i < leng; ++i)
+ {
+ ++ctx->column;
+ if (text[i] == '\n')
+ {
+ ctx->column = 1;
+ ++ctx->line;
+ }
+ }
+}
+
int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
{
struct preproc_ctx *ctx = yyget_extra(scanner);
@@ -101,7 +127,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
return PREPROC_YYEOF;
text = yyget_text(scanner);
- TRACE("Parsing token %d, string %s.\n", token, debugstr_a(text));
+ TRACE("Parsing token %d, line %d, string %s.\n", token, lloc->first_line, debugstr_a(text));
vkd3d_string_buffer_printf(&ctx->buffer, "%s ", text);
}
@@ -115,6 +141,10 @@ int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info,
void *output_code;
vkd3d_string_buffer_init(&ctx.buffer);
+ ctx.message_context = message_context;
+ ctx.source_name = compile_info->source_name ? compile_info->source_name : "<anonymous>";
+ ctx.line = 1;
+ ctx.column = 1;
yylex_init_extra(&ctx, &ctx.scanner);
top_buffer = yy_scan_bytes(compile_info->source.code, compile_info->source.size, ctx.scanner);
@@ -124,6 +154,13 @@ int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info,
yy_delete_buffer(top_buffer, ctx.scanner);
yylex_destroy(ctx.scanner);
+ if (ctx.error)
+ {
+ WARN("Failed to preprocess.\n");
+ vkd3d_string_buffer_cleanup(&ctx.buffer);
+ return VKD3D_ERROR_INVALID_SHADER;
+ }
+
if (!(output_code = vkd3d_malloc(ctx.buffer.content_size)))
{
vkd3d_string_buffer_cleanup(&ctx.buffer);
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
index 92448f24..88b855c6 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -36,13 +36,50 @@ int preproc_yylex(PREPROC_YYSTYPE *yylval_param, PREPROC_YYLTYPE *yylloc_param,
%code
{
+#define YYLLOC_DEFAULT(cur, rhs, n) \
+ do \
+ { \
+ if (n) \
+ { \
+ (cur).filename = YYRHSLOC(rhs, 1).filename; \
+ (cur).first_line = YYRHSLOC(rhs, 1).first_line; \
+ (cur).first_column = YYRHSLOC(rhs, 1).first_column; \
+ } \
+ else \
+ { \
+ (cur).filename = YYRHSLOC(rhs, 0).filename; \
+ (cur).first_line = YYRHSLOC(rhs, 0).first_line; \
+ (cur).first_column = YYRHSLOC(rhs, 0).first_column; \
+ } \
+ } while (0)
+
+static void set_location(struct preproc_ctx *ctx, const struct preproc_location *loc)
+{
+ ctx->message_context->source_name = loc->filename;
+ ctx->message_context->line = loc->first_line;
+ ctx->message_context->column = loc->first_column;
+}
+
+static void preproc_error(struct preproc_ctx *ctx, const struct preproc_location *loc,
+ enum vkd3d_shader_error error, const char *format, ...)
+{
+ va_list args;
+
+ set_location(ctx, loc);
+ va_start(args, format);
+ vkd3d_shader_verror(ctx->message_context, error, format, args);
+ va_end(args);
+ ctx->error = true;
+}
+
static void yyerror(const YYLTYPE *loc, void *scanner, struct preproc_ctx *ctx, const char *string)
{
- FIXME("Error reporting is not implemented.\n");
+ preproc_error(ctx, loc, VKD3D_SHADER_ERROR_PP_INVALID_SYNTAX, "%s", string);
}
}
+%define api.location.type {struct preproc_location}
%define api.prefix {preproc_yy}
%define api.pure full
%define parse.error verbose
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h
index 83038384..5a022708 100644
--- a/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -79,6 +79,8 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_RS_INVALID_ROOT_PARAMETER_TYPE = 3002,
VKD3D_SHADER_ERROR_RS_INVALID_DESCRIPTOR_RANGE_TYPE = 3003,
VKD3D_SHADER_ERROR_RS_MIXED_DESCRIPTOR_RANGE_TYPES = 3004,
+
+ VKD3D_SHADER_ERROR_PP_INVALID_SYNTAX = 4000,
};
enum VKD3D_SHADER_INSTRUCTION_HANDLER
--
2.29.2
Dec. 4, 2020
[PATCH vkd3d v2 3/5] vkd3d-shader: Preserve some tokens verbatim for HLSL.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/preproc.l | 22 ++++++++++++++++++++++
tests/hlsl_d3d12.c | 15 +++++++++------
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 966c11b0..f931292b 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -47,6 +47,7 @@
%s CXX_COMMENT
WS [ \t]
+IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
%%
@@ -61,6 +62,27 @@ WS [ \t]
<C_COMMENT,CXX_COMMENT><<EOF>> {yy_pop_state(yyscanner);}
<C_COMMENT,CXX_COMMENT>. {}
+<INITIAL>{IDENTIFIER} {return T_TEXT;}
+
+<INITIAL>[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;}
+<INITIAL>[0-9]+\.([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;}
+<INITIAL>[0-9]+([eE][+-]?[0-9]+)?[hHfF] {return T_TEXT;}
+<INITIAL>[0-9]+[eE][+-]?[0-9]+ {return T_TEXT;}
+<INITIAL>0[xX][0-9a-fA-f]+[ul]{0,2} {return T_TEXT;}
+<INITIAL>0[0-7]*[ul]{0,2} {return T_TEXT;}
+<INITIAL>[1-9][0-9]*[ul]{0,2} {return T_TEXT;}
+
+<INITIAL>"&&" {return T_TEXT;}
+<INITIAL>"||" {return T_TEXT;}
+<INITIAL>"++" {return T_TEXT;}
+<INITIAL>"--" {return T_TEXT;}
+<INITIAL>"<<"=? {return T_TEXT;}
+<INITIAL>">>"=? {return T_TEXT;}
+<INITIAL>[-+*/%&|^=><!]= {return T_TEXT;}
+
+ /* C strings (including escaped quotes). */
+<INITIAL>\"([^"\\]|\\.)*\" {return T_TEXT;}
+
<INITIAL>{WS}+ {}
<INITIAL>. {return T_TEXT;}
diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c
index 787355ba..61324fa9 100644
--- a/tests/hlsl_d3d12.c
+++ b/tests/hlsl_d3d12.c
@@ -43,7 +43,7 @@ static void check_preprocess_(int line, const char *source, const D3D_SHADER_MAC
ok_(line)(vkd3d_memmem(code, size, present, strlen(present)),
"\"%s\" not found in preprocessed shader.\n", present);
if (absent)
- assert_that_(line)(!vkd3d_memmem(code, size, absent, strlen(absent)),
+ ok_(line)(!vkd3d_memmem(code, size, absent, strlen(absent)),
"\"%s\" found in preprocessed shader.\n", absent);
ID3D10Blob_Release(blob);
}
@@ -349,8 +349,10 @@ static void test_preprocess(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
+ if (i == 43)
+ continue;
vkd3d_test_set_context("Source \"%s\"", tests[i].source);
- todo_if (i != 5 && i != 8 && i != 42)
+ todo_if (i <= 4 || (i >= 9 && i <= 14))
check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
}
vkd3d_test_set_context(NULL);
@@ -361,10 +363,10 @@ static void test_preprocess(void)
macros[1].Definition = NULL;
todo check_preprocess("KEY", macros, NULL, "value", "KEY");
- todo check_preprocess("#undef KEY\nKEY", macros, NULL, "KEY", "value");
+ check_preprocess("#undef KEY\nKEY", macros, NULL, "KEY", "value");
macros[0].Name = NULL;
- todo check_preprocess("KEY", macros, NULL, "KEY", "value");
+ check_preprocess("KEY", macros, NULL, "KEY", "value");
macros[0].Name = "KEY";
macros[0].Definition = NULL;
@@ -376,7 +378,7 @@ static void test_preprocess(void)
macros[0].Name = "KEY(a)";
macros[0].Definition = "value";
- todo check_preprocess("KEY(a)", macros, NULL, "KEY", "value");
+ check_preprocess("KEY(a)", macros, NULL, "KEY", "value");
macros[0].Name = "KEY";
macros[0].Definition = "value1";
@@ -398,7 +400,8 @@ static void test_preprocess(void)
macros[1].Definition = "KEY2";
todo check_preprocess("KEY", macros, NULL, "value", NULL);
- todo check_preprocess(test_include_top, NULL, &test_include, "pass", "fail");
+ if (0)
+ todo check_preprocess(test_include_top, NULL, &test_include, "pass", "fail");
ok(!refcount_file1, "Got %d references to file1.\n", refcount_file1);
ok(!refcount_file2, "Got %d references to file1.\n", refcount_file2);
ok(!refcount_file3, "Got %d references to file1.\n", refcount_file3);
--
2.29.2
Dec. 4, 2020
[PATCH vkd3d v2 2/5] vkd3d-shader: Parse comments in the preprocessor.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/preproc.l | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 1ae43a8d..966c11b0 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -36,16 +36,33 @@
%option never-interactive
%option noinput
%option nounput
+%option noyy_top_state
%option noyywrap
%option prefix="preproc_yy"
%option reentrant
+%option stack
+
+ /* Because these can both be terminated by EOF, we need states for them. */
+%s C_COMMENT
+%s CXX_COMMENT
WS [ \t]
%%
-{WS}+ {}
-. {return T_TEXT;}
+<INITIAL>"//" {yy_push_state(CXX_COMMENT, yyscanner);}
+<INITIAL>"/*" {yy_push_state(C_COMMENT, yyscanner);}
+<CXX_COMMENT>\\\r?\n {}
+<CXX_COMMENT>\n {
+ yy_pop_state(yyscanner);
+ return T_TEXT;
+ }
+<C_COMMENT>"*/" {yy_pop_state(yyscanner);}
+<C_COMMENT,CXX_COMMENT><<EOF>> {yy_pop_state(yyscanner);}
+<C_COMMENT,CXX_COMMENT>. {}
+
+<INITIAL>{WS}+ {}
+<INITIAL>. {return T_TEXT;}
%%
--
2.29.2
Dec. 4, 2020
[PATCH vkd3d v2 1/5] vkd3d-shader: Implement an initial pass-through HLSL preprocessor.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
v2: quote some autoconf macros, use AS_IF, try to fix out-of-tree builds
.gitignore | 3 +
Makefile.am | 25 +++++-
configure.ac | 6 ++
libs/vkd3d-shader/preproc.h | 33 ++++++++
libs/vkd3d-shader/preproc.l | 99 ++++++++++++++++++++++++
libs/vkd3d-shader/preproc.y | 60 ++++++++++++++
libs/vkd3d-shader/vkd3d_shader_main.c | 16 +++-
libs/vkd3d-shader/vkd3d_shader_private.h | 8 ++
tests/hlsl_d3d12.c | 31 ++++----
9 files changed, 260 insertions(+), 21 deletions(-)
create mode 100644 libs/vkd3d-shader/preproc.h
create mode 100644 libs/vkd3d-shader/preproc.l
create mode 100644 libs/vkd3d-shader/preproc.y
diff --git a/.gitignore b/.gitignore
index 63a9ffc6..b6d29d19 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,10 @@ vkd3d-*.tar.xz
*.log
*.o
*.pc
+*.tab.c
+*.tab.h
*.trs
+*.yy.c
*~
.deps
diff --git a/Makefile.am b/Makefile.am
index 5a6e4dc9..46eacbd9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -108,6 +108,29 @@ libvkd3d_common_la_SOURCES = \
lib_LTLIBRARIES = libvkd3d-shader.la libvkd3d.la libvkd3d-utils.la
+VKD3D_V_FLEX = $(vkd3d_v_flex_(a)AM_V@)
+vkd3d_v_flex_ = $(vkd3d_v_flex_(a)AM_DEFAULT_V@)
+vkd3d_v_flex_0 = @echo " FLEX " $@;
+vkd3d_v_flex_1 =
+
+VKD3D_V_BISON = $(vkd3d_v_bison_(a)AM_V@)
+vkd3d_v_bison_ = $(vkd3d_v_bison_(a)AM_DEFAULT_V@)
+vkd3d_v_bison_0 = @echo " BISON " $@;
+vkd3d_v_bison_1 =
+
+libs/vkd3d-shader/preproc.yy.c: libs/vkd3d-shader/preproc.l
+ $(VKD3D_V_FLEX)$(FLEX) $(LFLAGS) -o $@ $<
+
+libs/vkd3d-shader/preproc.tab.c libs/vkd3d-shader/preproc.tab.h &: libs/vkd3d-shader/preproc.y
+ $(VKD3D_V_BISON)$(BISON) $(YFLAGS) -d -o $@ $<
+
+BUILT_SOURCES += libs/vkd3d-shader/preproc.tab.h
+
+nodist_libvkd3d_shader_la_SOURCES = \
+ libs/vkd3d-shader/preproc.tab.c \
+ libs/vkd3d-shader/preproc.tab.h \
+ libs/vkd3d-shader/preproc.yy.c
+
libvkd3d_shader_la_SOURCES = \
include/private/list.h \
include/private/rbtree.h \
@@ -122,7 +145,7 @@ libvkd3d_shader_la_SOURCES = \
libs/vkd3d-shader/vkd3d_shader.map \
libs/vkd3d-shader/vkd3d_shader_main.c \
libs/vkd3d-shader/vkd3d_shader_private.h
-libvkd3d_shader_la_CFLAGS = $(AM_CFLAGS) @SPIRV_TOOLS_CFLAGS@
+libvkd3d_shader_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libs/vkd3d-shader @SPIRV_TOOLS_CFLAGS@
libvkd3d_shader_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0
libvkd3d_shader_la_LIBADD = libvkd3d-common.la @SPIRV_TOOLS_LIBS@
if HAVE_LD_VERSION_SCRIPT
diff --git a/configure.ac b/configure.ac
index 2f22b05f..b7902b63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,12 @@ AC_PROG_MKDIR_P
VKD3D_PROG_WIDL(3, 20)
AS_IF([test "x$WIDL" = "xno"], [AC_MSG_WARN([widl is required to build header files.])])
+AC_CHECK_PROGS([FLEX], [flex], [none])
+AS_IF([test "$FLEX" = "none"], [AC_MSG_ERROR([no suitable flex found. Please install the 'flex' package.])])
+
+AC_CHECK_PROGS([BISON], [bison], [none])
+AS_IF([test "$BISON" = "none"], [AC_MSG_ERROR([no suitable bison found. Please install the 'bison' package.])])
+
DX_PS_FEATURE([OFF])
DX_INIT_DOXYGEN([vkd3d], [Doxyfile], [doc])
AC_CONFIG_FILES([Doxyfile])
diff --git a/libs/vkd3d-shader/preproc.h b/libs/vkd3d-shader/preproc.h
new file mode 100644
index 00000000..cbd93229
--- /dev/null
+++ b/libs/vkd3d-shader/preproc.h
@@ -0,0 +1,33 @@
+/*
+ * HLSL preprocessor
+ *
+ * Copyright 2020 Zebediah Figura for CodeWeavers
+ *
+ * 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
+ */
+
+#ifndef __VKD3D_SHADER_PREPROC_H
+#define __VKD3D_SHADER_PREPROC_H
+
+#include "vkd3d_shader_private.h"
+
+struct preproc_ctx
+{
+ void *scanner;
+
+ struct vkd3d_string_buffer buffer;
+};
+
+#endif
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
new file mode 100644
index 00000000..1ae43a8d
--- /dev/null
+++ b/libs/vkd3d-shader/preproc.l
@@ -0,0 +1,99 @@
+/*
+ * HLSL preprocessor
+ *
+ * Copyright 2020 Zebediah Figura for CodeWeavers
+ *
+ * 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
+ */
+
+%{
+
+#include "preproc.tab.h"
+
+#define YYSTYPE PREPROC_YYSTYPE
+#define YYLTYPE PREPROC_YYLTYPE
+
+#define YY_DECL static int preproc_lexer_lex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
+
+%}
+
+%option 8bit
+%option bison-bridge
+%option bison-locations
+%option extra-type="struct preproc_ctx *"
+%option never-interactive
+%option noinput
+%option nounput
+%option noyywrap
+%option prefix="preproc_yy"
+%option reentrant
+
+WS [ \t]
+
+%%
+
+{WS}+ {}
+. {return T_TEXT;}
+
+%%
+
+int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
+{
+ struct preproc_ctx *ctx = yyget_extra(scanner);
+
+ for (;;)
+ {
+ const char *text;
+ int token;
+
+ if (!(token = preproc_lexer_lex(lval, lloc, scanner)))
+ return PREPROC_YYEOF;
+ text = yyget_text(scanner);
+
+ TRACE("Parsing token %d, string %s.\n", token, debugstr_a(text));
+
+ vkd3d_string_buffer_printf(&ctx->buffer, "%s ", text);
+ }
+}
+
+int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info,
+ struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
+{
+ struct preproc_ctx ctx = {0};
+ YY_BUFFER_STATE top_buffer;
+ void *output_code;
+
+ vkd3d_string_buffer_init(&ctx.buffer);
+
+ yylex_init_extra(&ctx, &ctx.scanner);
+ top_buffer = yy_scan_bytes(compile_info->source.code, compile_info->source.size, ctx.scanner);
+
+ preproc_yyparse(ctx.scanner, &ctx);
+
+ yy_delete_buffer(top_buffer, ctx.scanner);
+ yylex_destroy(ctx.scanner);
+
+ if (!(output_code = vkd3d_malloc(ctx.buffer.content_size)))
+ {
+ vkd3d_string_buffer_cleanup(&ctx.buffer);
+ return VKD3D_ERROR_OUT_OF_MEMORY;
+ }
+ memcpy(output_code, ctx.buffer.buffer, ctx.buffer.content_size);
+ out->size = ctx.buffer.content_size;
+ out->code = output_code;
+ vkd3d_string_buffer_trace(&ctx.buffer);
+ vkd3d_string_buffer_cleanup(&ctx.buffer);
+ return VKD3D_OK;
+}
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
new file mode 100644
index 00000000..92448f24
--- /dev/null
+++ b/libs/vkd3d-shader/preproc.y
@@ -0,0 +1,60 @@
+/*
+ * HLSL preprocessor
+ *
+ * Copyright 2020 Zebediah Figura for CodeWeavers
+ *
+ * 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
+ */
+
+%code requires
+{
+
+#include "vkd3d_shader_private.h"
+#include "preproc.h"
+
+}
+
+%code provides
+{
+
+int preproc_yylex(PREPROC_YYSTYPE *yylval_param, PREPROC_YYLTYPE *yylloc_param, void *scanner);
+
+}
+
+%code
+{
+
+static void yyerror(const YYLTYPE *loc, void *scanner, struct preproc_ctx *ctx, const char *string)
+{
+ FIXME("Error reporting is not implemented.\n");
+}
+
+}
+
+%define api.prefix {preproc_yy}
+%define api.pure full
+%define parse.error verbose
+%expect 0
+%locations
+%lex-param {yyscan_t scanner}
+%parse-param {void *scanner}
+%parse-param {struct preproc_ctx *ctx}
+
+%token T_TEXT
+
+%%
+
+shader_text
+ : %empty
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c
index 1a029246..eed0316c 100644
--- a/libs/vkd3d-shader/vkd3d_shader_main.c
+++ b/libs/vkd3d-shader/vkd3d_shader_main.c
@@ -78,8 +78,7 @@ int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *
}
}
-static int VKD3D_PRINTF_FUNC(2, 3) vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer,
- const char *format, ...)
+int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer, const char *format, ...)
{
va_list args;
int ret;
@@ -91,7 +90,7 @@ static int VKD3D_PRINTF_FUNC(2, 3) vkd3d_string_buffer_printf(struct vkd3d_strin
return ret;
}
-static void vkd3d_string_buffer_trace_(const struct vkd3d_string_buffer *buffer, const char *function)
+void vkd3d_string_buffer_trace_(const struct vkd3d_string_buffer *buffer, const char *function)
{
const char *p, *q, *end = buffer->buffer + buffer->content_size;
@@ -1154,6 +1153,7 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types(
int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out, char **messages)
{
+ struct vkd3d_shader_message_context message_context;
int ret;
TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
@@ -1164,5 +1164,13 @@ int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info
if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0)
return ret;
- return VKD3D_ERROR_NOT_IMPLEMENTED;
+ vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
+
+ ret = preproc_lexer_parse(compile_info, out, &message_context);
+
+ vkd3d_shader_message_context_trace_messages(&message_context);
+ if (!vkd3d_shader_message_context_copy_messages(&message_context, messages))
+ ret = VKD3D_ERROR_OUT_OF_MEMORY;
+ vkd3d_shader_message_context_cleanup(&message_context);
+ return ret;
}
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h
index 5ae5724a..83038384 100644
--- a/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -837,6 +837,11 @@ struct vkd3d_string_buffer
enum vkd3d_result vkd3d_dxbc_binary_to_text(void *data, struct vkd3d_shader_code *out) DECLSPEC_HIDDEN;
void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer) DECLSPEC_HIDDEN;
void vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer) DECLSPEC_HIDDEN;
+int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer,
+ const char *format, ...) VKD3D_PRINTF_FUNC(2, 3) DECLSPEC_HIDDEN;
+#define vkd3d_string_buffer_trace(buffer) \
+ vkd3d_string_buffer_trace_(buffer, __FUNCTION__)
+void vkd3d_string_buffer_trace_(const struct vkd3d_string_buffer *buffer, const char *function) DECLSPEC_HIDDEN;
int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *format, va_list args) DECLSPEC_HIDDEN;
struct vkd3d_shader_message_context
@@ -882,6 +887,9 @@ void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) DECLSPEC_
void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]) DECLSPEC_HIDDEN;
+int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info,
+ struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN;
+
static inline enum vkd3d_shader_component_type vkd3d_component_type_from_data_type(
enum vkd3d_data_type data_type)
{
diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c
index 4f4cc37f..787355ba 100644
--- a/tests/hlsl_d3d12.c
+++ b/tests/hlsl_d3d12.c
@@ -30,22 +30,20 @@ static void check_preprocess_(int line, const char *source, const D3D_SHADER_MAC
HRESULT hr;
hr = D3DPreprocess(source, strlen(source), NULL, macros, include, &blob, &errors);
- todo ok_(line)(hr == S_OK, "Failed to preprocess shader, hr %#x.\n", hr);
+ assert_that_(line)(hr == S_OK, "Failed to preprocess shader, hr %#x.\n", hr);
if (errors)
{
if (vkd3d_test_state.debug_level)
trace_(line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
ID3D10Blob_Release(errors);
}
- if (hr != S_OK)
- return;
code = ID3D10Blob_GetBufferPointer(blob);
size = ID3D10Blob_GetBufferSize(blob);
if (present)
ok_(line)(vkd3d_memmem(code, size, present, strlen(present)),
"\"%s\" not found in preprocessed shader.\n", present);
if (absent)
- ok_(line)(!vkd3d_memmem(code, size, absent, strlen(absent)),
+ assert_that_(line)(!vkd3d_memmem(code, size, absent, strlen(absent)),
"\"%s\" found in preprocessed shader.\n", absent);
ID3D10Blob_Release(blob);
}
@@ -352,7 +350,8 @@ static void test_preprocess(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
vkd3d_test_set_context("Source \"%s\"", tests[i].source);
- check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
+ todo_if (i != 5 && i != 8 && i != 42)
+ check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
}
vkd3d_test_set_context(NULL);
@@ -360,16 +359,16 @@ static void test_preprocess(void)
macros[0].Definition = "value";
macros[1].Name = NULL;
macros[1].Definition = NULL;
- check_preprocess("KEY", macros, NULL, "value", "KEY");
+ todo check_preprocess("KEY", macros, NULL, "value", "KEY");
- check_preprocess("#undef KEY\nKEY", macros, NULL, "KEY", "value");
+ todo check_preprocess("#undef KEY\nKEY", macros, NULL, "KEY", "value");
macros[0].Name = NULL;
- check_preprocess("KEY", macros, NULL, "KEY", "value");
+ todo check_preprocess("KEY", macros, NULL, "KEY", "value");
macros[0].Name = "KEY";
macros[0].Definition = NULL;
- check_preprocess("KEY", macros, NULL, NULL, "KEY");
+ todo check_preprocess("KEY", macros, NULL, NULL, "KEY");
macros[0].Name = "0";
macros[0].Definition = "value";
@@ -377,7 +376,7 @@ static void test_preprocess(void)
macros[0].Name = "KEY(a)";
macros[0].Definition = "value";
- check_preprocess("KEY(a)", macros, NULL, "KEY", "value");
+ todo check_preprocess("KEY(a)", macros, NULL, "KEY", "value");
macros[0].Name = "KEY";
macros[0].Definition = "value1";
@@ -385,33 +384,33 @@ static void test_preprocess(void)
macros[1].Definition = "value2";
macros[2].Name = NULL;
macros[2].Definition = NULL;
- check_preprocess("KEY", macros, NULL, "value2", NULL);
+ todo check_preprocess("KEY", macros, NULL, "value2", NULL);
macros[0].Name = "KEY";
macros[0].Definition = "KEY2";
macros[1].Name = "KEY2";
macros[1].Definition = "value";
- check_preprocess("KEY", macros, NULL, "value", NULL);
+ todo check_preprocess("KEY", macros, NULL, "value", NULL);
macros[0].Name = "KEY2";
macros[0].Definition = "value";
macros[1].Name = "KEY";
macros[1].Definition = "KEY2";
- check_preprocess("KEY", macros, NULL, "value", NULL);
+ todo check_preprocess("KEY", macros, NULL, "value", NULL);
- check_preprocess(test_include_top, NULL, &test_include, "pass", "fail");
+ todo check_preprocess(test_include_top, NULL, &test_include, "pass", "fail");
ok(!refcount_file1, "Got %d references to file1.\n", refcount_file1);
ok(!refcount_file2, "Got %d references to file1.\n", refcount_file2);
ok(!refcount_file3, "Got %d references to file1.\n", refcount_file3);
todo ok(include_count_file2 == 2, "file2 was included %u times.\n", include_count_file2);
/* Macro invocation spread across multiple files. */
- check_preprocess(test_include2_top, NULL, &test_include, "pass", NULL);
+ todo check_preprocess(test_include2_top, NULL, &test_include, "pass", NULL);
blob = errors = (ID3D10Blob *)0xdeadbeef;
hr = D3DPreprocess(test_include_top, strlen(test_include_top), NULL, NULL, &test_include_fail, &blob, &errors);
todo ok(hr == E_FAIL, "Got hr %#x.\n", hr);
- ok(blob == (ID3D10Blob *)0xdeadbeef, "Expected no compiled shader blob.\n");
+ todo ok(blob == (ID3D10Blob *)0xdeadbeef, "Expected no compiled shader blob.\n");
todo ok(!!errors, "Expected non-NULL error blob.\n");
if (errors)
{
--
2.29.2
Dec. 4, 2020
Re: [PATCH 2/2] xmllite: Drop superfluous casts to self.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
Dec. 4, 2020
Re: [PATCH 1/2] xmllite: Use a string literal for an empty string.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
Dec. 4, 2020
Re: [PATCH] mfplat: Zero-initialize the device manager object.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
Dec. 4, 2020
Re: [PATCH 07/17] winegstreamer: Introduce color conversion transform.
by Derek Lesho
On 12/3/20 10:40 PM, Zebediah Figura (she/her) wrote:
> On 12/3/20 3:55 PM, Derek Lesho wrote:
>> Serves as a wrapper of videoconvert, and roughly fills the roll of Windows' CColorConverterDMO.
> Why can't this be CColorConvertDMO?
Nothing specific, I don't think there's any fundamental differences here
to what a CColorConvertDMO implementation would like. While I haven't
tested any applications that manually use CColorConvertDMO, I don't
think we'd run into any problems with incompatibility if/when they come up.
Dec. 4, 2020
Re: [PATCH 03/17] winegstreamer: Implement ::Process(Input/Output) for audio conversion transform.
by Derek Lesho
On 12/3/20 10:26 PM, Zebediah Figura (she/her) wrote:
>
>> + g_signal_emit_by_name(converter->appsink, "pull-sample", &sample);
> I'm not fully familiar with mfplat, but this call may block, and it
> doesn't look like ProcessOutput() is supposed to. You probably want
> "try-pull-sample" instead.
Actually, with sync MFTs, ::ProcessOutput is blocking until a sample is
yielded or an error occurs. In MFT writing guides from Microsoft I've
seen, ::ProcessInput just buts the data in a buffer, and ::ProcessOutput
actually invokes the functionality of the transform. This should match
that behavior pretty closely.
Dec. 4, 2020
Re: [PATCH 07/17] winegstreamer: Introduce color conversion transform.
by Zebediah Figura (she/her)
On 12/3/20 3:55 PM, Derek Lesho wrote:
> Serves as a wrapper of videoconvert, and roughly fills the roll of Windows' CColorConverterDMO.
Why can't this be CColorConvertDMO?
>
> Signed-off-by: Derek Lesho <dlesho(a)codeweavers.com>
> ---
> dlls/winegstreamer/Makefile.in | 1 +
> dlls/winegstreamer/colorconvert.c | 302 +++++++++++++++++++
> dlls/winegstreamer/gst_private.h | 1 +
> dlls/winegstreamer/mfplat.c | 3 +
> dlls/winegstreamer/winegstreamer_classes.idl | 6 +
> 5 files changed, 313 insertions(+)
> create mode 100644 dlls/winegstreamer/colorconvert.c
>
> diff --git a/dlls/winegstreamer/Makefile.in b/dlls/winegstreamer/Makefile.in
> index 0b3229160b9..5395d6fd501 100644
> --- a/dlls/winegstreamer/Makefile.in
> +++ b/dlls/winegstreamer/Makefile.in
> @@ -7,6 +7,7 @@ PARENTSRC = ../strmbase
>
> C_SRCS = \
> audioconvert.c \
> + colorconvert.c \
> filter.c \
> gst_cbs.c \
> gstdemux.c \
> diff --git a/dlls/winegstreamer/colorconvert.c b/dlls/winegstreamer/colorconvert.c
> new file mode 100644
> index 00000000000..8d0823fc0dc
> --- /dev/null
> +++ b/dlls/winegstreamer/colorconvert.c
> @@ -0,0 +1,302 @@
> +/* GStreamer Color Converter
> + *
> + * Copyright 2020 Derek Lesho
> + *
> + * 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
> + */
> +
> +#include "config.h"
> +
> +#include "gst_private.h"
> +
> +#include "mfapi.h"
> +#include "mferror.h"
> +#include "mfidl.h"
> +
> +#include "wine/debug.h"
> +#include "wine/heap.h"
> +
> +WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
> +
> +struct color_converter
> +{
> + IMFTransform IMFTransform_iface;
> + LONG refcount;
> +};
> +
> +static struct color_converter *impl_color_converter_from_IMFTransform(IMFTransform *iface)
> +{
> + return CONTAINING_RECORD(iface, struct color_converter, IMFTransform_iface);
> +}
> +
> +static HRESULT WINAPI color_converter_QueryInterface(IMFTransform *iface, REFIID riid, void **obj)
> +{
> + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
> +
> + if (IsEqualIID(riid, &IID_IMFTransform) ||
> + IsEqualIID(riid, &IID_IUnknown))
> + {
> + *obj = iface;
> + IMFTransform_AddRef(iface);
> + return S_OK;
> + }
> +
> + WARN("Unsupported %s.\n", debugstr_guid(riid));
> + *obj = NULL;
> + return E_NOINTERFACE;
> +}
> +
> +static ULONG WINAPI color_converter_AddRef(IMFTransform *iface)
> +{
> + struct color_converter *transform = impl_color_converter_from_IMFTransform(iface);
> + ULONG refcount = InterlockedIncrement(&transform->refcount);
> +
> + TRACE("%p, refcount %u.\n", iface, refcount);
> +
> + return refcount;
> +}
> +
> +static ULONG WINAPI color_converter_Release(IMFTransform *iface)
> +{
> + struct color_converter *transform = impl_color_converter_from_IMFTransform(iface);
> + ULONG refcount = InterlockedDecrement(&transform->refcount);
> +
> + TRACE("%p, refcount %u.\n", iface, refcount);
> +
> + if (!refcount)
> + {
> + heap_free(transform);
> + }
> +
> + return refcount;
> +}
> +
> +static HRESULT WINAPI color_converter_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, DWORD *input_maximum,
> + DWORD *output_minimum, DWORD *output_maximum)
> +{
> + TRACE("%p, %p, %p, %p, %p.\n", iface, input_minimum, input_maximum, output_minimum, output_maximum);
> +
> + *input_minimum = *input_maximum = *output_minimum = *output_maximum = 1;
> +
> + return S_OK;
> +}
> +
> +static HRESULT WINAPI color_converter_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs)
> +{
> + TRACE("%p, %p, %p.\n", iface, inputs, outputs);
> +
> + *inputs = *outputs = 1;
> +
> + return S_OK;
> +}
> +
> +static HRESULT WINAPI color_converter_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs,
> + DWORD output_size, DWORD *outputs)
> +{
> + TRACE("%p %u %p %u %p.\n", iface, input_size, inputs, output_size, outputs);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info)
> +{
> + FIXME("%p %u %p.\n", iface, id, info);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info)
> +{
> + FIXME("%p %u %p.\n", iface, id, info);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetAttributes(IMFTransform *iface, IMFAttributes **attributes)
> +{
> + FIXME("%p, %p.\n", iface, attributes);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetInputStreamAttributes(IMFTransform *iface, DWORD id,
> + IMFAttributes **attributes)
> +{
> + FIXME("%p, %u, %p.\n", iface, id, attributes);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetOutputStreamAttributes(IMFTransform *iface, DWORD id,
> + IMFAttributes **attributes)
> +{
> + FIXME("%p, %u, %p.\n", iface, id, attributes);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_DeleteInputStream(IMFTransform *iface, DWORD id)
> +{
> + TRACE("%p, %u.\n", iface, id);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids)
> +{
> + TRACE("%p, %u, %p.\n", iface, streams, ids);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index,
> + IMFMediaType **type)
> +{
> + FIXME("%p, %u, %u, %p.\n", iface, id, index, type);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index,
> + IMFMediaType **type)
> +{
> + FIXME("%p, %u, %u, %p.\n", iface, id, index, type);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
> +{
> + FIXME("%p, %u, %p, %#x.\n", iface, id, type, flags);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
> +{
> + FIXME("%p, %u, %p, %#x.\n", iface, id, type, flags);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
> +{
> + FIXME("%p, %u, %p.\n", iface, id, type);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
> +{
> + FIXME("%p, %u, %p.\n", iface, id, type);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)
> +{
> + FIXME("%p, %u, %p.\n", iface, id, flags);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_GetOutputStatus(IMFTransform *iface, DWORD *flags)
> +{
> + FIXME("%p, %p.\n", iface, flags);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper)
> +{
> + FIXME("%p, %s, %s.\n", iface, wine_dbgstr_longlong(lower), wine_dbgstr_longlong(upper));
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event)
> +{
> + TRACE("%p, %u, %p.\n", iface, id, event);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param)
> +{
> + FIXME("%p, %u %lu.\n", iface, message, param);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags)
> +{
> + FIXME("%p, %u, %p, %#x.\n", iface, id, sample, flags);
> +
> + return E_NOTIMPL;
> +}
> +
> +static HRESULT WINAPI color_converter_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count,
> + MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status)
> +{
> + FIXME("%p, %#x, %u, %p, %p.\n", iface, flags, count, samples, status);
> +
> + return E_NOTIMPL;
> +}
> +
> +static const IMFTransformVtbl color_converter_vtbl =
> +{
> + color_converter_QueryInterface,
> + color_converter_AddRef,
> + color_converter_Release,
> + color_converter_GetStreamLimits,
> + color_converter_GetStreamCount,
> + color_converter_GetStreamIDs,
> + color_converter_GetInputStreamInfo,
> + color_converter_GetOutputStreamInfo,
> + color_converter_GetAttributes,
> + color_converter_GetInputStreamAttributes,
> + color_converter_GetOutputStreamAttributes,
> + color_converter_DeleteInputStream,
> + color_converter_AddInputStreams,
> + color_converter_GetInputAvailableType,
> + color_converter_GetOutputAvailableType,
> + color_converter_SetInputType,
> + color_converter_SetOutputType,
> + color_converter_GetInputCurrentType,
> + color_converter_GetOutputCurrentType,
> + color_converter_GetInputStatus,
> + color_converter_GetOutputStatus,
> + color_converter_SetOutputBounds,
> + color_converter_ProcessEvent,
> + color_converter_ProcessMessage,
> + color_converter_ProcessInput,
> + color_converter_ProcessOutput,
> +};
> +
> +HRESULT color_converter_create(REFIID riid, void **ret)
> +{
> + struct color_converter *object;
> +
> + TRACE("%s %p\n", debugstr_guid(riid), ret);
> +
> + if (!(object = heap_alloc_zero(sizeof(*object))))
> + return E_OUTOFMEMORY;
> +
> + object->IMFTransform_iface.lpVtbl = &color_converter_vtbl;
> + object->refcount = 1;
> +
> + *ret = &object->IMFTransform_iface;
> + return S_OK;
> +}
> diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
> index 14b6a011ac2..075e0ce1f0f 100644
> --- a/dlls/winegstreamer/gst_private.h
> +++ b/dlls/winegstreamer/gst_private.h
> @@ -87,5 +87,6 @@ GstBuffer *gst_buffer_from_mf_sample(IMFSample *in) DECLSPEC_HIDDEN;
> HRESULT winegstreamer_stream_handler_create(REFIID riid, void **obj) DECLSPEC_HIDDEN;
>
> HRESULT audio_converter_create(REFIID riid, void **ret) DECLSPEC_HIDDEN;
> +HRESULT color_converter_create(REFIID riid, void **ret) DECLSPEC_HIDDEN;
>
> #endif /* __GST_PRIVATE_INCLUDED__ */
> diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c
> index 883084b2d89..288b79997cd 100644
> --- a/dlls/winegstreamer/mfplat.c
> +++ b/dlls/winegstreamer/mfplat.c
> @@ -407,6 +407,8 @@ static const GUID CLSID_GStreamerByteStreamHandler = {0x317df618, 0x5e5a, 0x468a
>
> static const GUID CLSID_WINEAudioConverter = {0x6a170414,0xaad9,0x4693,{0xb8,0x06,0x3a,0x0c,0x47,0xc5,0x70,0xd6}};
>
> +static GUID CLSID_WINEColorConverter = {0x2be8b27f,0xcd60,0x4b8a,{0x95,0xae,0xd1,0x74,0xcc,0x5c,0xba,0xa7}};
> +
This can be const...
> static const struct class_object
> {
> const GUID *clsid;
> @@ -417,6 +419,7 @@ class_objects[] =
> { &CLSID_VideoProcessorMFT, &video_processor_create },
> { &CLSID_GStreamerByteStreamHandler, &winegstreamer_stream_handler_create },
> { &CLSID_WINEAudioConverter, &audio_converter_create },
> + { &CLSID_WINEColorConverter, &color_converter_create },
> };
>
> HRESULT mfplat_get_class_object(REFCLSID rclsid, REFIID riid, void **obj)
> diff --git a/dlls/winegstreamer/winegstreamer_classes.idl b/dlls/winegstreamer/winegstreamer_classes.idl
> index cf1fc69f38a..47c10a09cf0 100644
> --- a/dlls/winegstreamer/winegstreamer_classes.idl
> +++ b/dlls/winegstreamer/winegstreamer_classes.idl
> @@ -67,3 +67,9 @@ coclass GStreamerByteStreamHandler {}
> uuid(6a170414-aad9-4693-b806-3a0c47c570d6)
> ]
> coclass WINEAudioConverter { }
> +
> +[
> + threading(both),
> + uuid(2be8b27f-cd60-4b8a-95ae-d174cc5cbaa7)
> +]
> +coclass WINEColorConverter { }
>
Dec. 4, 2020
Re: [PATCH 06/17] winegstreamer: Implement Get(Input/Output)CurrentType functions for audio converter transform.
by Zebediah Figura (she/her)
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
Dec. 4, 2020