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
June 2022
- 68 participants
- 3274 messages
[PATCH v2 1/1] winebus: Optionally split joysticks with more than 6 axes.
by Timo Zuccarello
From: Timo Zuccarello <timo(a)zuccarello.eu>
Add registry option "Split Controllers" and optionally split joysticks
with more than 6 axes to improve compatibility with applications that
do not support more than 6 axes where on Windows a driver would be
installed that splits the device.
Signed-off-by: Timo Zuccarello <timo(a)zuccarello.eu>
---
dlls/winebus.sys/bus_sdl.c | 87 ++++++++++++++++++++++++++++++--------
dlls/winebus.sys/main.c | 2 +
dlls/winebus.sys/unixlib.h | 1 +
3 files changed, 73 insertions(+), 17 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c
index a5621972493..627ee72a6ff 100644
--- a/dlls/winebus.sys/bus_sdl.c
+++ b/dlls/winebus.sys/bus_sdl.c
@@ -28,6 +28,7 @@
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
+#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
@@ -143,6 +144,7 @@ struct sdl_device
int effect_ids[256];
int effect_state[256];
LONG effect_flags;
+ int axis_offset;
};
static inline struct sdl_device *impl_from_unix_device(struct unix_device *iface)
@@ -155,7 +157,20 @@ static struct sdl_device *find_device_from_id(SDL_JoystickID id)
struct sdl_device *impl;
LIST_FOR_EACH_ENTRY(impl, &device_list, struct sdl_device, unix_device.entry)
- if (impl->id == id) return impl;
+ if (impl->id == id && impl->axis_offset == 0) return impl;
+
+ return NULL;
+}
+
+static struct sdl_device *find_device_from_id_and_axis(SDL_JoystickID id, int axis)
+{
+ struct sdl_device *impl;
+
+ LIST_FOR_EACH_ENTRY(impl, &device_list, struct sdl_device, unix_device.entry)
+ if (impl->id == id &&
+ impl->axis_offset <= axis &&
+ impl->axis_offset + impl->unix_device.hid_device_state.abs_axis_count > axis)
+ return impl;
return NULL;
}
@@ -184,7 +199,8 @@ static BOOL descriptor_add_haptic(struct sdl_device *impl)
USHORT i, count = 0;
USAGE usages[16];
- if (!pSDL_JoystickIsHaptic(impl->sdl_joystick) ||
+ if (impl->axis_offset > 0 ||
+ !pSDL_JoystickIsHaptic(impl->sdl_joystick) ||
!(impl->sdl_haptic = pSDL_HapticOpenFromJoystick(impl->sdl_joystick)))
impl->effect_support = 0;
else
@@ -196,7 +212,7 @@ static BOOL descriptor_add_haptic(struct sdl_device *impl)
impl->effect_support |= WINE_SDL_HAPTIC_RUMBLE;
}
- if (pSDL_JoystickRumble && !pSDL_JoystickRumble(impl->sdl_joystick, 0, 0, 0))
+ if (impl->axis_offset == 0 && pSDL_JoystickRumble && !pSDL_JoystickRumble(impl->sdl_joystick, 0, 0, 0))
impl->effect_support |= WINE_SDL_JOYSTICK_RUMBLE;
if (impl->effect_support & EFFECT_SUPPORT_HAPTICS)
@@ -262,6 +278,7 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
USAGE_AND_PAGE physical_usage;
axis_count = pSDL_JoystickNumAxes(impl->sdl_joystick);
+ if (options.split_controllers) axis_count = min(6, axis_count - impl->axis_offset);
if (axis_count > ARRAY_SIZE(absolute_usages))
{
FIXME("More than %zu absolute axes found, ignoring.\n", ARRAY_SIZE(absolute_usages));
@@ -275,8 +292,16 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
ball_count = ARRAY_SIZE(relative_usages) / 2;
}
- hat_count = pSDL_JoystickNumHats(impl->sdl_joystick);
- button_count = pSDL_JoystickNumButtons(impl->sdl_joystick);
+ if (impl->axis_offset == 0)
+ {
+ hat_count = pSDL_JoystickNumHats(impl->sdl_joystick);
+ button_count = pSDL_JoystickNumButtons(impl->sdl_joystick);
+ }
+ else
+ {
+ hat_count = 0;
+ button_count = 0;
+ }
if (!pSDL_JoystickGetType) physical_usage = device_usage;
else switch (pSDL_JoystickGetType(impl->sdl_joystick))
@@ -902,8 +927,9 @@ static void sdl_add_device(unsigned int index)
SDL_JoystickID id;
SDL_JoystickGUID guid;
SDL_GameController *controller = NULL;
- const char *str;
- char guid_str[33];
+ const char *str, *product;
+ char guid_str[33], buffer[ARRAY_SIZE(desc.product)];
+ int axis_count, axis_offset;
if ((joystick = pSDL_JoystickOpen(index)) == NULL)
{
@@ -916,7 +942,12 @@ static void sdl_add_device(unsigned int index)
if (controller) str = pSDL_GameControllerName(controller);
else str = pSDL_JoystickName(joystick);
- if (str) ntdll_umbstowcs(str, strlen(str) + 1, desc.product, ARRAY_SIZE(desc.product));
+ if (str)
+ {
+ ntdll_umbstowcs(str, strlen(str) + 1, desc.product, ARRAY_SIZE(desc.product));
+ product = str;
+ }
+ else product = "Joystick";
id = pSDL_JoystickInstanceID(joystick);
@@ -936,10 +967,14 @@ static void sdl_add_device(unsigned int index)
pSDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str));
ntdll_umbstowcs(guid_str, strlen(guid_str) + 1, desc.serialnumber, ARRAY_SIZE(desc.serialnumber));
- if (controller) desc.is_gamepad = TRUE;
+ if (controller)
+ {
+ desc.is_gamepad = TRUE;
+ axis_count = 6;
+ }
else
{
- int button_count, axis_count;
+ int button_count;
axis_count = pSDL_JoystickNumAxes(joystick);
button_count = pSDL_JoystickNumButtons(joystick);
@@ -948,13 +983,20 @@ static void sdl_add_device(unsigned int index)
TRACE("%s id %d, desc %s.\n", controller ? "controller" : "joystick", id, debugstr_device_desc(&desc));
- if (!(impl = hid_device_create(&sdl_device_vtbl, sizeof(struct sdl_device)))) return;
- list_add_tail(&device_list, &impl->unix_device.entry);
- impl->sdl_joystick = joystick;
- impl->sdl_controller = controller;
- impl->id = id;
-
- bus_event_queue_device_created(&event_queue, &impl->unix_device, &desc);
+ for (axis_offset = 0; axis_offset < axis_count; axis_offset += (options.split_controllers ? 6 : axis_count))
+ {
+ if (axis_offset) snprintf(buffer, ARRAY_SIZE(buffer), "%s %d", product, axis_offset / 6);
+ else snprintf(buffer, ARRAY_SIZE(buffer), "%s", product);
+ ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc.product, ARRAY_SIZE(desc.product));
+ if (!(impl = hid_device_create(&sdl_device_vtbl, sizeof(struct sdl_device)))) return;
+ list_add_tail(&device_list, &impl->unix_device.entry);
+ impl->sdl_joystick = joystick;
+ impl->sdl_controller = controller;
+ impl->id = id;
+ impl->axis_offset = axis_offset;
+ bus_event_queue_device_created(&event_queue, &impl->unix_device, &desc);
+ if (options.split_controllers && axis_count > 6) TRACE("%s id %d, split for axis %d-%d.\n", controller ? "controller" : "joystick", id, axis_offset, axis_offset + min(6, axis_count - axis_offset));
+ }
}
static void process_device_event(SDL_Event *event)
@@ -975,6 +1017,17 @@ static void process_device_event(SDL_Event *event)
if (impl) bus_event_queue_device_removed(&event_queue, &impl->unix_device);
else WARN("failed to find device with id %d\n", id);
}
+ else if (event->type == SDL_JOYAXISMOTION && options.split_controllers)
+ {
+ id = ((SDL_JoyAxisEvent *)event)->which;
+ impl = find_device_from_id_and_axis(id, ((SDL_JoyAxisEvent *)event)->axis);
+ if (impl)
+ {
+ ((SDL_JoyAxisEvent *)event)->axis -= impl->axis_offset;
+ set_report_from_joystick_event(impl, event);
+ }
+ else WARN("failed to find device with id %d for axis %d\n", id, ((SDL_JoyAxisEvent *)event)->axis);
+ }
else if (event->type >= SDL_JOYAXISMOTION && event->type <= SDL_JOYBUTTONUP)
{
id = ((SDL_JoyButtonEvent *)event)->which;
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c
index 4588fee1b02..35db8a5fb9a 100644
--- a/dlls/winebus.sys/main.c
+++ b/dlls/winebus.sys/main.c
@@ -720,6 +720,8 @@ static NTSTATUS sdl_driver_init(void)
};
NTSTATUS status;
+ bus_options.split_controllers = check_bus_option(L"Split Controllers", 0);
+ if (bus_options.split_controllers) TRACE("SDL controller splitting enabled\n");
bus_options.map_controllers = check_bus_option(L"Map Controllers", 1);
if (!bus_options.map_controllers) TRACE("SDL controller to XInput HID gamepad mapping disabled\n");
sdl_bus_load_mappings(&bus_options);
diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h
index a84a3331a25..ba7674d36a7 100644
--- a/dlls/winebus.sys/unixlib.h
+++ b/dlls/winebus.sys/unixlib.h
@@ -47,6 +47,7 @@ struct device_desc
struct sdl_bus_options
{
BOOL map_controllers;
+ BOOL split_controllers;
/* freed after bus_init */
UINT mappings_count;
char **mappings;
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/181
June 7, 2022
[PATCH v2 0/1] MR181: winebus: Optionally split joysticks with more than 6 axes.
by Timo Zuccarello (ï¼ timozuccarello)
Add registry option "Split Controllers" and optionally split joysticks
with more than 6 axes to improve compatibility with applications that
do not support more than 6 axes where on Windows a driver would be
installed that splits the device.
Signed-off-by: Timo Zuccarello <timo(a)zuccarello.eu>
--
v2: winebus: Optionally split joysticks with more than 6 axes.
https://gitlab.winehq.org/wine/wine/-/merge_requests/181
June 7, 2022
Re: [PATCH v3 1/1] winegstreamer: reintroduce flushing for wg_parser
by Zebediah Figura
On 6/1/22 20:58, zlice wrote:
> From: zlice <zlice555(a)gmail.com>
>
> Previous commit removed flushing but this causes issues in some games.
>
> - add flushing back
> - move variable creation after initial condition returns in wm_reader_get_stream_sample. This caused some slow down.
> - Remove EOS sets. Some are not what flushing did before. Had some seg faults on exiting Fallout 3 with them in.
As stated in my original reply to this patch [1]:
I don't think "reintroduce flushing" is the right answer here, not
without understanding why it matters.
The point of 5144b2766 is that flushing should not make a difference. It
allows wg_parser_stream_get_event() to return more quickly, but that
same cost is added to the subsequent seek or stop request, so
GST_Seeking_SetPositions() or parser_cleanup_stream() will end up taking
just as long.
If flushing does make a difference, I think we need to understand why,
and quite likely solve this a different way.
[1] https://www.winehq.org/pipermail/wine-devel/2022-May/217461.html
June 7, 2022
Re: [PATCH v5 0/1] MR175: d3d11: Do not return uninitialized values on Map() failure. - approved
by Zebediah Figura (ï¼ zfigura)
This merge request was approved by Zebediah Figura.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/175
June 7, 2022
[PATCH] wined3d: Cap the maximum reported VRAM, not the current reported VRAM.
by Zebediah Figura
That is, subtract the currently used memory from the capped maximum, so that
creating textures will report that available VRAM has decreased. Drivers on
Windows seem to match this behaviour (at least NVidia and WARP), although they
vary on where the cap is set.
This fixes test failures in test_vidmem_accounting() for cards with over 4 GiB
of VRAM.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index c6a6de93123..f264494cb5f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1482,7 +1482,7 @@ UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device
wine_dbgstr_longlong(device->adapter->vram_bytes_used),
wine_dbgstr_longlong(driver_info->vram_bytes - device->adapter->vram_bytes_used));
- return min(UINT_MAX, driver_info->vram_bytes - device->adapter->vram_bytes_used);
+ return min(UINT_MAX, driver_info->vram_bytes) - device->adapter->vram_bytes_used;
}
struct wined3d_buffer * CDECL wined3d_device_context_get_stream_output(struct wined3d_device_context *context,
--
2.36.1
June 7, 2022
[PATCH vkd3d v5 14/14] vkd3d-shader/hlsl: Parse the mul() intrinsic.
by Zebediah Figura
From: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl.y | 118 ++++++++++++++++++++++++
tests/hlsl-majority-pragma.shader_test | 2 +-
tests/hlsl-majority-typedef.shader_test | 2 +-
tests/hlsl-mul.shader_test | 36 ++++----
4 files changed, 138 insertions(+), 20 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 2aee51533..df5fda472 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -2046,6 +2046,123 @@ static bool intrinsic_min(struct hlsl_ctx *ctx,
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, params->args[0], params->args[1], loc);
}
+static bool intrinsic_mul(struct hlsl_ctx *ctx,
+ const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
+{
+ struct hlsl_ir_node *arg1 = params->args[0], *arg2 = params->args[1], *cast1, *cast2;
+ enum hlsl_base_type base = expr_common_base_type(arg1->data_type->base_type, arg2->data_type->base_type);
+ struct hlsl_type *cast_type1 = arg1->data_type, *cast_type2 = arg2->data_type, *matrix_type, *ret_type;
+ unsigned int i, j, k, vect_count = 0;
+ struct vkd3d_string_buffer *name;
+ static unsigned int counter = 0;
+ struct hlsl_ir_load *load;
+ struct hlsl_ir_var *var;
+
+ if (arg1->data_type->type == HLSL_CLASS_SCALAR || arg2->data_type->type == HLSL_CLASS_SCALAR)
+ return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, arg1, arg2, loc);
+
+ if (arg1->data_type->type == HLSL_CLASS_VECTOR)
+ {
+ vect_count++;
+ cast_type1 = hlsl_get_matrix_type(ctx, base, arg1->data_type->dimx, 1);
+ }
+ if (arg2->data_type->type == HLSL_CLASS_VECTOR)
+ {
+ vect_count++;
+ cast_type2 = hlsl_get_matrix_type(ctx, base, 1, arg2->data_type->dimx);
+ }
+
+ matrix_type = hlsl_get_matrix_type(ctx, base, cast_type2->dimx, cast_type1->dimy);
+
+ if (vect_count == 0)
+ {
+ ret_type = matrix_type;
+ }
+ else if (vect_count == 1)
+ {
+ assert(matrix_type->dimx == 1 || matrix_type->dimy == 1);
+ ret_type = hlsl_get_vector_type(ctx, base, matrix_type->dimx * matrix_type->dimy);
+ }
+ else
+ {
+ assert(matrix_type->dimx == 1 && matrix_type->dimy == 1);
+ ret_type = hlsl_get_scalar_type(ctx, base);
+ }
+
+ if (!(cast1 = add_implicit_conversion(ctx, params->instrs, arg1, cast_type1, loc)))
+ return false;
+
+ if (!(cast2 = add_implicit_conversion(ctx, params->instrs, arg2, cast_type2, loc)))
+ return false;
+
+ name = vkd3d_string_buffer_get(&ctx->string_buffers);
+ vkd3d_string_buffer_printf(name, "<mul-%u>", counter++);
+ var = hlsl_new_synthetic_var(ctx, name->buffer, matrix_type, *loc);
+ vkd3d_string_buffer_release(&ctx->string_buffers, name);
+ if (!var)
+ return false;
+
+ for (i = 0; i < matrix_type->dimx; ++i)
+ for (j = 0; j < matrix_type->dimy; ++j)
+ {
+ struct hlsl_ir_node *node = NULL;
+ struct hlsl_type *scalar_type;
+ struct hlsl_ir_store *store;
+ struct hlsl_ir_constant *c;
+ unsigned int offset;
+
+ for (k = 0; k < cast_type1->dimx && k < cast_type2->dimy; ++k)
+ {
+ struct hlsl_ir_load *value1, *value2;
+ struct hlsl_ir_node *mul;
+
+ offset = hlsl_compute_component_offset(ctx, cast_type1, j * cast_type1->dimx + k, &scalar_type);
+ if (!(c = hlsl_new_uint_constant(ctx, offset, loc)))
+ return false;
+ list_add_tail(params->instrs, &c->node.entry);
+
+ if (!(value1 = add_load(ctx, params->instrs, cast1, &c->node, scalar_type, *loc)))
+ return false;
+
+ offset = hlsl_compute_component_offset(ctx, cast_type2, k * cast_type2->dimx + i, &scalar_type);
+ if (!(c = hlsl_new_uint_constant(ctx, offset, loc)))
+ return false;
+ list_add_tail(params->instrs, &c->node.entry);
+
+ if (!(value2 = add_load(ctx, params->instrs, cast2, &c->node, scalar_type, *loc)))
+ return false;
+
+ if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, &value1->node, &value2->node, loc)))
+ return false;
+
+ if (node)
+ {
+ if (!(node = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, node, mul, loc)))
+ return false;
+ }
+ else
+ {
+ node = mul;
+ }
+ }
+
+ offset = hlsl_compute_component_offset(ctx, matrix_type, j * matrix_type->dimx + i, &scalar_type);
+ if (!(c = hlsl_new_uint_constant(ctx, offset, loc)))
+ return false;
+ list_add_tail(params->instrs, &c->node.entry);
+
+ if (!(store = hlsl_new_store(ctx, var, &c->node, node, 0, *loc)))
+ return false;
+ list_add_tail(params->instrs, &store->node.entry);
+ }
+
+ if (!(load = hlsl_new_load(ctx, var, NULL, matrix_type, *loc)))
+ return false;
+ list_add_tail(params->instrs, &load->node.entry);
+
+ return !!add_implicit_conversion(ctx, params->instrs, &load->node, ret_type, loc);
+}
+
static bool intrinsic_pow(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
@@ -2106,6 +2223,7 @@ intrinsic_functions[] =
{"floor", 1, true, intrinsic_floor},
{"max", 2, true, intrinsic_max},
{"min", 2, true, intrinsic_min},
+ {"mul", 2, true, intrinsic_mul},
{"pow", 2, true, intrinsic_pow},
{"round", 1, true, intrinsic_round},
{"saturate", 1, true, intrinsic_saturate},
diff --git a/tests/hlsl-majority-pragma.shader_test b/tests/hlsl-majority-pragma.shader_test
index a9f917ff8..e7fc75cde 100644
--- a/tests/hlsl-majority-pragma.shader_test
+++ b/tests/hlsl-majority-pragma.shader_test
@@ -17,5 +17,5 @@ uniform 0 float4 0.1 0.2 0.0 0.0
uniform 4 float4 0.3 0.4 0.0 0.0
uniform 8 float4 0.1 0.3 0.0 0.0
uniform 12 float4 0.2 0.4 0.0 0.0
-todo draw quad
+draw quad
probe all rgba (0.17, 0.39, 0.17, 0.39) 1
diff --git a/tests/hlsl-majority-typedef.shader_test b/tests/hlsl-majority-typedef.shader_test
index 192c96db1..1460e9a08 100644
--- a/tests/hlsl-majority-typedef.shader_test
+++ b/tests/hlsl-majority-typedef.shader_test
@@ -18,5 +18,5 @@ uniform 0 float4 0.1 0.2 0.0 0.0
uniform 4 float4 0.3 0.4 0.0 0.0
uniform 8 float4 0.1 0.3 0.0 0.0
uniform 12 float4 0.2 0.4 0.0 0.0
-todo draw quad
+draw quad
probe all rgba (0.17, 0.39, 0.17, 0.39) 1
diff --git a/tests/hlsl-mul.shader_test b/tests/hlsl-mul.shader_test
index 1d137e696..7b4531873 100644
--- a/tests/hlsl-mul.shader_test
+++ b/tests/hlsl-mul.shader_test
@@ -12,7 +12,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (30.0, 70.0, 110.0, 150.0)
[pixel shader]
@@ -28,7 +28,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (90.0, 100.0, 110.0, 120.0)
[pixel shader]
@@ -44,7 +44,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (14.0, 38.0, 62.0, 86.0)
[pixel shader]
@@ -60,7 +60,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (38.0, 44.0, 50.0, 56.0)
[pixel shader]
@@ -75,7 +75,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (14.0, 32.0, 50.0, 0.0)
[pixel shader]
@@ -90,7 +90,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (30.0, 36.0, 42.0, 0.0)
[pixel shader]
@@ -106,7 +106,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (50.0, 60.0, 70.0, 80.0)
[pixel shader]
@@ -122,7 +122,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (50.0, 60.0, 70.0, 80.0)
[pixel shader]
@@ -138,7 +138,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (10.0, 20.0, 30.0, 40.0)
[pixel shader]
@@ -154,7 +154,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (10.0, 50.0, 90.0, 130.0)
[pixel shader]
@@ -170,7 +170,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (10.0, 20.0, 30.0, 40.0)
[pixel shader]
@@ -186,7 +186,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (10.0, 50.0, 90.0, 130.0)
[pixel shader]
@@ -202,7 +202,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (90.0, 100.0, 110.0, 120.0)
[pixel shader]
@@ -218,7 +218,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (5.0, 10.0, 15.0, 20.0)
[pixel shader]
@@ -234,7 +234,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -250,7 +250,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (30.0, 70.0, 110.0, 150.0)
[pixel shader]
@@ -268,7 +268,7 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (83.0, 98.0, 113.0, 128.0)
[pixel shader]
@@ -286,5 +286,5 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (78.0, 96.0, 114.0, 0.0)
--
2.36.1
June 7, 2022
[PATCH vkd3d v5 13/14] vkd3d-shader/hlsl: Split matrix operations.
by Zebediah Figura
From: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl.y | 74 ++++++++++++++++++++++++++++++++++++
tests/hlsl-shape.shader_test | 30 +++++++--------
2 files changed, 89 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 687569e83..2aee51533 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -1201,6 +1201,22 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct
return true;
}
+static unsigned int minor_size(const struct hlsl_type *type)
+{
+ if (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
+ return type->dimx;
+ else
+ return type->dimy;
+}
+
+static unsigned int major_size(const struct hlsl_type *type)
+{
+ if (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
+ return type->dimy;
+ else
+ return type->dimx;
+}
+
static struct hlsl_ir_node *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
struct hlsl_type *type, const struct vkd3d_shader_location *loc)
@@ -1208,6 +1224,64 @@ static struct hlsl_ir_node *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
struct hlsl_ir_expr *expr;
unsigned int i;
+ if (type->type == HLSL_CLASS_MATRIX)
+ {
+ struct vkd3d_string_buffer *name;
+ static unsigned int counter = 0;
+ struct hlsl_type *vector_type;
+ struct hlsl_ir_load *load;
+ struct hlsl_ir_var *var;
+
+ vector_type = hlsl_get_vector_type(ctx, type->base_type, minor_size(type));
+
+ name = vkd3d_string_buffer_get(&ctx->string_buffers);
+ vkd3d_string_buffer_printf(name, "<split_op-%u>", counter++);
+ var = hlsl_new_synthetic_var(ctx, name->buffer, type, *loc);
+ vkd3d_string_buffer_release(&ctx->string_buffers, name);
+ if (!var)
+ return NULL;
+
+ for (i = 0; i < major_size(type); i++)
+ {
+ struct hlsl_ir_node *value, *vector_operands[HLSL_MAX_OPERANDS] = { NULL };
+ struct hlsl_ir_store *store;
+ struct hlsl_ir_constant *c;
+ unsigned int j;
+
+ if (!(c = hlsl_new_uint_constant(ctx, 4 * i, loc)))
+ return NULL;
+ list_add_tail(instrs, &c->node.entry);
+
+ for (j = 0; j < HLSL_MAX_OPERANDS; j++)
+ {
+ if (operands[j])
+ {
+ struct hlsl_type *vector_arg_type;
+ struct hlsl_ir_load *load;
+
+ vector_arg_type = hlsl_get_vector_type(ctx, operands[j]->data_type->base_type, minor_size(type));
+
+ if (!(load = add_load(ctx, instrs, operands[j], &c->node, vector_arg_type, *loc)))
+ return NULL;
+ vector_operands[j] = &load->node;
+ }
+ }
+
+ if (!(value = add_expr(ctx, instrs, op, vector_operands, vector_type, loc)))
+ return NULL;
+
+ if (!(store = hlsl_new_store(ctx, var, &c->node, value, 0, *loc)))
+ return NULL;
+ list_add_tail(instrs, &store->node.entry);
+ }
+
+ if (!(load = hlsl_new_load(ctx, var, NULL, type, *loc)))
+ return NULL;
+ list_add_tail(instrs, &load->node.entry);
+
+ return &load->node;
+ }
+
if (!(expr = hlsl_alloc(ctx, sizeof(*expr))))
return NULL;
init_node(&expr->node, HLSL_IR_EXPR, type, *loc);
diff --git a/tests/hlsl-shape.shader_test b/tests/hlsl-shape.shader_test
index 65cc322c1..b96f0fd22 100644
--- a/tests/hlsl-shape.shader_test
+++ b/tests/hlsl-shape.shader_test
@@ -93,7 +93,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 7.0, 9.0)
[pixel shader]
@@ -107,7 +107,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 7.0, 9.0)
[pixel shader]
@@ -122,7 +122,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -137,7 +137,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -152,7 +152,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 7.0, 12.0, 17.0)
[pixel shader]
@@ -167,7 +167,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 7.0, 12.0, 17.0)
[pixel shader]
@@ -183,7 +183,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 0.0)
[pixel shader]
@@ -199,7 +199,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (9.0, 11.0, 13.0, 0.0)
[pixel shader]
@@ -223,7 +223,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -247,7 +247,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -273,7 +273,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -285,7 +285,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 3.0, 4.0, 5.0)
[pixel shader]
@@ -297,7 +297,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 3.0, 4.0, 5.0)
[pixel shader]
@@ -336,7 +336,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 3.0, 4.0, 5.0)
[pixel shader]
@@ -351,5 +351,5 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (6.0, 7.0, 8.0, 9.0)
--
2.36.1
June 7, 2022
[PATCH vkd3d v5 12/14] vkd3d-shader/hlsl: Have add_expr() return hlsl_ir_node*.
by Zebediah Figura
From: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl.y | 54 +++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 31 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index f85d42527..687569e83 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -674,7 +674,7 @@ static bool add_record_load(struct hlsl_ctx *ctx, struct list *instrs, struct hl
return !!add_load(ctx, instrs, record, &c->node, field->type, loc);
}
-static struct hlsl_ir_expr *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
const struct vkd3d_shader_location *loc);
@@ -682,8 +682,7 @@ static struct hlsl_ir_node *add_matrix_scalar_load(struct hlsl_ctx *ctx, struct
struct hlsl_ir_node *matrix, struct hlsl_ir_node *x, struct hlsl_ir_node *y,
const struct vkd3d_shader_location *loc)
{
- struct hlsl_ir_node *major, *minor;
- struct hlsl_ir_expr *mul, *add;
+ struct hlsl_ir_node *major, *minor, *mul, *add;
struct hlsl_ir_constant *four;
struct hlsl_ir_load *load;
struct hlsl_type *type = matrix->data_type, *scalar_type;
@@ -708,10 +707,10 @@ static struct hlsl_ir_node *add_matrix_scalar_load(struct hlsl_ctx *ctx, struct
if (!(mul = add_binary_arithmetic_expr(ctx, instrs, HLSL_OP2_MUL, &four->node, major, loc)))
return NULL;
- if (!(add = add_binary_arithmetic_expr(ctx, instrs, HLSL_OP2_ADD, &mul->node, minor, loc)))
+ if (!(add = add_binary_arithmetic_expr(ctx, instrs, HLSL_OP2_ADD, mul, minor, loc)))
return NULL;
- if (!(load = add_load(ctx, instrs, matrix, &add->node, scalar_type, *loc)))
+ if (!(load = add_load(ctx, instrs, matrix, add, scalar_type, *loc)))
return NULL;
return &load->node;
@@ -1202,7 +1201,7 @@ static bool expr_common_shape(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct
return true;
}
-static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
struct hlsl_type *type, const struct vkd3d_shader_location *loc)
{
@@ -1217,7 +1216,7 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
hlsl_src_from_node(&expr->operands[i], operands[i]);
list_add_tail(instrs, &expr->node.entry);
- return expr;
+ return &expr->node;
}
static void check_integer_type(struct hlsl_ctx *ctx, const struct hlsl_ir_node *instr)
@@ -1241,7 +1240,7 @@ static void check_integer_type(struct hlsl_ctx *ctx, const struct hlsl_ir_node *
}
}
-static struct hlsl_ir_expr *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {arg};
@@ -1249,7 +1248,7 @@ static struct hlsl_ir_expr *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, stru
return add_expr(ctx, instrs, op, args, arg->data_type, loc);
}
-static struct hlsl_ir_expr *add_unary_bitwise_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_unary_bitwise_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc)
{
check_integer_type(ctx, arg);
@@ -1257,7 +1256,7 @@ static struct hlsl_ir_expr *add_unary_bitwise_expr(struct hlsl_ctx *ctx, struct
return add_unary_arithmetic_expr(ctx, instrs, op, arg, loc);
}
-static struct hlsl_ir_expr *add_unary_logical_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_unary_logical_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};
@@ -1272,7 +1271,7 @@ static struct hlsl_ir_expr *add_unary_logical_expr(struct hlsl_ctx *ctx, struct
return add_expr(ctx, instrs, op, args, bool_type, loc);
}
-static struct hlsl_ir_expr *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
const struct vkd3d_shader_location *loc)
{
@@ -1307,7 +1306,7 @@ static struct list *add_binary_arithmetic_expr_merge(struct hlsl_ctx *ctx, struc
return list1;
}
-static struct hlsl_ir_expr *add_binary_bitwise_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_binary_bitwise_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
const struct vkd3d_shader_location *loc)
{
@@ -1329,7 +1328,7 @@ static struct list *add_binary_bitwise_expr_merge(struct hlsl_ctx *ctx, struct l
return list1;
}
-static struct hlsl_ir_expr *add_binary_comparison_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_binary_comparison_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
struct vkd3d_shader_location *loc)
{
@@ -1365,7 +1364,7 @@ static struct list *add_binary_comparison_expr_merge(struct hlsl_ctx *ctx, struc
return list1;
}
-static struct hlsl_ir_expr *add_binary_logical_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_binary_logical_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
const struct vkd3d_shader_location *loc)
{
@@ -1400,7 +1399,7 @@ static struct list *add_binary_logical_expr_merge(struct hlsl_ctx *ctx, struct l
return list1;
}
-static struct hlsl_ir_expr *add_binary_shift_expr(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_binary_shift_expr(struct hlsl_ctx *ctx, struct list *instrs,
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
const struct vkd3d_shader_location *loc)
{
@@ -1509,22 +1508,17 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
if (assign_op == ASSIGN_OP_SUB)
{
- struct hlsl_ir_expr *expr;
-
- if (!(expr = add_unary_arithmetic_expr(ctx, instrs, HLSL_OP1_NEG, rhs, &rhs->loc)))
+ if (!(rhs = add_unary_arithmetic_expr(ctx, instrs, HLSL_OP1_NEG, rhs, &rhs->loc)))
return NULL;
- rhs = &expr->node;
assign_op = ASSIGN_OP_ADD;
}
if (assign_op != ASSIGN_OP_ASSIGN)
{
enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
- struct hlsl_ir_expr *expr;
assert(op);
- if (!(expr = add_binary_arithmetic_expr(ctx, instrs, op, lhs, rhs, &rhs->loc)))
+ if (!(rhs = add_binary_arithmetic_expr(ctx, instrs, op, lhs, rhs, &rhs->loc)))
return NULL;
- rhs = &expr->node;
}
if (lhs_type->type <= HLSL_CLASS_LAST_NUMERIC)
@@ -1894,12 +1888,12 @@ static bool intrinsic_abs(struct hlsl_ctx *ctx,
static bool intrinsic_clamp(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
- struct hlsl_ir_expr *max;
+ struct hlsl_ir_node *max;
if (!(max = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MAX, params->args[0], params->args[1], loc)))
return false;
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, &max->node, params->args[2], loc);
+ return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, max, params->args[2], loc);
}
static bool intrinsic_cross(struct hlsl_ctx *ctx,
@@ -1907,8 +1901,7 @@ static bool intrinsic_cross(struct hlsl_ctx *ctx,
{
struct hlsl_ir_swizzle *arg1_swzl1, *arg1_swzl2, *arg2_swzl1, *arg2_swzl2;
struct hlsl_ir_node *arg1 = params->args[0], *arg2 = params->args[1];
- struct hlsl_ir_node *arg1_cast, *arg2_cast, *mul1_neg;
- struct hlsl_ir_expr *mul1, *mul2;
+ struct hlsl_ir_node *arg1_cast, *arg2_cast, *mul1_neg, *mul1, *mul2;
struct hlsl_type *cast_type;
enum hlsl_base_type base;
@@ -1937,7 +1930,7 @@ static bool intrinsic_cross(struct hlsl_ctx *ctx,
&arg1_swzl1->node, &arg2_swzl1->node, loc)))
return false;
- if (!(mul1_neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, &mul1->node, *loc)))
+ if (!(mul1_neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, mul1, *loc)))
return false;
list_add_tail(params->instrs, &mul1_neg->entry);
@@ -1953,7 +1946,7 @@ static bool intrinsic_cross(struct hlsl_ctx *ctx,
&arg1_swzl2->node, &arg2_swzl2->node, loc)))
return false;
- return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, &mul2->node, mul1_neg, loc);
+ return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, mul2, mul1_neg, loc);
}
static bool intrinsic_floor(struct hlsl_ctx *ctx,
@@ -1982,8 +1975,7 @@ static bool intrinsic_min(struct hlsl_ctx *ctx,
static bool intrinsic_pow(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
- struct hlsl_ir_node *log, *exp, *arg;
- struct hlsl_ir_expr *mul;
+ struct hlsl_ir_node *log, *exp, *arg, *mul;
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
return false;
@@ -1995,7 +1987,7 @@ static bool intrinsic_pow(struct hlsl_ctx *ctx,
if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, params->args[1], log, loc)))
return false;
- if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, *loc)))
+ if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, mul, *loc)))
return false;
list_add_tail(params->instrs, &exp->entry);
return true;
--
2.36.1
June 7, 2022
[PATCH vkd3d v5 11/14] vkd3d-shader/hlsl: Lower matrix casts.
by Zebediah Figura
From: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl.y | 93 ++++++++++++++++++-
tests/hlsl-duplicate-modifiers.shader_test | 2 +-
tests/hlsl-initializer-matrix.shader_test | 2 +-
...lsl-return-implicit-conversion.shader_test | 8 +-
tests/hlsl-shape.shader_test | 10 +-
tests/matrix-semantics.shader_test | 12 +--
6 files changed, 106 insertions(+), 21 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 23c48cdc8..f85d42527 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -266,6 +266,9 @@ static bool implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_typ
return false;
}
+static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *var_node,
+ struct hlsl_ir_node *offset, struct hlsl_type *data_type, const struct vkd3d_shader_location loc);
+
static struct hlsl_ir_node *add_cast(struct hlsl_ctx *ctx, struct list *instrs,
struct hlsl_ir_node *node, struct hlsl_type *dst_type, const struct vkd3d_shader_location *loc)
{
@@ -275,10 +278,92 @@ static struct hlsl_ir_node *add_cast(struct hlsl_ctx *ctx, struct list *instrs,
if (hlsl_types_are_equal(src_type, dst_type))
return node;
- if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
- return NULL;
- list_add_tail(instrs, &cast->node.entry);
- return &cast->node;
+ if ((src_type->type == HLSL_CLASS_MATRIX || dst_type->type == HLSL_CLASS_MATRIX)
+ && src_type->type <= HLSL_CLASS_LAST_NUMERIC && dst_type->type <= HLSL_CLASS_LAST_NUMERIC)
+ {
+ struct vkd3d_string_buffer *name;
+ static unsigned int counter = 0;
+ struct hlsl_ir_load *load;
+ struct hlsl_ir_var *var;
+ unsigned int dst_idx;
+ bool broadcast;
+
+ broadcast = src_type->dimx == 1 && src_type->dimy == 1;
+ assert(dst_type->dimx * dst_type->dimy <= src_type->dimx * src_type->dimy || broadcast);
+ if (src_type->type == HLSL_CLASS_MATRIX && dst_type->type == HLSL_CLASS_MATRIX && !broadcast)
+ {
+ assert(dst_type->dimx <= src_type->dimx);
+ assert(dst_type->dimy <= src_type->dimy);
+ }
+
+ name = vkd3d_string_buffer_get(&ctx->string_buffers);
+ vkd3d_string_buffer_printf(name, "<cast-%u>", counter++);
+ var = hlsl_new_synthetic_var(ctx, name->buffer, dst_type, *loc);
+ vkd3d_string_buffer_release(&ctx->string_buffers, name);
+ if (!var)
+ return NULL;
+
+ for (dst_idx = 0; dst_idx < dst_type->dimx * dst_type->dimy; ++dst_idx)
+ {
+ struct hlsl_type *src_scalar_type, *dst_scalar_type;
+ unsigned int src_idx, src_offset, dst_offset;
+ struct hlsl_ir_store *store;
+ struct hlsl_ir_constant *c;
+
+ if (broadcast)
+ {
+ src_idx = 0;
+ }
+ else
+ {
+ if (src_type->type == HLSL_CLASS_MATRIX && dst_type->type == HLSL_CLASS_MATRIX)
+ {
+ unsigned int x = dst_idx % dst_type->dimx, y = dst_idx / dst_type->dimx;
+
+ src_idx = y * src_type->dimx + x;
+ }
+ else
+ {
+ src_idx = dst_idx;
+ }
+ }
+
+ dst_offset = hlsl_compute_component_offset(ctx, dst_type, dst_idx, &dst_scalar_type);
+ src_offset = hlsl_compute_component_offset(ctx, src_type, src_idx, &src_scalar_type);
+
+ if (!(c = hlsl_new_uint_constant(ctx, src_offset, loc)))
+ return NULL;
+ list_add_tail(instrs, &c->node.entry);
+
+ if (!(load = add_load(ctx, instrs, node, &c->node, src_scalar_type, *loc)))
+ return NULL;
+
+ if (!(cast = hlsl_new_cast(ctx, &load->node, dst_scalar_type, loc)))
+ return NULL;
+ list_add_tail(instrs, &cast->node.entry);
+
+ if (!(c = hlsl_new_uint_constant(ctx, dst_offset, loc)))
+ return NULL;
+ list_add_tail(instrs, &c->node.entry);
+
+ if (!(store = hlsl_new_store(ctx, var, &c->node, &cast->node, 0, *loc)))
+ return NULL;
+ list_add_tail(instrs, &store->node.entry);
+ }
+
+ if (!(load = hlsl_new_load(ctx, var, NULL, dst_type, *loc)))
+ return NULL;
+ list_add_tail(instrs, &load->node.entry);
+
+ return &load->node;
+ }
+ else
+ {
+ if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
+ return NULL;
+ list_add_tail(instrs, &cast->node.entry);
+ return &cast->node;
+ }
}
static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct list *instrs,
diff --git a/tests/hlsl-duplicate-modifiers.shader_test b/tests/hlsl-duplicate-modifiers.shader_test
index fcae12da8..6491701ae 100644
--- a/tests/hlsl-duplicate-modifiers.shader_test
+++ b/tests/hlsl-duplicate-modifiers.shader_test
@@ -7,5 +7,5 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.1, 0.2, 0.3, 0.4)
diff --git a/tests/hlsl-initializer-matrix.shader_test b/tests/hlsl-initializer-matrix.shader_test
index ea9de9c03..7e12b0a00 100644
--- a/tests/hlsl-initializer-matrix.shader_test
+++ b/tests/hlsl-initializer-matrix.shader_test
@@ -55,7 +55,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (21, 22, 31, 32)
diff --git a/tests/hlsl-return-implicit-conversion.shader_test b/tests/hlsl-return-implicit-conversion.shader_test
index bf99d9cbd..545340eb3 100644
--- a/tests/hlsl-return-implicit-conversion.shader_test
+++ b/tests/hlsl-return-implicit-conversion.shader_test
@@ -5,7 +5,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.4, 0.3, 0.2, 0.1)
[pixel shader]
@@ -15,7 +15,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.4, 0.3, 0.2, 0.1)
[pixel shader]
@@ -25,7 +25,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.4, 0.3, 0.2, 0.1)
[pixel shader]
@@ -35,7 +35,7 @@ float4x1 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.4, 0.3, 0.2, 0.1)
[pixel shader]
diff --git a/tests/hlsl-shape.shader_test b/tests/hlsl-shape.shader_test
index 57d59534b..65cc322c1 100644
--- a/tests/hlsl-shape.shader_test
+++ b/tests/hlsl-shape.shader_test
@@ -211,7 +211,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -235,7 +235,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -260,7 +260,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 6.0, 8.0)
[pixel shader]
@@ -309,7 +309,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 0.0, 0.0)
[pixel shader]
@@ -321,7 +321,7 @@ float4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (2.0, 4.0, 0.0, 0.0)
[pixel shader]
diff --git a/tests/matrix-semantics.shader_test b/tests/matrix-semantics.shader_test
index 1be504064..43f467ecd 100644
--- a/tests/matrix-semantics.shader_test
+++ b/tests/matrix-semantics.shader_test
@@ -5,7 +5,7 @@ float4x1 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader]
@@ -15,7 +15,7 @@ row_major float1x4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe all rgba (1.0, 2.0, 3.0, 4.0)
[require]
@@ -44,7 +44,7 @@ row_major float4x1 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe render target 0 all r (1.0)
probe render target 1 all r (2.0)
probe render target 2 all r (3.0)
@@ -57,7 +57,7 @@ float1x4 main() : sv_target
}
[test]
-todo draw quad
+draw quad
probe render target 0 all r (1.0)
probe render target 1 all r (2.0)
probe render target 2 all r (3.0)
@@ -78,7 +78,7 @@ void main(out float1x2 x : sv_target0, out float1x2 y : sv_target2)
}
[test]
-todo draw quad
+draw quad
probe render target 0 all r (1.0)
probe render target 1 all r (2.0)
probe render target 2 all r (5.0)
@@ -96,7 +96,7 @@ void main(out row_major float1x4 x : sv_target0, out float1x2 y : sv_target1)
}
[test]
-todo draw quad
+draw quad
probe render target 0 all rgba (1.0, 2.0, 3.0, 4.0)
probe render target 1 all r (5.0)
probe render target 2 all r (6.0)
--
2.36.1
June 7, 2022
[PATCH vkd3d v5 10/14] vkd3d-shader/hlsl: Introduce add_cast() helper.
by Zebediah Figura
From: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl.y | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index faac562ab..23c48cdc8 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -266,7 +266,7 @@ static bool implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_typ
return false;
}
-static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct list *instrs,
+static struct hlsl_ir_node *add_cast(struct hlsl_ctx *ctx, struct list *instrs,
struct hlsl_ir_node *node, struct hlsl_type *dst_type, const struct vkd3d_shader_location *loc)
{
struct hlsl_type *src_type = node->data_type;
@@ -275,6 +275,17 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
if (hlsl_types_are_equal(src_type, dst_type))
return node;
+ if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
+ return NULL;
+ list_add_tail(instrs, &cast->node.entry);
+ return &cast->node;
+}
+
+static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct list *instrs,
+ struct hlsl_ir_node *node, struct hlsl_type *dst_type, const struct vkd3d_shader_location *loc)
+{
+ struct hlsl_type *src_type = node->data_type;
+
if (!implicit_compatible_data_types(src_type, dst_type))
{
struct vkd3d_string_buffer *src_string, *dst_string;
@@ -293,10 +304,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
hlsl_warning(ctx, loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.",
src_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
- if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
- return NULL;
- list_add_tail(instrs, &cast->node.entry);
- return &cast->node;
+ return add_cast(ctx, instrs, node, dst_type, loc);
}
static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, const struct vkd3d_shader_location loc)
@@ -3718,7 +3726,6 @@ unary_expr:
{
struct hlsl_type *src_type = node_from_list($6)->data_type;
struct hlsl_type *dst_type;
- struct hlsl_ir_expr *cast;
unsigned int i;
if ($2)
@@ -3746,12 +3753,11 @@ unary_expr:
YYABORT;
}
- if (!(cast = hlsl_new_cast(ctx, node_from_list($6), dst_type, &@3)))
+ if (!add_cast(ctx, $6, node_from_list($6), dst_type, &@3))
{
hlsl_free_instr_list($6);
YYABORT;
}
- list_add_tail($6, &cast->node.entry);
$$ = $6;
}
--
2.36.1
June 7, 2022