Wine-devel
Threads by month
- ----- 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
February 2021
- 81 participants
- 640 discussions
[PATCH] ntdll/tests: Avoid passing an uninitialized timeout to NtNotifyChangeKey().
by Zebediah Figura 24 Feb '21
by Zebediah Figura 24 Feb '21
24 Feb '21
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/ntdll/tests/reg.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index ac1dec9f2f8..7463f98aa29 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -1850,7 +1850,7 @@ static void test_NtQueryKey(void)
static void test_notify(void)
{
OBJECT_ATTRIBUTES attr;
- LARGE_INTEGER timeout;
+ static const LARGE_INTEGER timeout;
IO_STATUS_BLOCK iosb;
UNICODE_STRING str;
HANDLE key, key2, events[4], subkey;
@@ -1952,7 +1952,6 @@ static void test_notify(void)
status = pNtNotifyChangeMultipleKeys(key, 0, NULL, events[0], NULL, NULL, &iosb, REG_NOTIFY_CHANGE_NAME, FALSE, NULL, 0, TRUE);
ok(status == STATUS_PENDING, "NtNotifyChangeKey returned %x\n", status);
- timeout.QuadPart = 0;
status = pNtWaitForSingleObject(events[0], FALSE, &timeout);
ok(status == STATUS_TIMEOUT, "NtWaitForSingleObject returned %x\n", status);
--
2.20.1
1
0
And use it in a few more places.
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
---
dlls/ntdll/unix/signal_x86_64.c | 16 ++++++----------
dlls/ntdll/unix/system.c | 2 +-
dlls/ntdll/unix/unix_private.h | 1 +
3 files changed, 8 insertions(+), 11 deletions(-)
1
1
[PATCH 5/5] d3d11: Always return the rectangle count in d3d11_immediate_context_RSGetScissorRects().
by Henri Verbeet 23 Feb '21
by Henri Verbeet 23 Feb '21
23 Feb '21
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
This supersedes patch 200186.
dlls/d3d11/device.c | 9 ++-------
dlls/d3d11/tests/d3d11.c | 6 +++---
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index a5d9dc1aa7be..c8ec35a59c0f 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2270,14 +2270,9 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11De
wined3d_device_get_scissor_rects(device->wined3d_device, &actual_count, rects);
wined3d_mutex_unlock();
- if (!rects)
- {
- *rect_count = actual_count;
- return;
- }
-
- if (*rect_count > actual_count)
+ if (rects && *rect_count > actual_count)
memset(&rects[actual_count], 0, (*rect_count - actual_count) * sizeof(*rects));
+ *rect_count = actual_count;
}
static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext1 *iface,
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 2eff98fe8fcf..32a9dc2e5306 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -7235,7 +7235,7 @@ static void test_device_context_state(void)
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
- todo_wine ok(count == 0, "Got unexpected scissor rect count %u.\n", count);
+ ok(count == 0, "Got unexpected scissor rect count %u.\n", count);
tmp_sob = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_SOGetTargets(context, 1, &tmp_sob);
@@ -7514,7 +7514,7 @@ static void test_device_context_state(void)
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
- todo_wine ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
+ ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
ok(!memcmp(tmp_rect, &rect, sizeof(rect)), "Got scissor rect %s, expected %s.\n",
wine_dbgstr_rect(tmp_rect), wine_dbgstr_rect(&rect));
@@ -7962,7 +7962,7 @@ static void test_device_context_state(void)
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
- todo_wine ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
+ ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
ok(!memcmp(tmp_rect, &rect, sizeof(rect)), "Got scissor rect %s, expected %s.\n",
wine_dbgstr_rect(tmp_rect), wine_dbgstr_rect(&rect));
--
2.20.1
2
1
[PATCH vkd3d v2 1/3] vkd3d-shader: Implement hlsl_error() and hlsl_warning().
by Zebediah Figura 23 Feb '21
by Zebediah Figura 23 Feb '21
23 Feb '21
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
Makefile.am | 1 -
libs/vkd3d-shader/hlsl.c | 18 +-
libs/vkd3d-shader/hlsl.h | 8 +-
libs/vkd3d-shader/hlsl.l | 3 +-
libs/vkd3d-shader/hlsl.y | 204 ++++++++++++-----------
libs/vkd3d-shader/vkd3d_shader_private.h | 18 ++
6 files changed, 147 insertions(+), 105 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 065b9817..3c219e8a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -246,7 +246,6 @@ XFAIL_TESTS = \
tests/conditional.shader_test \
tests/hlsl-array-dimension.shader_test \
tests/hlsl-comma.shader_test \
- tests/hlsl-invalid.shader_test \
tests/hlsl-majority-pragma.shader_test \
tests/hlsl-majority-typedef.shader_test \
tests/hlsl-return-implicit-conversion.shader_test \
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 9e1eb7ee..1f9a3927 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -31,16 +31,26 @@ void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
/* FIXME */
}
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...)
+void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
+ enum vkd3d_shader_error error, const char *fmt, ...)
{
- /* FIXME */
+ va_list args;
+
+ va_start(args, fmt);
+ vkd3d_shader_verror(ctx->message_context, &loc, error, fmt, args);
+ va_end(args);
ctx->failed = true;
}
-void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...)
+void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
+ enum vkd3d_shader_error error, const char *fmt, ...)
{
- /* FIXME */
+ va_list args;
+
+ va_start(args, fmt);
+ vkd3d_shader_vwarning(ctx->message_context, &loc, error, fmt, args);
+ va_end(args);
}
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 56b8e2a8..9122b097 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -546,10 +546,10 @@ struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd
void hlsl_message(const char *fmt, ...) VKD3D_PRINTF_FUNC(1,2) DECLSPEC_HIDDEN;
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
- const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
-void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
- const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
+void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_error error,
+ const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
+void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_error error,
+ const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_log_level level,
const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l
index 933c9b88..4cc0a3ea 100644
--- a/libs/vkd3d-shader/hlsl.l
+++ b/libs/vkd3d-shader/hlsl.l
@@ -65,7 +65,8 @@ ANY (.)
{RESERVED4} {
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
- hlsl_error(ctx, *yylloc, "Reserved keyword \"%s\" used.\n", yytext);
+ hlsl_error(ctx, *yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
+ "Reserved keyword \"%s\" used.", yytext);
}
BlendState {return KW_BLENDSTATE; }
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index c33d97c6..b6d03243 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -113,7 +113,7 @@ int yylex(HLSL_YYSTYPE *yylval_param, HLSL_YYLTYPE *yylloc_param, void *yyscanne
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s)
{
- hlsl_error(ctx, *loc, "%s", s);
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s);
}
static struct hlsl_ir_node *node_from_list(struct list *list)
@@ -124,7 +124,8 @@ static struct hlsl_ir_node *node_from_list(struct list *list)
static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc)
{
if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
- hlsl_error(ctx, loc, "'row_major' or 'column_major' modifiers are only allowed for matrices.");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "'row_major' and 'column_major' modifiers are only allowed for matrices.");
}
static bool convertible_data_type(struct hlsl_type *type)
@@ -257,14 +258,16 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
char *src_string = hlsl_type_to_string(src_type), *dst_string = hlsl_type_to_string(dst_type);
if (src_string && dst_string)
- hlsl_error(ctx, *loc, "Can't implicitly convert from %s to %s.", src_string, dst_string);
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Can't implicitly convert from %s to %s.", src_string, dst_string);
vkd3d_free(src_string);
vkd3d_free(dst_string);
return NULL;
}
if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy)
- hlsl_warning(ctx, *loc, "implicit truncation of vector type");
+ 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(node, dst_type, loc)))
return NULL;
@@ -289,14 +292,15 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
char *string;
if ((string = hlsl_modifiers_to_string(invalid)))
- hlsl_error(ctx, decl->loc,
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers '%s' are not allowed on local variables.", string);
vkd3d_free(string);
}
if (decl->semantic)
{
- hlsl_error(ctx, decl->loc, "semantics are not allowed on local variables");
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
+ "Semantics are not allowed on local variables.");
return false;
}
}
@@ -304,7 +308,8 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
{
if (hlsl_get_function(ctx, decl->name))
{
- hlsl_error(ctx, decl->loc, "redefinition of '%s'", decl->name);
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Variable '%s' is already defined as a function.", decl->name);
return false;
}
}
@@ -313,8 +318,9 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
{
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, decl->name);
- hlsl_error(ctx, decl->loc, "\"%s\" already declared", decl->name);
- hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here", old->name);
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Variable \"%s\" was already declared in this scope.", decl->name);
+ hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
return false;
}
return true;
@@ -327,13 +333,15 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con
char *string;
if ((string = hlsl_modifiers_to_string(mod)))
- hlsl_error(ctx, loc, "Modifier '%s' was already specified.", string);
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifier '%s' was already specified.", string);
vkd3d_free(string);
return modifiers;
}
if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK))
{
- hlsl_error(ctx, loc, "more than one matrix majority keyword");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "'row_major' and 'column_major' modifiers are mutually exclusive.");
return modifiers;
}
return modifiers | mod;
@@ -541,7 +549,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
}
else if (!hlsl_type_is_void(return_type))
{
- hlsl_error(ctx, loc, "non-void function must return a value");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value.");
return NULL;
}
@@ -631,9 +639,9 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in
else
{
if (expr_type->type == HLSL_CLASS_SCALAR)
- hlsl_error(ctx, loc, "array-indexed expression is scalar");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed.");
else
- hlsl_error(ctx, loc, "expression is not array-indexable");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed.");
return NULL;
}
@@ -733,7 +741,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty
field->semantic = v->semantic;
if (v->initializer.args_count)
{
- hlsl_error(ctx, v->loc, "struct field with an initializer.\n");
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field.\n");
free_parse_initializer(&v->initializer);
}
list_add_tail(list, &field->entry);
@@ -768,12 +776,13 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
- hlsl_error(ctx, v->loc, "more than one matrix majority keyword");
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "'row_major' and 'column_major' modifiers are mutually exclusive.");
ret = hlsl_scope_add_type(ctx->cur_scope, type);
if (!ret)
- hlsl_error(ctx, v->loc,
- "redefinition of custom type '%s'", v->name);
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Type '%s' is already defined.", v->name);
vkd3d_free(v);
}
vkd3d_free(list);
@@ -1009,7 +1018,8 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
if (t1->type > HLSL_CLASS_LAST_NUMERIC || t2->type > HLSL_CLASS_LAST_NUMERIC)
{
- hlsl_error(ctx, *loc, "non scalar/vector/matrix data type in expression");
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Non-numeric types cannot be used in expressions.");
return NULL;
}
@@ -1018,7 +1028,8 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
if (!expr_compatible_data_types(t1, t2))
{
- hlsl_error(ctx, *loc, "expression data types are incompatible");
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Expression data types are incompatible.");
return NULL;
}
@@ -1121,9 +1132,9 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
continue;
if (operands[i]->data_type->dimx * operands[i]->data_type->dimy != 1
&& operands[i]->data_type->dimx * operands[i]->data_type->dimy != type->dimx * type->dimy)
- {
- hlsl_warning(ctx, operands[i]->loc, "implicit truncation of vector/matrix type");
- }
+ hlsl_warning(ctx, operands[i]->loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION,
+ "Implicit truncation of %s type.",
+ operands[i]->data_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
if (!(cast = hlsl_new_cast(operands[i], type, &operands[i]->loc)))
return NULL;
@@ -1261,7 +1272,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
hlsl_src_from_node(&swizzle->val, rhs);
if (!invert_swizzle(&swizzle->swizzle, &writemask, &width))
{
- hlsl_error(ctx, lhs->loc, "invalid writemask");
+ hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask.");
vkd3d_free(assign);
return NULL;
}
@@ -1272,7 +1283,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
}
else
{
- hlsl_error(ctx, lhs->loc, "invalid lvalue");
+ hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue.");
vkd3d_free(assign);
return NULL;
}
@@ -1308,7 +1319,8 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (initializer_size(initializer) != hlsl_type_component_count(type))
{
- hlsl_error(ctx, var->loc, "structure initializer mismatch");
+ hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Wrong number of parameters in struct initializer.");
free_parse_initializer(initializer);
return;
}
@@ -1396,7 +1408,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if (type->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer.args_count)
{
- hlsl_error(ctx, v->loc, "const variable without initializer");
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER,
+ "Const variable \"%s\" is missing an initializer.", var->name);
hlsl_free_var(var);
vkd3d_free(v);
continue;
@@ -1420,8 +1433,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
{
if (size < type->dimx * type->dimy)
{
- hlsl_error(ctx, v->loc,
- "'%s' initializer does not match", v->name);
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Wrong number of parameters in numeric initializer.");
free_parse_initializer(&v->initializer);
vkd3d_free(v);
continue;
@@ -1430,8 +1443,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY)
&& hlsl_type_component_count(type) != size)
{
- hlsl_error(ctx, v->loc,
- "'%s' initializer does not match", v->name);
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Wrong number of parameters in initializer.");
free_parse_initializer(&v->initializer);
vkd3d_free(v);
continue;
@@ -1710,14 +1723,14 @@ hlsl_prog:
{
if (decl->body && $2.decl->body)
{
- hlsl_error(ctx, $2.decl->loc,
- "redefinition of function \"%s\"", $2.name);
+ hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Function \"%s\" is already defined.", $2.name);
YYABORT;
}
else if (!hlsl_type_compare(decl->return_type, $2.decl->return_type))
{
- hlsl_error(ctx, $2.decl->loc,
- "redefining function \"%s\" with a different return type", $2.name);
+ hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Function \"%s\" was already declared with a different return type.", $2.name);
hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR,
"\"%s\" previously declared here", $2.name);
YYABORT;
@@ -1725,10 +1738,8 @@ hlsl_prog:
}
if (hlsl_type_is_void($2.decl->return_type) && $2.decl->semantic)
- {
- hlsl_error(ctx, $2.decl->loc,
- "void function with a semantic");
- }
+ hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
+ "Semantics are not allowed on void functions.");
hlsl_add_function(&ctx->functions, $2.name, $2.decl, false);
}
@@ -1772,15 +1783,11 @@ struct_declaration:
if (!$3)
{
if (!$2->name)
- {
- hlsl_error(ctx, @2,
- "anonymous struct declaration with no variables");
- }
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
+ "Anonymous struct type must declare a variable.");
if (modifiers)
- {
- hlsl_error(ctx, @1,
- "modifier not allowed on struct type declaration");
- }
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on struct type declataions.");
}
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
@@ -1801,14 +1808,14 @@ named_struct_spec:
if (hlsl_get_var(ctx->cur_scope, $2))
{
- hlsl_error(ctx, @2, "redefinition of '%s'", $2);
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is already declared as a variable.", $2);
YYABORT;
}
ret = hlsl_scope_add_type(ctx->cur_scope, $$);
if (!ret)
{
- hlsl_error(ctx, @2, "redefinition of struct '%s'", $2);
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct \"%s\" is already defined.", $2);
YYABORT;
}
}
@@ -1841,7 +1848,8 @@ fields_list:
ret = add_struct_field($$, field);
if (ret == false)
{
- hlsl_error(ctx, @2, "redefinition of '%s'", field->name);
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Field \"%s\" is already defined.", field->name);
vkd3d_free(field);
}
}
@@ -1882,17 +1890,19 @@ func_prototype:
{
if ($1)
{
- hlsl_error(ctx, @1, "unexpected modifiers on a function");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on functions.");
YYABORT;
}
if (hlsl_get_var(ctx->globals, $3))
{
- hlsl_error(ctx, @3, "redefinition of '%s'\n", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Function \"%s\" is already defined.", $3);
YYABORT;
}
if (hlsl_type_is_void($2) && $7.semantic)
{
- hlsl_error(ctx, @7, "void function with a semantic");
+ hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
+ "Semantics are not allowed on void functions.");
}
if ($7.reg_reservation)
@@ -1995,7 +2005,8 @@ param_list:
$$ = $1;
if (!add_func_parameter(ctx, $$, &$3, @3))
{
- hlsl_error(ctx, @3, "duplicate parameter %s", $3.name);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Parameter \"%s\" is already declared.", $3.name);
YYABORT;
}
}
@@ -2026,8 +2037,7 @@ input_mods:
{
if ($1 & $2)
{
- hlsl_error(ctx, @2,
- "duplicate input-output modifiers");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Duplicate modifiers specified.");
YYABORT;
}
$$ = $1 | $2;
@@ -2056,14 +2066,14 @@ type:
{
if ($3->type != HLSL_CLASS_SCALAR)
{
- hlsl_error(ctx, @3,
- "vectors of non-scalar types are not allowed\n");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Vectors of non-scalar types are not allowed.");
YYABORT;
}
if ($5 < 1 || $5 > 4)
{
- hlsl_error(ctx, @5,
- "vector size must be between 1 and 4\n");
+ hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Vector size must be between 1 and 4.");
YYABORT;
}
@@ -2073,20 +2083,20 @@ type:
{
if ($3->type != HLSL_CLASS_SCALAR)
{
- hlsl_error(ctx, @3,
- "matrices of non-scalar types are not allowed\n");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Matrices of non-scalar types are not allowed.");
YYABORT;
}
if ($5 < 1 || $5 > 4)
{
- hlsl_error(ctx, @5,
- "matrix row count must be between 1 and 4\n");
+ hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Matrix row count must be between 1 and 4.");
YYABORT;
}
if ($7 < 1 || $7 > 4)
{
- hlsl_error(ctx, @7,
- "matrix column count must be between 1 and 4\n");
+ hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Matrix column count must be between 1 and 4.");
YYABORT;
}
@@ -2127,7 +2137,7 @@ base_type:
{
$$ = hlsl_get_type(ctx->cur_scope, $2, true);
if ($$->type != HLSL_CLASS_STRUCT)
- hlsl_error(ctx, @1, "'%s' redefined as a structure\n", $2);
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" redefined as a structure.", $2);
vkd3d_free($2);
}
@@ -2151,7 +2161,8 @@ typedef:
if ($2 & ~HLSL_TYPE_MODIFIERS_MASK)
{
struct parse_variable_def *v, *v_next;
- hlsl_error(ctx, @1, "modifier not allowed on typedefs");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Storage modifiers are not allowed on typedefs.");
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry)
vkd3d_free(v);
vkd3d_free($4);
@@ -2248,15 +2259,15 @@ array:
if (!size)
{
- hlsl_error(ctx, @2,
- "array size is not a positive integer constant\n");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Array size is not a positive integer constant.");
YYABORT;
}
if (size > 65536)
{
- hlsl_error(ctx, @2,
- "array size must be between 1 and 65536");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Array size must be between 1 and 65536.");
YYABORT;
}
$$ = size;
@@ -2408,8 +2419,8 @@ selection_statement:
vkd3d_free($5.then_instrs);
vkd3d_free($5.else_instrs);
if (condition->data_type->dimx > 1 || condition->data_type->dimy > 1)
- hlsl_error(ctx, instr->node.loc,
- "if condition requires a scalar");
+ hlsl_error(ctx, instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "if condition requires a scalar.");
$$ = $3;
list_add_tail($$, &instr->node.entry);
}
@@ -2498,7 +2509,7 @@ primary_expr:
if (!(var = hlsl_get_var(ctx->cur_scope, $1)))
{
- hlsl_error(ctx, @1, "variable '%s' is not declared\n", $1);
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1);
YYABORT;
}
if ((load = hlsl_new_var_load(var, @1)))
@@ -2522,7 +2533,7 @@ postfix_expr:
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @2, "modifying a const expression");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTINC, node_from_list($1), @2);
@@ -2537,7 +2548,7 @@ postfix_expr:
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @2, "modifying a const expression");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTDEC, node_from_list($1), @2);
@@ -2568,7 +2579,7 @@ postfix_expr:
}
if (!$$)
{
- hlsl_error(ctx, @3, "invalid subscript \"%s\"", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field \"%s\" is not defined.", $3);
YYABORT;
}
}
@@ -2578,14 +2589,14 @@ postfix_expr:
if (!(swizzle = get_swizzle(ctx, node, $3, &@3)))
{
- hlsl_error(ctx, @3, "invalid swizzle \"%s\"", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle \"%s\".", $3);
YYABORT;
}
$$ = append_unop($1, &swizzle->node);
}
else
{
- hlsl_error(ctx, @3, "invalid subscript \"%s\"", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript \"%s\".", $3);
YYABORT;
}
}
@@ -2598,7 +2609,7 @@ postfix_expr:
if (index->data_type->type != HLSL_CLASS_SCALAR)
{
- hlsl_error(ctx, @3, "array index is not scalar");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar.");
hlsl_free_instr_list($1);
YYABORT;
}
@@ -2623,20 +2634,20 @@ postfix_expr:
if ($1)
{
- hlsl_error(ctx, @1,
- "unexpected modifier on a constructor\n");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on constructors.");
YYABORT;
}
if ($2->type > HLSL_CLASS_LAST_NUMERIC)
{
- hlsl_error(ctx, @2,
- "constructors may only be used with numeric data types\n");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Constructors may only be used with numeric data types.");
YYABORT;
}
if ($2->dimx * $2->dimy != initializer_size(&$4))
{
- hlsl_error(ctx, @4,
- "expected %u components in constructor, but got %u\n",
+ hlsl_error(ctx, @4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Expected %u components in constructor, but got %u.",
$2->dimx * $2->dimy, initializer_size(&$4));
YYABORT;
}
@@ -2654,7 +2665,8 @@ postfix_expr:
if (arg->data_type->type == HLSL_CLASS_OBJECT)
{
- hlsl_error(ctx, arg->loc, "invalid constructor argument");
+ hlsl_error(ctx, arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Invalid type for constructor argument.");
continue;
}
width = hlsl_type_component_count(arg->data_type);
@@ -2687,7 +2699,7 @@ unary_expr:
{
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @1, "modifying a const expression");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREINC, node_from_list($2), @1));
@@ -2696,7 +2708,7 @@ unary_expr:
{
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @1, "modifying a const expression");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREDEC, node_from_list($2), @1));
@@ -2720,7 +2732,8 @@ unary_expr:
if ($2)
{
- hlsl_error(ctx, @3, "unexpected modifier in a cast");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on casts.");
YYABORT;
}
@@ -2734,7 +2747,8 @@ unary_expr:
char *src_string = hlsl_type_to_string(src_type), *dst_string = hlsl_type_to_string(dst_type);
if (src_string && dst_string)
- hlsl_error(ctx, @3, "Can't cast from %s to %s.", src_string, dst_string);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.",
+ src_string, dst_string);
vkd3d_free(src_string);
vkd3d_free(dst_string);
YYABORT;
@@ -2879,7 +2893,7 @@ assignment_expr:
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @2, "l-value is const");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
list_move_tail($3, $1);
@@ -3103,8 +3117,8 @@ int hlsl_parser_compile(struct hlsl_ctx *ctx, const char *entrypoint)
if (!hlsl_type_is_void(entry_func->return_type)
&& entry_func->return_type->type != HLSL_CLASS_STRUCT && !entry_func->semantic)
{
- hlsl_error(ctx, entry_func->loc,
- "entry point \"%s\" is missing a return value semantic", entry_func->func->name);
+ hlsl_error(ctx, entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
+ "Entry point \"%s\" is missing a return value semantic.", entry_func->func->name);
}
list_move_head(entry_func->body, &ctx->static_initializers);
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h
index 6101c385..2d7eb05b 100644
--- a/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -91,6 +91,24 @@ enum vkd3d_shader_error
VKD3D_SHADER_WARNING_PP_UNTERMINATED_MACRO = 4304,
VKD3D_SHADER_WARNING_PP_UNTERMINATED_IF = 4305,
VKD3D_SHADER_WARNING_PP_DIV_BY_ZERO = 4306,
+
+ VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX = 5000,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER = 5001,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE = 5002,
+ VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST = 5003,
+ VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC = 5004,
+ VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED = 5005,
+ VKD3D_SHADER_ERROR_HLSL_REDEFINED = 5006,
+ VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT = 5007,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE = 5008,
+ VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER = 5009,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE = 5010,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK = 5011,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX = 5012,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC = 5013,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN = 5014,
+
+ VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
};
enum vkd3d_shader_opcode
--
2.30.1
3
8
[PATCH 4/5] d3d11: Implement d3d11_immediate_context_SwapDeviceContextState() on top of wined3d_device_set_state().
by Henri Verbeet 23 Feb '21
by Henri Verbeet 23 Feb '21
23 Feb '21
Based on a patch by Rémi Bernon.
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
This supersedes patch 200188.
dlls/d3d11/d3d11_private.h | 36 ++---
dlls/d3d11/device.c | 293 +++++++++++++++++++++++--------------
dlls/d3d11/tests/d3d11.c | 140 +++++++-----------
3 files changed, 250 insertions(+), 219 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index 650b5c358716..a64d6975f857 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -516,6 +516,12 @@ struct d3d_query *unsafe_impl_from_ID3D11Query(ID3D11Query *iface) DECLSPEC_HIDD
struct d3d_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface) DECLSPEC_HIDDEN;
struct d3d_query *unsafe_impl_from_ID3D11Asynchronous(ID3D11Asynchronous *iface) DECLSPEC_HIDDEN;
+struct d3d_device_context_state_entry
+{
+ struct d3d_device *device;
+ struct wined3d_state *wined3d_state;
+};
+
/* ID3DDeviceContextState */
struct d3d_device_context_state
{
@@ -523,30 +529,12 @@ struct d3d_device_context_state
LONG refcount, private_refcount;
struct wined3d_private_store private_store;
- struct
- {
- ID3D11VertexShader *shader;
- ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
- ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
- ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
- } vs;
- struct
- {
- ID3D11GeometryShader *shader;
- ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
- ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
- ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
- } gs;
- struct
- {
- ID3D11PixelShader *shader;
- ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
- ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
- ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
- } ps;
-
GUID emulated_interface;
+ struct d3d_device_context_state_entry *entries;
+ SIZE_T entries_size;
+ SIZE_T entry_count;
+
struct wined3d_device *wined3d_device;
ID3D11Device2 *device;
};
@@ -585,6 +573,10 @@ struct d3d_device
struct wine_rb_tree depthstencil_states;
struct wine_rb_tree rasterizer_states;
struct wine_rb_tree sampler_states;
+
+ struct d3d_device_context_state **context_states;
+ SIZE_T context_states_size;
+ SIZE_T context_state_count;
};
static inline struct d3d_device *impl_from_ID3D11Device(ID3D11Device *iface)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index b0041c858816..a5d9dc1aa7be 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -22,6 +22,32 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
+static BOOL d3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
+{
+ SIZE_T max_capacity, new_capacity;
+ void *new_elements;
+
+ if (count <= *capacity)
+ return TRUE;
+
+ max_capacity = ~(SIZE_T)0 / size;
+ if (count > max_capacity)
+ return FALSE;
+
+ new_capacity = max(1, *capacity);
+ while (new_capacity < count && new_capacity <= max_capacity / 2)
+ new_capacity *= 2;
+ if (new_capacity < count)
+ new_capacity = count;
+
+ if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
+ return FALSE;
+
+ *elements = new_elements;
+ *capacity = new_capacity;
+ return TRUE;
+}
+
static void STDMETHODCALLTYPE d3d_null_wined3d_object_destroyed(void *parent) {}
static const struct wined3d_parent_ops d3d_null_wined3d_parent_ops =
@@ -88,9 +114,27 @@ static ULONG STDMETHODCALLTYPE d3d_device_context_state_AddRef(ID3DDeviceContext
return refcount;
}
+static void d3d_device_remove_context_state(struct d3d_device *device, struct d3d_device_context_state *state)
+{
+ unsigned int i;
+
+ for (i = 0; i < device->context_state_count; ++i)
+ {
+ if (device->context_states[i] != state)
+ continue;
+
+ if (i != device->context_state_count - 1)
+ device->context_states[i] = device->context_states[device->context_state_count - 1];
+ --device->context_state_count;
+ break;
+ }
+}
+
static void d3d_device_context_state_private_release(struct d3d_device_context_state *state)
{
ULONG refcount = InterlockedDecrement(&state->private_refcount);
+ struct d3d_device_context_state_entry *entry;
+ struct d3d_device *device;
unsigned int i;
TRACE("%p decreasing private refcount to %u.\n", state, refcount);
@@ -98,27 +142,17 @@ static void d3d_device_context_state_private_release(struct d3d_device_context_s
if (!refcount)
{
wined3d_private_store_cleanup(&state->private_store);
- if (state->vs.shader) ID3D11VertexShader_Release(state->vs.shader);
- if (state->gs.shader) ID3D11GeometryShader_Release(state->gs.shader);
- if (state->ps.shader) ID3D11PixelShader_Release(state->ps.shader);
- for (i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
- {
- if (state->vs.samplers[i]) ID3D11SamplerState_Release(state->vs.samplers[i]);
- if (state->gs.samplers[i]) ID3D11SamplerState_Release(state->gs.samplers[i]);
- if (state->ps.samplers[i]) ID3D11SamplerState_Release(state->ps.samplers[i]);
- }
- for (i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
+ for (i = 0; i < state->entry_count; ++i)
{
- if (state->vs.srvs[i]) ID3D11ShaderResourceView_Release(state->vs.srvs[i]);
- if (state->gs.srvs[i]) ID3D11ShaderResourceView_Release(state->gs.srvs[i]);
- if (state->ps.srvs[i]) ID3D11ShaderResourceView_Release(state->ps.srvs[i]);
- }
- for (i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
- {
- if (state->vs.cbs[i]) ID3D11Buffer_Release(state->vs.cbs[i]);
- if (state->gs.cbs[i]) ID3D11Buffer_Release(state->gs.cbs[i]);
- if (state->ps.cbs[i]) ID3D11Buffer_Release(state->ps.cbs[i]);
+ entry = &state->entries[i];
+ device = entry->device;
+
+ if (entry->wined3d_state != wined3d_device_get_state(device->wined3d_device))
+ wined3d_state_destroy(entry->wined3d_state);
+
+ d3d_device_remove_context_state(device, state);
}
+ heap_free(state->entries);
wined3d_device_decref(state->wined3d_device);
heap_free(state);
}
@@ -194,6 +228,85 @@ static const struct ID3DDeviceContextStateVtbl d3d_device_context_state_vtbl =
/* ID3DDeviceContextState methods */
};
+static struct d3d_device_context_state_entry *d3d_device_context_state_get_entry(
+ struct d3d_device_context_state *state, struct d3d_device *device)
+{
+ unsigned int i;
+
+ for (i = 0; i < state->entry_count; ++i)
+ {
+ if (state->entries[i].device == device)
+ return &state->entries[i];
+ }
+
+ return NULL;
+}
+
+static BOOL d3d_device_context_state_add_entry(struct d3d_device_context_state *state,
+ struct d3d_device *device, struct wined3d_state *wined3d_state)
+{
+ struct d3d_device_context_state_entry *entry;
+
+ if (!d3d_array_reserve((void **)&state->entries, &state->entries_size,
+ state->entry_count + 1, sizeof(*state->entries)))
+ return FALSE;
+
+ if (!d3d_array_reserve((void **)&device->context_states, &device->context_states_size,
+ device->context_state_count + 1, sizeof(*device->context_states)))
+ return FALSE;
+
+ entry = &state->entries[state->entry_count++];
+ entry->device = device;
+ entry->wined3d_state = wined3d_state;
+
+ device->context_states[device->context_state_count++] = state;
+
+ return TRUE;
+}
+
+static void d3d_device_context_state_remove_entry(struct d3d_device_context_state *state, struct d3d_device *device)
+{
+ struct d3d_device_context_state_entry *entry;
+ unsigned int i;
+
+ for (i = 0; i < state->entry_count; ++i)
+ {
+ entry = &state->entries[i];
+ if (entry->device != device)
+ continue;
+
+ if (entry->wined3d_state != wined3d_device_get_state(device->wined3d_device))
+ wined3d_state_destroy(entry->wined3d_state);
+
+ if (i != state->entry_count)
+ state->entries[i] = state->entries[state->entry_count - 1];
+ --state->entry_count;
+
+ break;
+ }
+}
+
+static struct wined3d_state *d3d_device_context_state_get_wined3d_state(struct d3d_device_context_state *state,
+ struct d3d_device *device)
+{
+ struct d3d_device_context_state_entry *entry;
+ struct wined3d_state *wined3d_state;
+
+ if ((entry = d3d_device_context_state_get_entry(state, device)))
+ return entry->wined3d_state;
+
+ if (FAILED(wined3d_state_create(device->wined3d_device, &wined3d_state)))
+ return NULL;
+
+ if (!d3d_device_context_state_add_entry(state, device, wined3d_state))
+ {
+ wined3d_state_destroy(wined3d_state);
+ return NULL;
+ }
+
+ return wined3d_state;
+}
+
static void d3d_device_context_state_init(struct d3d_device_context_state *state, struct d3d_device *device,
REFIID emulated_interface)
{
@@ -201,9 +314,6 @@ static void d3d_device_context_state_init(struct d3d_device_context_state *state
state->refcount = state->private_refcount = 0;
wined3d_private_store_init(&state->private_store);
- memset(&state->vs, 0, sizeof(state->vs));
- memset(&state->gs, 0, sizeof(state->gs));
- memset(&state->ps, 0, sizeof(state->ps));
state->emulated_interface = *emulated_interface;
wined3d_device_incref(state->wined3d_device = device->wined3d_device);
@@ -2722,98 +2832,39 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers1(ID3D
iface, start_slot, buffer_count, buffers, first_constant, num_constants);
}
-static void d3d11_immediate_context_capture_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state)
+static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1 *iface,
+ ID3DDeviceContextState *state, ID3DDeviceContextState **prev)
{
- wined3d_mutex_lock();
-
- d3d11_immediate_context_VSGetShader(iface, &state->vs.shader, NULL, 0);
- d3d11_immediate_context_VSGetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers);
- d3d11_immediate_context_VSGetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs);
- d3d11_immediate_context_VSGetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs);
-
- d3d11_immediate_context_GSGetShader(iface, &state->gs.shader, NULL, 0);
- d3d11_immediate_context_GSGetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers);
- d3d11_immediate_context_GSGetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs);
- d3d11_immediate_context_GSGetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs);
+ struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface);
+ struct d3d_device_context_state *state_impl, *prev_impl;
+ struct wined3d_state *wined3d_state;
- d3d11_immediate_context_PSGetShader(iface, &state->ps.shader, NULL, 0);
- d3d11_immediate_context_PSGetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers);
- d3d11_immediate_context_PSGetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs);
- d3d11_immediate_context_PSGetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs);
+ FIXME("iface %p, state %p, prev %p semi-stub!\n", iface, state, prev);
- wined3d_mutex_unlock();
-}
+ if (!state)
+ {
+ if (prev)
+ *prev = NULL;
+ return;
+ }
-static void d3d11_immediate_context_restore_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state)
-{
wined3d_mutex_lock();
- d3d11_immediate_context_VSSetShader(iface, state->vs.shader, NULL, 0);
- d3d11_immediate_context_VSSetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers);
- d3d11_immediate_context_VSSetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs);
- d3d11_immediate_context_VSSetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs);
+ prev_impl = device->state;
+ state_impl = impl_from_ID3DDeviceContextState(state);
+ if (!(wined3d_state = d3d_device_context_state_get_wined3d_state(state_impl, device)))
+ ERR("Failed to get wined3d state for device context state %p.\n", state_impl);
+ wined3d_device_set_state(device->wined3d_device, wined3d_state);
- d3d11_immediate_context_GSSetShader(iface, state->gs.shader, NULL, 0);
- d3d11_immediate_context_GSSetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers);
- d3d11_immediate_context_GSSetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs);
- d3d11_immediate_context_GSSetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs);
+ if (prev)
+ ID3DDeviceContextState_AddRef(*prev = &prev_impl->ID3DDeviceContextState_iface);
- d3d11_immediate_context_PSSetShader(iface, state->ps.shader, NULL, 0);
- d3d11_immediate_context_PSSetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers);
- d3d11_immediate_context_PSSetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs);
- d3d11_immediate_context_PSSetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs);
+ d3d_device_context_state_private_addref(state_impl);
+ device->state = state_impl;
+ d3d_device_context_state_private_release(prev_impl);
- wined3d_mutex_unlock();
-}
-
-static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1 *iface,
- ID3DDeviceContextState *state, ID3DDeviceContextState **prev_state)
-{
- struct d3d_device_context_state *state_impl;
- struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface);
-
- FIXME("iface %p, state %p, prev_state %p semi-stub!\n", iface, state, prev_state);
-
- if (prev_state) *prev_state = NULL;
- if (!state) return;
-
- wined3d_mutex_lock();
- if (prev_state)
- {
- *prev_state = NULL;
- if ((state_impl = heap_alloc(sizeof(*state_impl))))
- {
- d3d_device_context_state_init(state_impl, device, &device->state->emulated_interface);
- d3d11_immediate_context_capture_state(iface, state_impl);
- *prev_state = &state_impl->ID3DDeviceContextState_iface;
- }
- }
-
- if ((state_impl = impl_from_ID3DDeviceContextState(state)))
- {
- d3d11_immediate_context_restore_state(iface, state_impl);
- device->state->emulated_interface = state_impl->emulated_interface;
- if (d3d_device_is_d3d10_active(device))
- FIXME("D3D10 interface emulation not fully implemented yet!\n");
- }
+ if (d3d_device_is_d3d10_active(device))
+ FIXME("D3D10 interface emulation not fully implemented yet!\n");
wined3d_mutex_unlock();
}
@@ -4027,9 +4078,12 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeviceContextState(ID3D11Dev
if (state)
{
- *state = NULL;
- if (!(state_impl = heap_alloc(sizeof(*state_impl))))
+ if (!(state_impl = heap_alloc_zero(sizeof(*state_impl))))
+ {
+ *state = NULL;
return E_OUTOFMEMORY;
+ }
+
d3d_device_context_state_init(state_impl, device, emulated_interface);
*state = &state_impl->ID3DDeviceContextState_iface;
}
@@ -4211,12 +4265,19 @@ static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface)
{
struct d3d_device *device = impl_from_IUnknown(iface);
ULONG refcount = InterlockedDecrement(&device->refcount);
+ unsigned int i;
TRACE("%p decreasing refcount to %u.\n", device, refcount);
if (!refcount)
{
- if (device->state) d3d_device_context_state_private_release(device->state);
+ if (device->state)
+ d3d_device_context_state_private_release(device->state);
+ for (i = 0; i < device->context_state_count; ++i)
+ {
+ d3d_device_context_state_remove_entry(device->context_states[i], device);
+ }
+ heap_free(device->context_states);
d3d11_immediate_context_destroy(&device->immediate_context);
if (device->wined3d_device)
{
@@ -6394,6 +6455,7 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
struct wined3d_device *wined3d_device)
{
struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
+ struct wined3d_state *wined3d_state;
ID3DDeviceContextState *state;
HRESULT hr;
@@ -6407,13 +6469,18 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
if (FAILED(hr = d3d11_device_CreateDeviceContextState(&device->ID3D11Device2_iface, 0, &device->feature_level,
1, D3D11_SDK_VERSION, device->d3d11_only ? &IID_ID3D11Device2 : &IID_ID3D10Device1, NULL,
&state)))
- ERR("Failed to create the initial device context state, hr %#x.\n", hr);
- else
{
- device->state = impl_from_ID3DDeviceContextState(state);
- d3d_device_context_state_private_addref(device->state);
- ID3DDeviceContextState_Release(state);
+ ERR("Failed to create the initial device context state, hr %#x.\n", hr);
+ return;
}
+
+ device->state = impl_from_ID3DDeviceContextState(state);
+ wined3d_state = wined3d_device_get_state(device->wined3d_device);
+ if (!d3d_device_context_state_add_entry(device->state, device, wined3d_state))
+ ERR("Failed to add entry for wined3d state %p, device %p.\n", wined3d_state, device);
+
+ d3d_device_context_state_private_addref(device->state);
+ ID3DDeviceContextState_Release(state);
}
static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 1505b3fddbc7..2eff98fe8fcf 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -7083,7 +7083,7 @@ static void test_device_context_state(void)
ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &previous_context_state);
ok(previous_context_state != NULL, "Failed to get previous context state\n");
refcount = get_refcount(vs);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
hr = ID3DDeviceContextState_SetPrivateData(context_state, &test_guid, sizeof(constant), &constant);
ok(hr == S_OK, "Failed to set private data, hr %#x.\n", hr);
@@ -7093,9 +7093,9 @@ static void test_device_context_state(void)
data_size = sizeof(data);
memset(data, 0xa5, sizeof(data));
hr = ID3DDeviceContextState_GetPrivateData(context_state, &test_guid, &data_size, data);
- todo_wine ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr);
- todo_wine ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant));
- todo_wine ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n");
+ ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr);
+ ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant));
+ ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n");
ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, NULL);
context_type = ID3D11DeviceContext1_GetType(context);
@@ -7142,118 +7142,96 @@ static void test_device_context_state(void)
tmp_cb = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_HSGetConstantBuffers(context, 0, 1, &tmp_cb);
- todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
- if (tmp_cb) ID3D11Buffer_Release(tmp_cb);
+ ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
tmp_sampler = (ID3D11SamplerState *)0xdeadbeef;
ID3D11DeviceContext1_HSGetSamplers(context, 0, 1, &tmp_sampler);
- todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
- if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler);
+ ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
tmp_hs = (ID3D11HullShader *)0xdeadbeef;
ID3D11DeviceContext1_HSGetShader(context, &tmp_hs, NULL, NULL);
- if (hs) todo_wine ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs);
- if (tmp_hs) ID3D11HullShader_Release(tmp_hs);
+ if (hs) ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs);
tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef;
ID3D11DeviceContext1_HSGetShaderResources(context, 0, 1, &tmp_srv);
- todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
- if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv);
+ ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_DSGetConstantBuffers(context, 0, 1, &tmp_cb);
- todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
- if (tmp_cb) ID3D11Buffer_Release(tmp_cb);
+ ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
tmp_sampler = (ID3D11SamplerState *)0xdeadbeef;
ID3D11DeviceContext1_DSGetSamplers(context, 0, 1, &tmp_sampler);
- todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
- if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler);
+ ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
tmp_ds = (ID3D11DomainShader *)0xdeadbeef;
ID3D11DeviceContext1_DSGetShader(context, &tmp_ds, NULL, NULL);
- if (ds) todo_wine ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds);
- if (tmp_ds) ID3D11DomainShader_Release(tmp_ds);
+ if (ds) ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds);
tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef;
ID3D11DeviceContext1_DSGetShaderResources(context, 0, 1, &tmp_srv);
- todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
- if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv);
+ ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_CSGetConstantBuffers(context, 0, 1, &tmp_cb);
- todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
- if (tmp_cb) ID3D11Buffer_Release(tmp_cb);
+ ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
tmp_sampler = (ID3D11SamplerState *)0xdeadbeef;
ID3D11DeviceContext1_CSGetSamplers(context, 0, 1, &tmp_sampler);
- todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
- if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler);
+ ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
tmp_cs = (ID3D11ComputeShader *)0xdeadbeef;
ID3D11DeviceContext1_CSGetShader(context, &tmp_cs, NULL, NULL);
- if (cs) todo_wine ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs);
- if (tmp_cs) ID3D11ComputeShader_Release(tmp_cs);
+ if (cs) ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs);
tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef;
ID3D11DeviceContext1_CSGetShaderResources(context, 0, 1, &tmp_srv);
- todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
- if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv);
+ ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef;
ID3D11DeviceContext1_CSGetUnorderedAccessViews(context, 0, 1, &tmp_uav);
- todo_wine ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav);
- if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav);
+ ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav);
topo = 0xdeadbeef;
ID3D11DeviceContext1_IAGetPrimitiveTopology(context, &topo);
- todo_wine ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo);
+ ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo);
tmp_il = (ID3D11InputLayout *)0xdeadbeef;
ID3D11DeviceContext1_IAGetInputLayout(context, &tmp_il);
- todo_wine ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il);
- if (tmp_il) ID3D11InputLayout_Release(tmp_il);
+ ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il);
tmp_ib = (ID3D11Buffer *)0xdeadbeef;
format = 0xdeadbeef;
offset = 0xdeadbeef;
ID3D11DeviceContext1_IAGetIndexBuffer(context, &tmp_ib, &format, &offset);
- todo_wine ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib);
- if (tmp_ib) ID3D11Buffer_Release(tmp_ib);
- todo_wine ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format);
- todo_wine ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset);
+ ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib);
+ ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format);
+ ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset);
tmp_vb = (ID3D11Buffer *)0xdeadbeef;
stride = 0xdeadbeef;
offset = 0xdeadbeef;
ID3D11DeviceContext1_IAGetVertexBuffers(context, 0, 1, &tmp_vb, &stride, &offset);
- todo_wine ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb);
- if (tmp_vb) ID3D11Buffer_Release(tmp_vb);
- todo_wine ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride);
- todo_wine ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset);
+ ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb);
+ ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride);
+ ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset);
tmp_rtv = (ID3D11RenderTargetView *)0xdeadbeef;
tmp_dsv = (ID3D11DepthStencilView *)0xdeadbeef;
tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef;
ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context, 1, &tmp_rtv, &tmp_dsv, 1, 1, &tmp_uav);
- todo_wine ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv);
- if (tmp_rtv) ID3D11RenderTargetView_Release(tmp_rtv);
- todo_wine ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv);
- if (tmp_dsv) ID3D11DepthStencilView_Release(tmp_dsv);
- todo_wine ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav);
- if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav);
+ ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv);
+ ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv);
+ ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav);
tmp_bs = (ID3D11BlendState *)0xdeadbeef;
memset(blend_factor, 0xcd, sizeof(blend_factor));
sample_mask = 0xdeadbeef;
ID3D11DeviceContext1_OMGetBlendState(context, &tmp_bs, blend_factor, &sample_mask);
- todo_wine ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs);
- if (tmp_bs) ID3D11BlendState_Release(tmp_bs);
- todo_wine ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)),
+ ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs);
+ ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)),
"Got unexpected blend factor %f,%f,%f,%f.\n",
blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
- todo_wine ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask);
+ ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask);
tmp_dss = (ID3D11DepthStencilState *)0xdeadbeef;
stencil_ref = 0xdeadbeef;
ID3D11DeviceContext1_OMGetDepthStencilState(context, &tmp_dss, &stencil_ref);
- todo_wine ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss);
- if (tmp_dss) ID3D11DepthStencilState_Release(tmp_dss);
- todo_wine ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref);
+ ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss);
+ ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref);
tmp_rs = (ID3D11RasterizerState *)0xdeadbeef;
ID3D11DeviceContext1_RSGetState(context, &tmp_rs);
- todo_wine ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs);
- if (tmp_rs) ID3D11RasterizerState_Release(tmp_rs);
+ ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs);
memset(tmp_vp, 0xa5, sizeof(tmp_vp));
count = 2;
ID3D11DeviceContext1_RSGetViewports(context, &count, tmp_vp);
- todo_wine ok(count == 0, "Got unexpected viewport count %u.\n", count);
+ ok(count == 0, "Got unexpected viewport count %u.\n", count);
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
@@ -7261,15 +7239,13 @@ static void test_device_context_state(void)
tmp_sob = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_SOGetTargets(context, 1, &tmp_sob);
- todo_wine ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob);
- if (tmp_sob) ID3D11Buffer_Release(tmp_sob);
+ ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob);
tmp_pred = (ID3D11Predicate *)0xdeadbeef;
pred_value = 0xdeadbeef;
ID3D11DeviceContext1_GetPredication(context, &tmp_pred, &pred_value);
- todo_wine ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred);
- if (tmp_pred) ID3D11Predicate_Release(tmp_pred);
- todo_wine ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value);
+ ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred);
+ ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value);
/* updating the device context should also update the device context state */
hr = ID3D11Device1_CreateVertexShader(device, simple_vs, sizeof(simple_vs), NULL, &vs2);
@@ -7277,14 +7253,13 @@ static void test_device_context_state(void)
ID3D11DeviceContext1_VSSetShader(context, vs2, NULL, 0);
ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &tmp_context_state);
refcount = ID3DDeviceContextState_Release(tmp_context_state);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
- todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* context states may be used with other devices instances too */
d3d11_device2 = create_device(NULL);
@@ -7305,17 +7280,16 @@ static void test_device_context_state(void)
/* updating context2 vertex shader doesn't update other contexts using the same state */
ID3D11DeviceContext1_VSSetShader(context2, vs, NULL, 0);
ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
ID3D11DeviceContext1_SwapDeviceContextState(context2, tmp_context_state, &context_state2);
refcount = ID3DDeviceContextState_Release(tmp_context_state);
ok(refcount == 0, "Got refcount %u, expected 1.\n", refcount);
refcount = ID3DDeviceContextState_Release(context_state2);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
- todo_wine ok(context_state2 == context_state, "Got unexpected state pointer.\n");
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(context_state2 == context_state, "Got unexpected state pointer.\n");
/* swapping the default state on context2 effectively clears the vertex shader */
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
@@ -7333,19 +7307,17 @@ static void test_device_context_state(void)
ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount);
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* even after swapping it again */
ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, NULL);
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* swapping the initial state on context2 doesn't have side effect on context either */
ID3D11DeviceContext1_SwapDeviceContextState(context2, previous_context_state, NULL);
@@ -7362,10 +7334,10 @@ static void test_device_context_state(void)
refcount = ID3DDeviceContextState_Release(previous_context_state);
ok(!refcount, "Got refcount %u, expected 0.\n", refcount);
refcount = ID3DDeviceContextState_Release(tmp_context_state);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
refcount = ID3DDeviceContextState_Release(context_state);
ok(!refcount, "Got refcount %u, expected 0.\n", refcount);
- todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
+ ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
refcount = get_refcount(vs);
ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
--
2.20.1
2
1
[PATCH 3/5] wined3d: Introduce public API to set a wined3d_state object on a device.
by Henri Verbeet 23 Feb '21
by Henri Verbeet 23 Feb '21
23 Feb '21
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
This supersedes patches 200183 and 200187.
dlls/wined3d/device.c | 139 ++++++++++++++++++++++++++++++++++++--
dlls/wined3d/stateblock.c | 22 ++++++
dlls/wined3d/wined3d.spec | 5 ++
include/wine/wined3d.h | 6 ++
4 files changed, 167 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index c9df09b53483..7405a38e13b8 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -251,7 +251,7 @@ void wined3d_device_cleanup(struct wined3d_device *device)
wine_rb_destroy(&device->depth_stencil_states, device_leftover_depth_stencil_state, NULL);
wine_rb_destroy(&device->so_descs, device_free_so_desc, NULL);
- heap_free(device->state);
+ wined3d_state_destroy(device->state);
device->state = NULL;
wined3d_decref(device->wined3d);
device->wined3d = NULL;
@@ -1926,6 +1926,136 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device,
*rect_count = state->scissor_rect_count;
}
+void CDECL wined3d_device_set_state(struct wined3d_device *device, struct wined3d_state *state)
+{
+ const struct wined3d_light_info *light;
+ unsigned int i, j;
+
+ TRACE("device %p, state %p.\n", device, state);
+
+ device->state = state;
+
+ for (i = 0; i < WINED3D_MAX_RENDER_TARGETS; ++i)
+ {
+ wined3d_cs_emit_set_rendertarget_view(device->cs, i, state->fb.render_targets[i]);
+ }
+
+ wined3d_cs_emit_set_depth_stencil_view(device->cs, state->fb.depth_stencil);
+ wined3d_cs_emit_set_vertex_declaration(device->cs, state->vertex_declaration);
+
+ for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i)
+ {
+ wined3d_cs_emit_set_stream_output(device->cs, i,
+ state->stream_output[i].buffer, state->stream_output[i].offset);
+ }
+
+ for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
+ {
+ wined3d_cs_emit_set_stream_source(device->cs, i, state->streams[i].buffer,
+ state->streams[i].offset, state->streams[i].stride);
+ }
+
+ wined3d_cs_emit_set_index_buffer(device->cs, state->index_buffer, state->index_format, state->index_offset);
+
+ wined3d_cs_emit_set_predication(device->cs, state->predicate, state->predicate_value);
+
+ for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
+ {
+ wined3d_cs_emit_set_shader(device->cs, i, state->shader[i]);
+ for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j)
+ {
+ wined3d_cs_emit_set_constant_buffer(device->cs, i, j, state->cb[i][j]);
+ }
+ for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j)
+ {
+ wined3d_cs_emit_set_sampler(device->cs, i, j, state->sampler[i][j]);
+ }
+ for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j)
+ {
+ wined3d_cs_emit_set_shader_resource_view(device->cs, i, j, state->shader_resource_view[i][j]);
+ }
+ }
+
+ for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
+ {
+ for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j)
+ {
+ wined3d_cs_emit_set_unordered_access_view(device->cs, i, j, state->unordered_access_view[i][j], ~0);
+ }
+ }
+
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_F,
+ 0, WINED3D_MAX_VS_CONSTS_F, state->vs_consts_f);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_I,
+ 0, WINED3D_MAX_CONSTS_I, state->vs_consts_i);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_B,
+ 0, WINED3D_MAX_CONSTS_B, state->vs_consts_b);
+
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_F,
+ 0, WINED3D_MAX_PS_CONSTS_F, state->ps_consts_f);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_I,
+ 0, WINED3D_MAX_CONSTS_I, state->ps_consts_i);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_B,
+ 0, WINED3D_MAX_CONSTS_B, state->ps_consts_b);
+
+ for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
+ {
+ wined3d_cs_emit_set_texture(device->cs, i, state->textures[i]);
+ for (j = 0; j < WINED3D_HIGHEST_SAMPLER_STATE + 1; ++j)
+ {
+ wined3d_cs_emit_set_sampler_state(device->cs, i, j, state->sampler_states[i][j]);
+ }
+ }
+
+ for (i = 0; i < WINED3D_MAX_TEXTURES; ++i)
+ {
+ for (j = 0; j < WINED3D_HIGHEST_TEXTURE_STATE + 1; ++j)
+ {
+ wined3d_cs_emit_set_texture_state(device->cs, i, j, state->texture_states[i][j]);
+ }
+ }
+
+ for (i = 0; i < WINED3D_HIGHEST_TRANSFORM_STATE + 1; ++i)
+ {
+ wined3d_cs_emit_set_transform(device->cs, i, state->transforms + i);
+ }
+
+ for (i = 0; i < WINED3D_MAX_CLIP_DISTANCES; ++i)
+ {
+ wined3d_cs_emit_set_clip_plane(device->cs, i, state->clip_planes + i);
+ }
+
+ wined3d_cs_emit_set_material(device->cs, &state->material);
+
+ wined3d_cs_emit_set_viewports(device->cs, state->viewport_count, state->viewports);
+ wined3d_cs_emit_set_scissor_rects(device->cs, state->scissor_rect_count, state->scissor_rects);
+
+ for (i = 0; i < LIGHTMAP_SIZE; ++i)
+ {
+ LIST_FOR_EACH_ENTRY(light, &state->light_state.light_map[i], struct wined3d_light_info, entry)
+ {
+ wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
+ wined3d_cs_emit_set_light_enable(device->cs, light->OriginalIndex, light->glIndex != -1);
+ }
+ }
+
+ for (i = 0; i < WINEHIGHEST_RENDER_STATE + 1; ++i)
+ {
+ wined3d_cs_emit_set_render_state(device->cs, i, state->render_states[i]);
+ }
+
+ wined3d_cs_emit_set_blend_state(device->cs, state->blend_state, &state->blend_factor, state->sample_mask);
+ wined3d_cs_emit_set_depth_stencil_state(device->cs, state->depth_stencil_state, state->stencil_ref);
+ wined3d_cs_emit_set_rasterizer_state(device->cs, state->rasterizer_state);
+}
+
+struct wined3d_state * CDECL wined3d_device_get_state(struct wined3d_device *device)
+{
+ TRACE("device %p.\n", device);
+
+ return device->state;
+}
+
void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
struct wined3d_vertex_declaration *declaration)
{
@@ -5952,12 +6082,11 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
return hr;
}
- if (!(state = heap_alloc_zero(sizeof(*state))))
+ if (FAILED(hr = wined3d_state_create(device, &state)))
{
- hr = E_OUTOFMEMORY;
+ ERR("Failed to create device state, hr %#x.\n", hr);
goto err;
}
- state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->state = state;
device->max_frame_latency = 3;
@@ -5974,7 +6103,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
err:
if (state)
- heap_free(state);
+ wined3d_state_destroy(state);
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
heap_free(device->multistate_funcs[i]);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 52124583c90c..97020e1cd407 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1885,6 +1885,28 @@ void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_
state_init_default(state, d3d_info);
}
+HRESULT CDECL wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state)
+{
+ struct wined3d_state *object;
+
+ TRACE("device %p, state %p.\n", device, state);
+
+ if (!(object = heap_alloc_zero(sizeof(*object))))
+ return E_OUTOFMEMORY;
+ state_init(object, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+
+ *state = object;
+ return S_OK;
+}
+
+void CDECL wined3d_state_destroy(struct wined3d_state *state)
+{
+ TRACE("state %p.\n", state);
+
+ state_cleanup(state);
+ heap_free(state);
+}
+
static void stateblock_state_init_default(struct wined3d_stateblock_state *state,
const struct wined3d_d3d_info *d3d_info)
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 44008119a8dd..6b6480cec8f0 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -98,6 +98,7 @@
@ cdecl wined3d_device_get_rendertarget_view(ptr long)
@ cdecl wined3d_device_get_scissor_rects(ptr ptr ptr)
@ cdecl wined3d_device_get_software_vertex_processing(ptr)
+@ cdecl wined3d_device_get_state(ptr)
@ cdecl wined3d_device_get_stream_output(ptr long ptr)
@ cdecl wined3d_device_get_stream_source(ptr long ptr ptr ptr)
@ cdecl wined3d_device_get_swapchain(ptr long)
@@ -151,6 +152,7 @@
@ cdecl wined3d_device_set_rendertarget_view(ptr long ptr long)
@ cdecl wined3d_device_set_scissor_rects(ptr long ptr)
@ cdecl wined3d_device_set_software_vertex_processing(ptr long)
+@ cdecl wined3d_device_set_state(ptr ptr)
@ cdecl wined3d_device_set_stream_output(ptr long ptr long)
@ cdecl wined3d_device_set_stream_source(ptr long ptr long long)
@ cdecl wined3d_device_set_unordered_access_view(ptr long ptr long)
@@ -237,6 +239,9 @@
@ cdecl wined3d_shader_resource_view_get_parent(ptr)
@ cdecl wined3d_shader_resource_view_incref(ptr)
+@ cdecl wined3d_state_create(ptr ptr)
+@ cdecl wined3d_state_destroy(ptr)
+
@ cdecl wined3d_stateblock_apply(ptr ptr)
@ cdecl wined3d_stateblock_capture(ptr ptr)
@ cdecl wined3d_stateblock_create(ptr ptr long ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 96cb6fc1d863..0d67e8c89d17 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2223,6 +2223,7 @@ struct wined3d_resource;
struct wined3d_sampler;
struct wined3d_shader;
struct wined3d_shader_resource_view;
+struct wined3d_state;
struct wined3d_stateblock;
struct wined3d_swapchain;
struct wined3d_swapchain_state;
@@ -2432,6 +2433,7 @@ struct wined3d_rendertarget_view * __cdecl wined3d_device_get_rendertarget_view(
void __cdecl wined3d_device_get_scissor_rects(const struct wined3d_device *device, unsigned int *rect_count,
RECT *rect);
BOOL __cdecl wined3d_device_get_software_vertex_processing(const struct wined3d_device *device);
+struct wined3d_state * __cdecl wined3d_device_get_state(struct wined3d_device *device);
struct wined3d_buffer * __cdecl wined3d_device_get_stream_output(struct wined3d_device *device,
UINT idx, UINT *offset);
HRESULT __cdecl wined3d_device_get_stream_source(const struct wined3d_device *device,
@@ -2522,6 +2524,7 @@ HRESULT __cdecl wined3d_device_set_rendertarget_view(struct wined3d_device *devi
void __cdecl wined3d_device_set_scissor_rects(struct wined3d_device *device,
unsigned int rect_count, const RECT *rect);
void __cdecl wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software);
+void __cdecl wined3d_device_set_state(struct wined3d_device *device, struct wined3d_state *state);
void __cdecl wined3d_device_set_stream_output(struct wined3d_device *device, UINT idx,
struct wined3d_buffer *buffer, UINT offset);
HRESULT __cdecl wined3d_device_set_stream_source(struct wined3d_device *device,
@@ -2730,6 +2733,9 @@ void __cdecl wined3d_shader_resource_view_generate_mipmaps(struct wined3d_shader
void * __cdecl wined3d_shader_resource_view_get_parent(const struct wined3d_shader_resource_view *view);
ULONG __cdecl wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view);
+HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state);
+void __cdecl wined3d_state_destroy(struct wined3d_state *state);
+
void __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
struct wined3d_stateblock *device_state);
void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
--
2.20.1
1
0
[PATCH 2/5] wined3d: Unbind framebuffer state in state_unbind_resources().
by Henri Verbeet 23 Feb '21
by Henri Verbeet 23 Feb '21
23 Feb '21
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/device.c | 13 -------------
dlls/wined3d/stateblock.c | 16 ++++++++++++++++
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 792263ca7d8b..c9df09b53483 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1196,7 +1196,6 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
struct wined3d_resource *resource, *cursor;
struct wined3d_rendertarget_view *view;
struct wined3d_texture *texture;
- unsigned int i;
TRACE("device %p.\n", device);
@@ -1224,10 +1223,6 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
wined3d_cs_emit_reset_state(device->cs);
state_cleanup(state);
- for (i = 0; i < device->adapter->d3d_info.limits.max_rt_count; ++i)
- {
- wined3d_device_set_rendertarget_view(device, i, NULL, FALSE);
- }
wine_rb_clear(&device->samplers, device_free_sampler, NULL);
wine_rb_clear(&device->rasterizer_states, device_free_rasterizer_state, NULL);
@@ -1243,14 +1238,6 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
device->adapter->adapter_ops->adapter_uninit_3d(device);
device->d3d_initialized = FALSE;
- if ((view = state->fb.depth_stencil))
- {
- TRACE("Releasing depth/stencil view %p.\n", view);
-
- state->fb.depth_stencil = NULL;
- wined3d_rendertarget_view_decref(view);
- }
-
if ((view = device->auto_depth_stencil_view))
{
device->auto_depth_stencil_view = NULL;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 46588fa4246c..52124583c90c 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -374,6 +374,7 @@ void state_unbind_resources(struct wined3d_state *state)
struct wined3d_shader_resource_view *srv;
struct wined3d_vertex_declaration *decl;
struct wined3d_blend_state *blend_state;
+ struct wined3d_rendertarget_view *rtv;
struct wined3d_sampler *sampler;
struct wined3d_texture *texture;
struct wined3d_buffer *buffer;
@@ -473,6 +474,21 @@ void state_unbind_resources(struct wined3d_state *state)
state->blend_state = NULL;
wined3d_blend_state_decref(blend_state);
}
+
+ for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
+ {
+ if ((rtv = state->fb.render_targets[i]))
+ {
+ state->fb.render_targets[i] = NULL;
+ wined3d_rendertarget_view_decref(rtv);
+ }
+ }
+
+ if ((rtv = state->fb.depth_stencil))
+ {
+ state->fb.depth_stencil = NULL;
+ wined3d_rendertarget_view_decref(rtv);
+ }
}
void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
--
2.20.1
1
0
23 Feb '21
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
This supersedes patches 200185 and 200184.
dlls/wined3d/cs.c | 10 +-
dlls/wined3d/device.c | 417 +++++++++++++++++++--------------
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/wined3d_private.h | 2 +-
4 files changed, 251 insertions(+), 180 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 0385b8f46937..4ee3d97b7fc4 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -677,7 +677,7 @@ static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data)
void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
{
- const struct wined3d_state *state = &cs->device->state;
+ const struct wined3d_state *state = cs->device->state;
const struct wined3d_viewport *vp = &state->viewports[0];
struct wined3d_rendertarget_view *view;
struct wined3d_cs_clear *op;
@@ -886,7 +886,7 @@ static void acquire_compute_pipeline_resources(const struct wined3d_state *state
void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z)
{
- const struct wined3d_state *state = &cs->device->state;
+ const struct wined3d_state *state = cs->device->state;
struct wined3d_cs_dispatch *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
@@ -904,7 +904,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs,
struct wined3d_buffer *buffer, unsigned int offset)
{
- const struct wined3d_state *state = &cs->device->state;
+ const struct wined3d_state *state = cs->device->state;
struct wined3d_cs_dispatch *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
@@ -1045,7 +1045,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, enum wined3d_primitive_type pri
unsigned int index_count, unsigned int start_instance, unsigned int instance_count, bool indexed)
{
const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info;
- const struct wined3d_state *state = &cs->device->state;
+ const struct wined3d_state *state = cs->device->state;
struct wined3d_cs_draw *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
@@ -1069,7 +1069,7 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, enum wined3d_primitive
unsigned int patch_vertex_count, struct wined3d_buffer *buffer, unsigned int offset, bool indexed)
{
const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info;
- const struct wined3d_state *state = &cs->device->state;
+ const struct wined3d_state *state = cs->device->state;
struct wined3d_cs_draw *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1fd5f4b012e5..792263ca7d8b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -251,6 +251,8 @@ void wined3d_device_cleanup(struct wined3d_device *device)
wine_rb_destroy(&device->depth_stencil_states, device_leftover_depth_stencil_state, NULL);
wine_rb_destroy(&device->so_descs, device_free_so_desc, NULL);
+ heap_free(device->state);
+ device->state = NULL;
wined3d_decref(device->wined3d);
device->wined3d = NULL;
}
@@ -1083,6 +1085,7 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str
{
static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f};
const struct wined3d_swapchain_desc *swapchain_desc;
+ struct wined3d_fb_state *fb = &device->state->fb;
DWORD clear_flags = 0;
unsigned int i;
HRESULT hr;
@@ -1101,11 +1104,13 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str
}
device->swapchains[0] = swapchain;
- for (i = 0; i < ARRAY_SIZE(device->state.fb.render_targets); ++i)
- if (device->state.fb.render_targets[i])
- wined3d_rtv_bind_count_dec(device->state.fb.render_targets[i]);
+ for (i = 0; i < ARRAY_SIZE(fb->render_targets); ++i)
+ {
+ if (fb->render_targets[i])
+ wined3d_rtv_bind_count_dec(fb->render_targets[i]);
+ }
+ memset(fb->render_targets, 0, sizeof(fb->render_targets));
- memset(device->state.fb.render_targets, 0, sizeof(device->state.fb.render_targets));
if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device)))
goto err_out;
device->d3d_initialized = TRUE;
@@ -1187,6 +1192,7 @@ static void device_free_depth_stencil_state(struct wine_rb_entry *entry, void *c
void wined3d_device_uninit_3d(struct wined3d_device *device)
{
+ struct wined3d_state *state = device->state;
struct wined3d_resource *resource, *cursor;
struct wined3d_rendertarget_view *view;
struct wined3d_texture *texture;
@@ -1217,7 +1223,7 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
}
wined3d_cs_emit_reset_state(device->cs);
- state_cleanup(&device->state);
+ state_cleanup(state);
for (i = 0; i < device->adapter->d3d_info.limits.max_rt_count; ++i)
{
wined3d_device_set_rendertarget_view(device, i, NULL, FALSE);
@@ -1237,11 +1243,11 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
device->adapter->adapter_ops->adapter_uninit_3d(device);
device->d3d_initialized = FALSE;
- if ((view = device->state.fb.depth_stencil))
+ if ((view = state->fb.depth_stencil))
{
TRACE("Releasing depth/stencil view %p.\n", view);
- device->state.fb.depth_stencil = NULL;
+ state->fb.depth_stencil = NULL;
wined3d_rendertarget_view_decref(view);
}
@@ -1261,8 +1267,8 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
heap_free(device->swapchains);
device->swapchains = NULL;
- memset(&device->state, 0, sizeof(device->state));
- state_init(&device->state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+ memset(state, 0, sizeof(*state));
+ state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
}
/* Enables thread safety in the wined3d device and its resources. Called by DirectDraw
@@ -1309,7 +1315,7 @@ void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT
return;
}
- stream = &device->state.stream_output[idx];
+ stream = &device->state->stream_output[idx];
prev_buffer = stream->buffer;
if (buffer)
@@ -1333,8 +1339,8 @@ struct wined3d_buffer * CDECL wined3d_device_get_stream_output(struct wined3d_de
}
if (offset)
- *offset = device->state.stream_output[idx].offset;
- return device->state.stream_output[idx].buffer;
+ *offset = device->state->stream_output[idx].offset;
+ return device->state->stream_output[idx].buffer;
}
HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UINT stream_idx,
@@ -1357,7 +1363,7 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI
return WINED3DERR_INVALIDCALL;
}
- stream = &device->state.streams[stream_idx];
+ stream = &device->state->streams[stream_idx];
prev_buffer = stream->buffer;
if (prev_buffer == buffer
@@ -1394,7 +1400,7 @@ HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *devi
return WINED3DERR_INVALIDCALL;
}
- stream = &device->state.streams[stream_idx];
+ stream = &device->state->streams[stream_idx];
*buffer = stream->buffer;
if (offset)
*offset = stream->offset;
@@ -1410,7 +1416,7 @@ static void wined3d_device_set_stream_source_freq(struct wined3d_device *device,
TRACE("device %p, stream_idx %u, divider %#x.\n", device, stream_idx, divider);
- stream = &device->state.streams[stream_idx];
+ stream = &device->state->streams[stream_idx];
old_flags = stream->flags;
old_freq = stream->frequency;
@@ -1421,10 +1427,10 @@ static void wined3d_device_set_stream_source_freq(struct wined3d_device *device,
}
static void wined3d_device_set_transform(struct wined3d_device *device,
- enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
+ enum wined3d_transform_state state, const struct wined3d_matrix *matrix)
{
TRACE("device %p, state %s, matrix %p.\n",
- device, debug_d3dtstype(d3dts), matrix);
+ device, debug_d3dtstype(state), matrix);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_11, matrix->_12, matrix->_13, matrix->_14);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_21, matrix->_22, matrix->_23, matrix->_24);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_31, matrix->_32, matrix->_33, matrix->_34);
@@ -1436,14 +1442,14 @@ static void wined3d_device_set_transform(struct wined3d_device *device,
* tend towards setting the same matrix repeatedly for some reason.
*
* From here on we assume that the new matrix is different, wherever it matters. */
- if (!memcmp(&device->state.transforms[d3dts], matrix, sizeof(*matrix)))
+ if (!memcmp(&device->state->transforms[state], matrix, sizeof(*matrix)))
{
TRACE("The application is setting the same matrix over again.\n");
return;
}
- device->state.transforms[d3dts] = *matrix;
- wined3d_cs_emit_set_transform(device->cs, d3dts, matrix);
+ device->state->transforms[state] = *matrix;
+ wined3d_cs_emit_set_transform(device->cs, state, matrix);
}
static void wined3d_device_get_transform(const struct wined3d_device *device,
@@ -1451,7 +1457,7 @@ static void wined3d_device_get_transform(const struct wined3d_device *device,
{
TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix);
- *matrix = device->state.transforms[state];
+ *matrix = device->state->transforms[state];
}
/* Note lights are real special cases. Although the device caps state only
@@ -1469,7 +1475,7 @@ static void wined3d_device_set_light(struct wined3d_device *device,
TRACE("device %p, light_idx %u, light %p.\n", device, light_idx, light);
- if (FAILED(wined3d_light_state_set_light(&device->state.light_state, light_idx, light, &object)))
+ if (FAILED(wined3d_light_state_set_light(&device->state->light_state, light_idx, light, &object)))
return;
/* Initialize the object. */
@@ -1563,30 +1569,33 @@ static void wined3d_device_set_light(struct wined3d_device *device,
static void wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable)
{
+ struct wined3d_light_state *light_state = &device->state->light_state;
struct wined3d_light_info *light_info;
TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable);
/* Special case - enabling an undefined light creates one with a strict set of parameters. */
- if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx)))
+ if (!(light_info = wined3d_light_state_get_light(light_state, light_idx)))
{
TRACE("Light enabled requested but light not defined, so defining one!\n");
wined3d_device_set_light(device, light_idx, &WINED3D_default_light);
- if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx)))
+ if (!(light_info = wined3d_light_state_get_light(light_state, light_idx)))
{
FIXME("Adding default lights has failed dismally\n");
return;
}
}
- wined3d_light_state_enable_light(&device->state.light_state, &device->adapter->d3d_info, light_info, enable);
+ wined3d_light_state_enable_light(light_state, &device->adapter->d3d_info, light_info, enable);
wined3d_cs_emit_set_light_enable(device->cs, light_idx, enable);
}
static HRESULT wined3d_device_set_clip_plane(struct wined3d_device *device,
UINT plane_idx, const struct wined3d_vec4 *plane)
{
+ struct wined3d_vec4 *clip_planes = device->state->clip_planes;
+
TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
if (plane_idx >= device->adapter->d3d_info.limits.max_clip_distances)
@@ -1595,13 +1604,13 @@ static HRESULT wined3d_device_set_clip_plane(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL;
}
- if (!memcmp(&device->state.clip_planes[plane_idx], plane, sizeof(*plane)))
+ if (!memcmp(&clip_planes[plane_idx], plane, sizeof(*plane)))
{
TRACE("Application is setting old values over, nothing to do.\n");
return WINED3D_OK;
}
- device->state.clip_planes[plane_idx] = *plane;
+ clip_planes[plane_idx] = *plane;
wined3d_cs_emit_set_clip_plane(device->cs, plane_idx, plane);
@@ -1634,13 +1643,14 @@ static void wined3d_device_set_material(struct wined3d_device *device, const str
{
TRACE("device %p, material %p.\n", device, material);
- device->state.material = *material;
+ device->state->material = *material;
wined3d_cs_emit_set_material(device->cs, material);
}
void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device,
struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
{
+ struct wined3d_state *state = device->state;
enum wined3d_format_id prev_format;
struct wined3d_buffer *prev_buffer;
unsigned int prev_offset;
@@ -1648,18 +1658,18 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device,
TRACE("device %p, buffer %p, format %s, offset %u.\n",
device, buffer, debug_d3dformat(format_id), offset);
- prev_buffer = device->state.index_buffer;
- prev_format = device->state.index_format;
- prev_offset = device->state.index_offset;
+ prev_buffer = state->index_buffer;
+ prev_format = state->index_format;
+ prev_offset = state->index_offset;
if (prev_buffer == buffer && prev_format == format_id && prev_offset == offset)
return;
if (buffer)
wined3d_buffer_incref(buffer);
- device->state.index_buffer = buffer;
- device->state.index_format = format_id;
- device->state.index_offset = offset;
+ state->index_buffer = buffer;
+ state->index_format = format_id;
+ state->index_offset = offset;
wined3d_cs_emit_set_index_buffer(device->cs, buffer, format_id, offset);
if (prev_buffer)
wined3d_buffer_decref(prev_buffer);
@@ -1668,24 +1678,27 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device,
struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device,
enum wined3d_format_id *format, unsigned int *offset)
{
+ const struct wined3d_state *state = device->state;
+
TRACE("device %p, format %p, offset %p.\n", device, format, offset);
- *format = device->state.index_format;
+ *format = state->index_format;
if (offset)
- *offset = device->state.index_offset;
- return device->state.index_buffer;
+ *offset = state->index_offset;
+ return state->index_buffer;
}
void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index)
{
TRACE("device %p, base_index %d.\n", device, base_index);
- device->state.base_vertex_index = base_index;
+ device->state->base_vertex_index = base_index;
}
void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned int viewport_count,
const struct wined3d_viewport *viewports)
{
+ struct wined3d_state *state = device->state;
unsigned int i;
TRACE("device %p, viewport_count %u, viewports %p.\n", device, viewport_count, viewports);
@@ -1697,10 +1710,10 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned
}
if (viewport_count)
- memcpy(device->state.viewports, viewports, viewport_count * sizeof(*viewports));
+ memcpy(state->viewports, viewports, viewport_count * sizeof(*viewports));
else
- memset(device->state.viewports, 0, sizeof(device->state.viewports));
- device->state.viewport_count = viewport_count;
+ memset(state->viewports, 0, sizeof(state->viewports));
+ state->viewport_count = viewport_count;
wined3d_cs_emit_set_viewports(device->cs, viewport_count, viewports);
}
@@ -1708,20 +1721,21 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned
void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, unsigned int *viewport_count,
struct wined3d_viewport *viewports)
{
+ const struct wined3d_state *state = device->state;
unsigned int count;
TRACE("device %p, viewport_count %p, viewports %p.\n", device, viewport_count, viewports);
- count = viewport_count ? min(*viewport_count, device->state.viewport_count) : 1;
+ count = viewport_count ? min(*viewport_count, state->viewport_count) : 1;
if (count && viewports)
- memcpy(viewports, device->state.viewports, count * sizeof(*viewports));
+ memcpy(viewports, state->viewports, count * sizeof(*viewports));
if (viewport_count)
- *viewport_count = device->state.viewport_count;
+ *viewport_count = state->viewport_count;
}
static void resolve_depth_buffer(struct wined3d_device *device)
{
- const struct wined3d_state *state = &device->state;
+ const struct wined3d_state *state = device->state;
struct wined3d_rendertarget_view *src_view;
struct wined3d_resource *dst_resource;
struct wined3d_texture *dst_texture;
@@ -1741,7 +1755,7 @@ static void resolve_depth_buffer(struct wined3d_device *device)
void CDECL wined3d_device_set_blend_state(struct wined3d_device *device,
struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor, unsigned int sample_mask)
{
- struct wined3d_state *state = &device->state;
+ struct wined3d_state *state = device->state;
struct wined3d_blend_state *prev;
TRACE("device %p, blend_state %p, blend_factor %s, sample_mask %#x.\n",
@@ -1765,7 +1779,7 @@ void CDECL wined3d_device_set_blend_state(struct wined3d_device *device,
struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct wined3d_device *device,
struct wined3d_color *blend_factor, unsigned int *sample_mask)
{
- const struct wined3d_state *state = &device->state;
+ const struct wined3d_state *state = device->state;
TRACE("device %p, blend_factor %p, sample_mask %p.\n", device, blend_factor, sample_mask);
@@ -1775,47 +1789,52 @@ struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct w
}
void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device,
- struct wined3d_depth_stencil_state *state, unsigned int stencil_ref)
+ struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref)
{
+ struct wined3d_state *state = device->state;
struct wined3d_depth_stencil_state *prev;
- TRACE("device %p, state %p, stencil_ref %u.\n", device, state, stencil_ref);
+ TRACE("device %p, depth_stencil_state %p, stencil_ref %u.\n", device, depth_stencil_state, stencil_ref);
- prev = device->state.depth_stencil_state;
- if (prev == state && device->state.stencil_ref == stencil_ref)
+ prev = state->depth_stencil_state;
+ if (prev == depth_stencil_state && state->stencil_ref == stencil_ref)
return;
- if (state)
- wined3d_depth_stencil_state_incref(state);
- device->state.depth_stencil_state = state;
- device->state.stencil_ref = stencil_ref;
- wined3d_cs_emit_set_depth_stencil_state(device->cs, state, stencil_ref);
+ if (depth_stencil_state)
+ wined3d_depth_stencil_state_incref(depth_stencil_state);
+ state->depth_stencil_state = depth_stencil_state;
+ state->stencil_ref = stencil_ref;
+ wined3d_cs_emit_set_depth_stencil_state(device->cs, depth_stencil_state, stencil_ref);
if (prev)
wined3d_depth_stencil_state_decref(prev);
}
-struct wined3d_depth_stencil_state * CDECL wined3d_device_get_depth_stencil_state(const struct wined3d_device *device, unsigned int *stencil_ref)
+struct wined3d_depth_stencil_state * CDECL wined3d_device_get_depth_stencil_state(const struct wined3d_device *device,
+ unsigned int *stencil_ref)
{
+ const struct wined3d_state *state = device->state;
+
TRACE("device %p, stencil_ref %p.\n", device, stencil_ref);
- *stencil_ref = device->state.stencil_ref;
- return device->state.depth_stencil_state;
+ *stencil_ref = state->stencil_ref;
+ return state->depth_stencil_state;
}
void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device,
struct wined3d_rasterizer_state *rasterizer_state)
{
+ struct wined3d_state *state = device->state;
struct wined3d_rasterizer_state *prev;
TRACE("device %p, rasterizer_state %p.\n", device, rasterizer_state);
- prev = device->state.rasterizer_state;
+ prev = state->rasterizer_state;
if (prev == rasterizer_state)
return;
if (rasterizer_state)
wined3d_rasterizer_state_incref(rasterizer_state);
- device->state.rasterizer_state = rasterizer_state;
+ state->rasterizer_state = rasterizer_state;
wined3d_cs_emit_set_rasterizer_state(device->cs, rasterizer_state);
if (prev)
wined3d_rasterizer_state_decref(prev);
@@ -1825,7 +1844,7 @@ struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(stru
{
TRACE("device %p.\n", device);
- return device->state.rasterizer_state;
+ return device->state->rasterizer_state;
}
void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
@@ -1839,11 +1858,11 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
return;
}
- if (value == device->state.render_states[state])
+ if (value == device->state->render_states[state])
TRACE("Application is setting the old value over, nothing to do.\n");
else
{
- device->state.render_states[state] = value;
+ device->state->render_states[state] = value;
wined3d_cs_emit_set_render_state(device->cs, state, value);
}
@@ -1858,7 +1877,7 @@ DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device,
{
TRACE("device %p, state %s (%#x).\n", device, debug_d3drenderstate(state), state);
- return device->state.render_states[state];
+ return device->state->render_states[state];
}
static void wined3d_device_set_sampler_state(struct wined3d_device *device,
@@ -1867,19 +1886,20 @@ static void wined3d_device_set_sampler_state(struct wined3d_device *device,
TRACE("device %p, sampler_idx %u, state %s, value %#x.\n",
device, sampler_idx, debug_d3dsamplerstate(state), value);
- if (value == device->state.sampler_states[sampler_idx][state])
+ if (value == device->state->sampler_states[sampler_idx][state])
{
TRACE("Application is setting the old value over, nothing to do.\n");
return;
}
- device->state.sampler_states[sampler_idx][state] = value;
+ device->state->sampler_states[sampler_idx][state] = value;
wined3d_cs_emit_set_sampler_state(device->cs, sampler_idx, state, value);
}
void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsigned int rect_count,
const RECT *rects)
{
+ struct wined3d_state *state = device->state;
unsigned int i;
TRACE("device %p, rect_count %u, rects %p.\n", device, rect_count, rects);
@@ -1889,48 +1909,51 @@ void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsig
TRACE("%u: %s\n", i, wine_dbgstr_rect(&rects[i]));
}
- if (device->state.scissor_rect_count == rect_count
- && !memcmp(device->state.scissor_rects, rects, rect_count * sizeof(*rects)))
+ if (state->scissor_rect_count == rect_count
+ && !memcmp(state->scissor_rects, rects, rect_count * sizeof(*rects)))
{
TRACE("App is setting the old scissor rectangles over, nothing to do.\n");
return;
}
if (rect_count)
- memcpy(device->state.scissor_rects, rects, rect_count * sizeof(*rects));
+ memcpy(state->scissor_rects, rects, rect_count * sizeof(*rects));
else
- memset(device->state.scissor_rects, 0, sizeof(device->state.scissor_rects));
- device->state.scissor_rect_count = rect_count;
+ memset(state->scissor_rects, 0, sizeof(state->scissor_rects));
+ state->scissor_rect_count = rect_count;
wined3d_cs_emit_set_scissor_rects(device->cs, rect_count, rects);
}
void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, unsigned int *rect_count, RECT *rects)
{
+ const struct wined3d_state *state = device->state;
unsigned int count;
TRACE("device %p, rect_count %p, rects %p.\n", device, rect_count, rects);
- count = rect_count ? min(*rect_count, device->state.scissor_rect_count) : 1;
+ count = rect_count ? min(*rect_count, state->scissor_rect_count) : 1;
if (count && rects)
- memcpy(rects, device->state.scissor_rects, count * sizeof(*rects));
+ memcpy(rects, state->scissor_rects, count * sizeof(*rects));
if (rect_count)
- *rect_count = device->state.scissor_rect_count;
+ *rect_count = state->scissor_rect_count;
}
void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
struct wined3d_vertex_declaration *declaration)
{
- struct wined3d_vertex_declaration *prev = device->state.vertex_declaration;
+ struct wined3d_state *state = device->state;
+ struct wined3d_vertex_declaration *prev;
TRACE("device %p, declaration %p.\n", device, declaration);
+ prev = state->vertex_declaration;
if (declaration == prev)
return;
if (declaration)
wined3d_vertex_declaration_incref(declaration);
- device->state.vertex_declaration = declaration;
+ state->vertex_declaration = declaration;
wined3d_cs_emit_set_vertex_declaration(device->cs, declaration);
if (prev)
wined3d_vertex_declaration_decref(prev);
@@ -1940,21 +1963,23 @@ struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(
{
TRACE("device %p.\n", device);
- return device->state.vertex_declaration;
+ return device->state->vertex_declaration;
}
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
- struct wined3d_shader *prev = device->state.shader[WINED3D_SHADER_TYPE_VERTEX];
+ struct wined3d_state *state = device->state;
+ struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
+ prev = state->shader[WINED3D_SHADER_TYPE_VERTEX];
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
- device->state.shader[WINED3D_SHADER_TYPE_VERTEX] = shader;
+ state->shader[WINED3D_SHADER_TYPE_VERTEX] = shader;
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_VERTEX, shader);
if (prev)
wined3d_shader_decref(prev);
@@ -1964,12 +1989,13 @@ struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wine
{
TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_VERTEX];
+ return device->state->shader[WINED3D_SHADER_TYPE_VERTEX];
}
void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device,
enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer)
{
+ struct wined3d_state *state = device->state;
struct wined3d_buffer *prev;
TRACE("device %p, type %#x, idx %u, buffer %p.\n", device, type, idx, buffer);
@@ -1980,13 +2006,13 @@ void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device,
return;
}
- prev = device->state.cb[type][idx];
+ prev = state->cb[type][idx];
if (buffer == prev)
return;
if (buffer)
wined3d_buffer_incref(buffer);
- device->state.cb[type][idx] = buffer;
+ state->cb[type][idx] = buffer;
wined3d_cs_emit_set_constant_buffer(device->cs, type, idx, buffer);
if (prev)
wined3d_buffer_decref(prev);
@@ -2003,13 +2029,14 @@ struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wi
return NULL;
}
- return device->state.cb[shader_type][idx];
+ return device->state->cb[shader_type][idx];
}
static void wined3d_device_set_shader_resource_view(struct wined3d_device *device,
enum wined3d_shader_type type, UINT idx, struct wined3d_shader_resource_view *view)
{
const struct wined3d_rendertarget_view *dsv;
+ struct wined3d_state *state = device->state;
struct wined3d_shader_resource_view *prev;
if (idx >= MAX_SHADER_RESOURCE_VIEWS)
@@ -2018,12 +2045,12 @@ static void wined3d_device_set_shader_resource_view(struct wined3d_device *devic
return;
}
- prev = device->state.shader_resource_view[type][idx];
+ prev = state->shader_resource_view[type][idx];
if (view == prev)
return;
if (view && (wined3d_is_srv_rtv_bound(view)
- || ((dsv = device->state.fb.depth_stencil)
+ || ((dsv = state->fb.depth_stencil)
&& dsv->resource == view->resource && wined3d_dsv_srv_conflict(dsv, view->format))))
{
WARN("Application is trying to bind resource which is attached as render target.\n");
@@ -2036,7 +2063,7 @@ static void wined3d_device_set_shader_resource_view(struct wined3d_device *devic
wined3d_srv_bind_count_inc(view);
}
- device->state.shader_resource_view[type][idx] = view;
+ state->shader_resource_view[type][idx] = view;
wined3d_cs_emit_set_shader_resource_view(device->cs, type, idx, view);
if (prev)
{
@@ -2062,7 +2089,7 @@ static struct wined3d_shader_resource_view *wined3d_device_get_shader_resource_v
return NULL;
}
- return device->state.shader_resource_view[shader_type][idx];
+ return device->state->shader_resource_view[shader_type][idx];
}
struct wined3d_shader_resource_view * CDECL wined3d_device_get_vs_resource_view(const struct wined3d_device *device,
@@ -2076,6 +2103,7 @@ struct wined3d_shader_resource_view * CDECL wined3d_device_get_vs_resource_view(
static void wined3d_device_set_sampler(struct wined3d_device *device,
enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler)
{
+ struct wined3d_state *state = device->state;
struct wined3d_sampler *prev;
if (idx >= MAX_SAMPLER_OBJECTS)
@@ -2084,13 +2112,13 @@ static void wined3d_device_set_sampler(struct wined3d_device *device,
return;
}
- prev = device->state.sampler[type][idx];
+ prev = state->sampler[type][idx];
if (sampler == prev)
return;
if (sampler)
wined3d_sampler_incref(sampler);
- device->state.sampler[type][idx] = sampler;
+ state->sampler[type][idx] = sampler;
wined3d_cs_emit_set_sampler(device->cs, type, idx, sampler);
if (prev)
wined3d_sampler_decref(prev);
@@ -2112,7 +2140,7 @@ static struct wined3d_sampler *wined3d_device_get_sampler(const struct wined3d_d
return NULL;
}
- return device->state.sampler[shader_type][idx];
+ return device->state->sampler[shader_type][idx];
}
struct wined3d_sampler * CDECL wined3d_device_get_vs_sampler(const struct wined3d_device *device, UINT idx)
@@ -2130,7 +2158,7 @@ static void wined3d_device_set_vs_consts_b(struct wined3d_device *device,
TRACE("device %p, start_idx %u, count %u, constants %p.\n",
device, start_idx, count, constants);
- memcpy(&device->state.vs_consts_b[start_idx], constants, count * sizeof(*constants));
+ memcpy(&device->state->vs_consts_b[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d))
{
for (i = 0; i < count; ++i)
@@ -2148,7 +2176,7 @@ static void wined3d_device_set_vs_consts_i(struct wined3d_device *device,
TRACE("device %p, start_idx %u, count %u, constants %p.\n",
device, start_idx, count, constants);
- memcpy(&device->state.vs_consts_i[start_idx], constants, count * sizeof(*constants));
+ memcpy(&device->state->vs_consts_i[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d))
{
for (i = 0; i < count; ++i)
@@ -2166,7 +2194,7 @@ static void wined3d_device_set_vs_consts_f(struct wined3d_device *device,
TRACE("device %p, start_idx %u, count %u, constants %p.\n",
device, start_idx, count, constants);
- memcpy(&device->state.vs_consts_f[start_idx], constants, count * sizeof(*constants));
+ memcpy(&device->state->vs_consts_f[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d))
{
for (i = 0; i < count; ++i)
@@ -2178,16 +2206,18 @@ static void wined3d_device_set_vs_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
- struct wined3d_shader *prev = device->state.shader[WINED3D_SHADER_TYPE_PIXEL];
+ struct wined3d_state *state = device->state;
+ struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
+ prev = state->shader[WINED3D_SHADER_TYPE_PIXEL];
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
- device->state.shader[WINED3D_SHADER_TYPE_PIXEL] = shader;
+ state->shader[WINED3D_SHADER_TYPE_PIXEL] = shader;
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_PIXEL, shader);
if (prev)
wined3d_shader_decref(prev);
@@ -2197,7 +2227,7 @@ struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined
{
TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_PIXEL];
+ return device->state->shader[WINED3D_SHADER_TYPE_PIXEL];
}
void CDECL wined3d_device_set_ps_resource_view(struct wined3d_device *device,
@@ -2238,7 +2268,7 @@ static void wined3d_device_set_ps_consts_b(struct wined3d_device *device,
TRACE("device %p, start_idx %u, count %u, constants %p.\n",
device, start_idx, count, constants);
- memcpy(&device->state.ps_consts_b[start_idx], constants, count * sizeof(*constants));
+ memcpy(&device->state->ps_consts_b[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d))
{
for (i = 0; i < count; ++i)
@@ -2256,7 +2286,7 @@ static void wined3d_device_set_ps_consts_i(struct wined3d_device *device,
TRACE("device %p, start_idx %u, count %u, constants %p.\n",
device, start_idx, count, constants);
- memcpy(&device->state.ps_consts_i[start_idx], constants, count * sizeof(*constants));
+ memcpy(&device->state->ps_consts_i[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d))
{
for (i = 0; i < count; ++i)
@@ -2274,7 +2304,7 @@ static void wined3d_device_set_ps_consts_f(struct wined3d_device *device,
TRACE("device %p, start_idx %u, count %u, constants %p.\n",
device, start_idx, count, constants);
- memcpy(&device->state.ps_consts_f[start_idx], constants, count * sizeof(*constants));
+ memcpy(&device->state->ps_consts_f[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d))
{
for (i = 0; i < count; ++i)
@@ -2286,16 +2316,17 @@ static void wined3d_device_set_ps_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
+ struct wined3d_state *state = device->state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
- prev = device->state.shader[WINED3D_SHADER_TYPE_HULL];
+ prev = state->shader[WINED3D_SHADER_TYPE_HULL];
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
- device->state.shader[WINED3D_SHADER_TYPE_HULL] = shader;
+ state->shader[WINED3D_SHADER_TYPE_HULL] = shader;
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_HULL, shader);
if (prev)
wined3d_shader_decref(prev);
@@ -2305,7 +2336,7 @@ struct wined3d_shader * CDECL wined3d_device_get_hull_shader(const struct wined3
{
TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_HULL];
+ return device->state->shader[WINED3D_SHADER_TYPE_HULL];
}
void CDECL wined3d_device_set_hs_resource_view(struct wined3d_device *device,
@@ -2341,16 +2372,17 @@ struct wined3d_sampler * CDECL wined3d_device_get_hs_sampler(const struct wined3
void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
+ struct wined3d_state *state = device->state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
- prev = device->state.shader[WINED3D_SHADER_TYPE_DOMAIN];
+ prev = state->shader[WINED3D_SHADER_TYPE_DOMAIN];
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
- device->state.shader[WINED3D_SHADER_TYPE_DOMAIN] = shader;
+ state->shader[WINED3D_SHADER_TYPE_DOMAIN] = shader;
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_DOMAIN, shader);
if (prev)
wined3d_shader_decref(prev);
@@ -2360,7 +2392,7 @@ struct wined3d_shader * CDECL wined3d_device_get_domain_shader(const struct wine
{
TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_DOMAIN];
+ return device->state->shader[WINED3D_SHADER_TYPE_DOMAIN];
}
void CDECL wined3d_device_set_ds_resource_view(struct wined3d_device *device,
@@ -2396,15 +2428,17 @@ struct wined3d_sampler * CDECL wined3d_device_get_ds_sampler(const struct wined3
void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
- struct wined3d_shader *prev = device->state.shader[WINED3D_SHADER_TYPE_GEOMETRY];
+ struct wined3d_state *state = device->state;
+ struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
+ prev = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
- device->state.shader[WINED3D_SHADER_TYPE_GEOMETRY] = shader;
+ state->shader[WINED3D_SHADER_TYPE_GEOMETRY] = shader;
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_GEOMETRY, shader);
if (prev)
wined3d_shader_decref(prev);
@@ -2414,7 +2448,7 @@ struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wi
{
TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_GEOMETRY];
+ return device->state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
}
void CDECL wined3d_device_set_gs_resource_view(struct wined3d_device *device,
@@ -2449,16 +2483,17 @@ struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3
void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
+ struct wined3d_state *state = device->state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
- prev = device->state.shader[WINED3D_SHADER_TYPE_COMPUTE];
+ prev = state->shader[WINED3D_SHADER_TYPE_COMPUTE];
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
- device->state.shader[WINED3D_SHADER_TYPE_COMPUTE] = shader;
+ state->shader[WINED3D_SHADER_TYPE_COMPUTE] = shader;
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_COMPUTE, shader);
if (prev)
wined3d_shader_decref(prev);
@@ -2468,7 +2503,7 @@ struct wined3d_shader * CDECL wined3d_device_get_compute_shader(const struct win
{
TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_COMPUTE];
+ return device->state->shader[WINED3D_SHADER_TYPE_COMPUTE];
}
void CDECL wined3d_device_set_cs_resource_view(struct wined3d_device *device,
@@ -2506,6 +2541,7 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev
enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav,
unsigned int initial_count)
{
+ struct wined3d_state *state = device->state;
struct wined3d_unordered_access_view *prev;
if (idx >= MAX_UNORDERED_ACCESS_VIEWS)
@@ -2514,13 +2550,13 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev
return;
}
- prev = device->state.unordered_access_view[pipeline][idx];
+ prev = state->unordered_access_view[pipeline][idx];
if (uav == prev && initial_count == ~0u)
return;
if (uav)
wined3d_unordered_access_view_incref(uav);
- device->state.unordered_access_view[pipeline][idx] = uav;
+ state->unordered_access_view[pipeline][idx] = uav;
wined3d_cs_emit_set_unordered_access_view(device->cs, pipeline, idx, uav, initial_count);
if (prev)
wined3d_unordered_access_view_decref(prev);
@@ -2535,7 +2571,7 @@ static struct wined3d_unordered_access_view *wined3d_device_get_pipeline_unorder
return NULL;
}
- return device->state.unordered_access_view[pipeline][idx];
+ return device->state->unordered_access_view[pipeline][idx];
}
void CDECL wined3d_device_set_cs_uav(struct wined3d_device *device, unsigned int idx,
@@ -3136,7 +3172,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
enum wined3d_material_color_source diffuse_source, specular_source, ambient_source, emissive_source;
const struct wined3d_color *material_specular_state_colour;
struct wined3d_matrix mat, proj_mat, view_mat, world_mat;
- const struct wined3d_state *state = &device->state;
+ const struct wined3d_state *state = device->state;
const struct wined3d_format *output_colour_format;
static const struct wined3d_color black;
struct wined3d_map_desc map_desc;
@@ -3454,7 +3490,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
const struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf)
{
- struct wined3d_state *state = &device->state;
+ struct wined3d_state *state = device->state;
struct wined3d_stream_info stream_info;
struct wined3d_resource *resource;
struct wined3d_box box = {0};
@@ -3543,13 +3579,13 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device
return;
}
- if (value == device->state.texture_states[stage][state])
+ if (value == device->state->texture_states[stage][state])
{
TRACE("Application is setting the old value over, nothing to do.\n");
return;
}
- device->state.texture_states[stage][state] = value;
+ device->state->texture_states[stage][state] = value;
wined3d_cs_emit_set_texture_state(device->cs, stage, state, value);
}
@@ -3557,18 +3593,19 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device
static void wined3d_device_set_texture(struct wined3d_device *device,
UINT stage, struct wined3d_texture *texture)
{
+ struct wined3d_state *state = device->state;
struct wined3d_texture *prev;
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
/* Windows accepts overflowing this array... we do not. */
- if (stage >= ARRAY_SIZE(device->state.textures))
+ if (stage >= ARRAY_SIZE(state->textures))
{
WARN("Ignoring invalid stage %u.\n", stage);
return;
}
- prev = device->state.textures[stage];
+ prev = state->textures[stage];
TRACE("Previous texture %p.\n", prev);
if (texture == prev)
@@ -3578,7 +3615,7 @@ static void wined3d_device_set_texture(struct wined3d_device *device,
}
TRACE("Setting new texture to %p.\n", texture);
- device->state.textures[stage] = texture;
+ state->textures[stage] = texture;
if (texture)
wined3d_texture_incref(texture);
@@ -4047,6 +4084,8 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count,
const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
{
+ struct wined3d_fb_state *fb = &device->state->fb;
+
TRACE("device %p, rect_count %u, rects %p, flags %#x, color %s, depth %.8e, stencil %u.\n",
device, rect_count, rects, flags, debug_color(color), depth, stencil);
@@ -4058,7 +4097,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
{
- struct wined3d_rendertarget_view *ds = device->state.fb.depth_stencil;
+ struct wined3d_rendertarget_view *ds = fb->depth_stencil;
if (!ds)
{
WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
@@ -4067,8 +4106,8 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
}
else if (flags & WINED3DCLEAR_TARGET)
{
- if (ds->width < device->state.fb.render_targets[0]->width
- || ds->height < device->state.fb.render_targets[0]->height)
+ if (ds->width < fb->render_targets[0]->width
+ || ds->height < fb->render_targets[0]->height)
{
WARN("Silently ignoring depth and target clear with mismatching sizes\n");
return WINED3D_OK;
@@ -4084,18 +4123,19 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
void CDECL wined3d_device_set_predication(struct wined3d_device *device,
struct wined3d_query *predicate, BOOL value)
{
+ struct wined3d_state *state = device->state;
struct wined3d_query *prev;
TRACE("device %p, predicate %p, value %#x.\n", device, predicate, value);
- prev = device->state.predicate;
+ prev = state->predicate;
if (predicate)
{
FIXME("Predicated rendering not implemented.\n");
wined3d_query_incref(predicate);
}
- device->state.predicate = predicate;
- device->state.predicate_value = value;
+ state->predicate = predicate;
+ state->predicate_value = value;
wined3d_cs_emit_set_predication(device->cs, predicate, value);
if (prev)
wined3d_query_decref(prev);
@@ -4103,11 +4143,13 @@ void CDECL wined3d_device_set_predication(struct wined3d_device *device,
struct wined3d_query * CDECL wined3d_device_get_predication(struct wined3d_device *device, BOOL *value)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, value %p.\n", device, value);
if (value)
- *value = device->state.predicate_value;
- return device->state.predicate;
+ *value = state->predicate_value;
+ return state->predicate;
}
void CDECL wined3d_device_dispatch_compute(struct wined3d_device *device,
@@ -4130,32 +4172,38 @@ void CDECL wined3d_device_dispatch_compute_indirect(struct wined3d_device *devic
void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device,
enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, primitive_type %s, patch_vertex_count %u.\n",
device, debug_d3dprimitivetype(primitive_type), patch_vertex_count);
- device->state.primitive_type = primitive_type;
- device->state.patch_vertex_count = patch_vertex_count;
+ state->primitive_type = primitive_type;
+ state->patch_vertex_count = patch_vertex_count;
}
void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device,
enum wined3d_primitive_type *primitive_type, unsigned int *patch_vertex_count)
{
+ const struct wined3d_state *state = device->state;
+
TRACE("device %p, primitive_type %p, patch_vertex_count %p.\n",
device, primitive_type, patch_vertex_count);
- *primitive_type = device->state.primitive_type;
+ *primitive_type = state->primitive_type;
if (patch_vertex_count)
- *patch_vertex_count = device->state.patch_vertex_count;
+ *patch_vertex_count = state->patch_vertex_count;
TRACE("Returning %s.\n", debug_d3dprimitivetype(*primitive_type));
}
HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, start_vertex %u, vertex_count %u.\n", device, start_vertex, vertex_count);
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type,
- device->state.patch_vertex_count, 0, start_vertex, vertex_count, 0, 0, false);
+ wined3d_cs_emit_draw(device->cs, state->primitive_type,
+ state->patch_vertex_count, 0, start_vertex, vertex_count, 0, 0, false);
return WINED3D_OK;
}
@@ -4163,27 +4211,33 @@ HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT
void CDECL wined3d_device_draw_primitive_instanced(struct wined3d_device *device,
UINT start_vertex, UINT vertex_count, UINT start_instance, UINT instance_count)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, start_vertex %u, vertex_count %u, start_instance %u, instance_count %u.\n",
device, start_vertex, vertex_count, start_instance, instance_count);
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type, device->state.patch_vertex_count,
+ wined3d_cs_emit_draw(device->cs, state->primitive_type, state->patch_vertex_count,
0, start_vertex, vertex_count, start_instance, instance_count, false);
}
void CDECL wined3d_device_draw_primitive_instanced_indirect(struct wined3d_device *device,
struct wined3d_buffer *buffer, unsigned int offset)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
- wined3d_cs_emit_draw_indirect(device->cs, device->state.primitive_type,
- device->state.patch_vertex_count, buffer, offset, false);
+ wined3d_cs_emit_draw_indirect(device->cs, state->primitive_type,
+ state->patch_vertex_count, buffer, offset, false);
}
HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, start_idx %u, index_count %u.\n", device, start_idx, index_count);
- if (!device->state.index_buffer)
+ if (!state->index_buffer)
{
/* D3D9 returns D3DERR_INVALIDCALL when DrawIndexedPrimitive is called
* without an index buffer set. (The first time at least...)
@@ -4193,8 +4247,8 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic
return WINED3DERR_INVALIDCALL;
}
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type, device->state.patch_vertex_count,
- device->state.base_vertex_index, start_idx, index_count, 0, 0, true);
+ wined3d_cs_emit_draw(device->cs, state->primitive_type, state->patch_vertex_count,
+ state->base_vertex_index, start_idx, index_count, 0, 0, true);
return WINED3D_OK;
}
@@ -4202,20 +4256,24 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic
void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device *device,
UINT start_idx, UINT index_count, UINT start_instance, UINT instance_count)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, start_idx %u, index_count %u, start_instance %u, instance_count %u.\n",
device, start_idx, index_count, start_instance, instance_count);
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type, device->state.patch_vertex_count,
- device->state.base_vertex_index, start_idx, index_count, start_instance, instance_count, true);
+ wined3d_cs_emit_draw(device->cs, state->primitive_type, state->patch_vertex_count,
+ state->base_vertex_index, start_idx, index_count, start_instance, instance_count, true);
}
void CDECL wined3d_device_draw_indexed_primitive_instanced_indirect(struct wined3d_device *device,
struct wined3d_buffer *buffer, unsigned int offset)
{
+ struct wined3d_state *state = device->state;
+
TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
- wined3d_cs_emit_draw_indirect(device->cs, device->state.primitive_type,
- device->state.patch_vertex_count, buffer, offset, true);
+ wined3d_cs_emit_draw_indirect(device->cs, state->primitive_type,
+ state->patch_vertex_count, buffer, offset, true);
}
HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
@@ -4375,7 +4433,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes)
{
- const struct wined3d_state *state = &device->state;
+ const struct wined3d_state *state = device->state;
struct wined3d_texture *texture;
DWORD i;
@@ -4418,8 +4476,8 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device
if (wined3d_state_uses_depth_buffer(state)
|| (state->depth_stencil_state && state->depth_stencil_state->desc.stencil))
{
- struct wined3d_rendertarget_view *rt = device->state.fb.render_targets[0];
- struct wined3d_rendertarget_view *ds = device->state.fb.depth_stencil;
+ struct wined3d_rendertarget_view *rt = state->fb.render_targets[0];
+ struct wined3d_rendertarget_view *ds = state->fb.depth_stencil;
if (ds && rt && (ds->width < rt->width || ds->height < rt->height))
{
@@ -4967,19 +5025,21 @@ struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(co
return NULL;
}
- return device->state.fb.render_targets[view_idx];
+ return device->state->fb.render_targets[view_idx];
}
struct wined3d_rendertarget_view * CDECL wined3d_device_get_depth_stencil_view(const struct wined3d_device *device)
{
TRACE("device %p.\n", device);
- return device->state.fb.depth_stencil;
+ return device->state->fb.depth_stencil;
}
static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device,
const struct wined3d_rendertarget_view *view, BOOL dsv)
{
+ struct wined3d_state *state = device->state;
+
if (view && wined3d_is_rtv_srv_bound(view))
{
const struct wined3d_resource *resource = view->resource;
@@ -4990,7 +5050,7 @@ static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device,
for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j)
- if ((srv = device->state.shader_resource_view[i][j]) && srv->resource == resource
+ if ((srv = state->shader_resource_view[i][j]) && srv->resource == resource
&& ((!dsv && wined3d_is_srv_rtv_bound(srv))
|| (dsv && wined3d_dsv_srv_conflict(view, srv->format))))
wined3d_device_set_shader_resource_view(device, i, j, NULL);
@@ -5000,6 +5060,7 @@ static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device,
HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device,
unsigned int view_idx, struct wined3d_rendertarget_view *view, BOOL set_viewport)
{
+ struct wined3d_state *state = device->state;
struct wined3d_rendertarget_view *prev;
unsigned int max_rt_count;
@@ -5024,8 +5085,6 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device
* primary stateblock. */
if (!view_idx && set_viewport)
{
- struct wined3d_state *state = &device->state;
-
state->viewports[0].x = 0;
state->viewports[0].y = 0;
state->viewports[0].width = view->width;
@@ -5040,7 +5099,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device
wined3d_cs_emit_set_scissor_rects(device->cs, 1, state->scissor_rects);
}
- prev = device->state.fb.render_targets[view_idx];
+ prev = state->fb.render_targets[view_idx];
if (view == prev)
return WINED3D_OK;
@@ -5049,7 +5108,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device
wined3d_rendertarget_view_incref(view);
wined3d_rtv_bind_count_inc(view);
}
- device->state.fb.render_targets[view_idx] = view;
+ state->fb.render_targets[view_idx] = view;
wined3d_cs_emit_set_rendertarget_view(device->cs, view_idx, view);
/* Release after the assignment, to prevent device_resource_released()
* from seeing the surface as still in use. */
@@ -5067,6 +5126,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device
HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *view)
{
+ struct wined3d_fb_state *fb = &device->state->fb;
struct wined3d_rendertarget_view *prev;
TRACE("device %p, view %p.\n", device, view);
@@ -5078,14 +5138,14 @@ HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *devic
return WINED3DERR_INVALIDCALL;
}
- prev = device->state.fb.depth_stencil;
+ prev = fb->depth_stencil;
if (prev == view)
{
TRACE("Trying to do a NOP SetRenderTarget operation.\n");
return WINED3D_OK;
}
- if ((device->state.fb.depth_stencil = view))
+ if ((fb->depth_stencil = view))
wined3d_rendertarget_view_incref(view);
wined3d_cs_emit_set_depth_stencil_view(device->cs, view);
if (prev)
@@ -5341,6 +5401,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
struct wined3d_swapchain_state *swapchain_state;
struct wined3d_swapchain_desc *current_desc;
+ struct wined3d_state *state = device->state;
struct wined3d_resource *resource, *cursor;
struct wined3d_rendertarget_view *view;
struct wined3d_swapchain *swapchain;
@@ -5374,7 +5435,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
wined3d_texture_decref(device->cursor_texture);
device->cursor_texture = NULL;
}
- state_unbind_resources(&device->state);
+ state_unbind_resources(state);
}
for (i = 0; i < d3d_info->limits.max_rt_count; ++i)
@@ -5584,7 +5645,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
{
TRACE("Resetting state.\n");
wined3d_cs_emit_reset_state(device->cs);
- state_cleanup(&device->state);
+ state_cleanup(state);
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
{
@@ -5594,8 +5655,8 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->adapter->adapter_ops->adapter_uninit_3d(device);
- memset(&device->state, 0, sizeof(device->state));
- state_init(&device->state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+ memset(state, 0, sizeof(*state));
+ state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device_init_swapchain_state(device, swapchain);
if (wined3d_settings.logo)
@@ -5695,18 +5756,19 @@ static void device_resource_remove(struct wined3d_device *device, struct wined3d
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource)
{
enum wined3d_resource_type type = resource->type;
+ struct wined3d_state *state = device->state;
struct wined3d_rendertarget_view *rtv;
unsigned int i;
TRACE("device %p, resource %p, type %s.\n", device, resource, debug_d3dresourcetype(type));
- for (i = 0; i < ARRAY_SIZE(device->state.fb.render_targets); ++i)
+ for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
{
- if ((rtv = device->state.fb.render_targets[i]) && rtv->resource == resource)
+ if ((rtv = state->fb.render_targets[i]) && rtv->resource == resource)
ERR("Resource %p is still in use as render target %u.\n", resource, i);
}
- if ((rtv = device->state.fb.depth_stencil) && rtv->resource == resource)
+ if ((rtv = state->fb.depth_stencil) && rtv->resource == resource)
ERR("Resource %p is still in use as depth/stencil buffer.\n", resource);
switch (type)
@@ -5716,10 +5778,10 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
case WINED3D_RTYPE_TEXTURE_3D:
for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
{
- if (&device->state.textures[i]->resource == resource)
+ if (&state->textures[i]->resource == resource)
{
ERR("Texture resource %p is still in use, stage %u.\n", resource, i);
- device->state.textures[i] = NULL;
+ state->textures[i] = NULL;
}
}
break;
@@ -5727,17 +5789,17 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
case WINED3D_RTYPE_BUFFER:
for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
{
- if (&device->state.streams[i].buffer->resource == resource)
+ if (&state->streams[i].buffer->resource == resource)
{
ERR("Buffer resource %p is still in use, stream %u.\n", resource, i);
- device->state.streams[i].buffer = NULL;
+ state->streams[i].buffer = NULL;
}
}
- if (&device->state.index_buffer->resource == resource)
+ if (&state->index_buffer->resource == resource)
{
ERR("Buffer resource %p is still in use as index buffer.\n", resource);
- device->state.index_buffer = NULL;
+ state->index_buffer = NULL;
}
break;
@@ -5852,6 +5914,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
struct wined3d_adapter *adapter = wined3d->adapters[adapter_idx];
const struct wined3d_fragment_pipe_ops *fragment_pipeline;
const struct wined3d_vertex_pipe_ops *vertex_pipeline;
+ struct wined3d_state *state;
unsigned int i;
HRESULT hr;
@@ -5902,14 +5965,20 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
return hr;
}
- state_init(&device->state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+ if (!(state = heap_alloc_zero(sizeof(*state))))
+ {
+ hr = E_OUTOFMEMORY;
+ goto err;
+ }
+ state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+ device->state = state;
device->max_frame_latency = 3;
if (!(device->cs = wined3d_cs_create(device)))
{
WARN("Failed to create command stream.\n");
- state_cleanup(&device->state);
+ state_cleanup(state);
hr = E_FAIL;
goto err;
}
@@ -5917,6 +5986,8 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
return WINED3D_OK;
err:
+ if (state)
+ heap_free(state);
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
heap_free(device->multistate_funcs[i]);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index f4f929db2cab..b53cd02d75cc 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1610,7 +1610,7 @@ DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod)
wined3d_texture_gl(texture)->texture_srgb.base_level = ~0u;
if (resource->bind_count)
wined3d_cs_emit_set_sampler_state(device->cs, texture->sampler, WINED3D_SAMP_MAX_MIP_LEVEL,
- device->state.sampler_states[texture->sampler][WINED3D_SAMP_MAX_MIP_LEVEL]);
+ device->state->sampler_states[texture->sampler][WINED3D_SAMP_MAX_MIP_LEVEL]);
}
return old;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 2a75ab5d43d9..56d3ef8fea21 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3776,7 +3776,7 @@ struct wined3d_device
enum wined3d_feature_level feature_level;
- struct wined3d_state state;
+ struct wined3d_state *state;
/* Internal use fields */
struct wined3d_device_creation_parameters create_parms;
--
2.20.1
1
0
23 Feb '21
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=14025
Signed-off-by: Szegeczki Imre <szegeczki1(a)gmail.com>
---
dlls/dinput/mouse.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index e50731fda41..73dd46c7249 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -379,8 +379,12 @@ void dinput_mouse_rawinput_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPA
if (ri->data.mouse.usButtonFlags & RI_MOUSE_WHEEL)
{
This->m_state.lZ += (wdata = (SHORT)ri->data.mouse.usButtonData);
- queue_event( iface, DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS,
- wdata, GetCurrentTime(), seq );
+ if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
+ queue_event( iface, DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS,
+ This->m_state.lZ, GetCurrentTime(), seq );
+ else
+ queue_event( iface, DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS,
+ wdata, GetCurrentTime(), seq );
}
for (i = 0; i < ARRAY_SIZE(mouse_button_flags); ++i)
@@ -449,6 +453,8 @@ int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam
case WM_MOUSEWHEEL:
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS;
This->m_state.lZ += wdata = (short)HIWORD(hook->mouseData);
+ if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
+ wdata = This->m_state.lZ;
/* FarCry crashes if it gets a mouse wheel message */
/* FIXME: should probably filter out other messages too */
ret = This->clipped;
--
2.30.1
1
0
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
---
dlls/ntdll/unix/signal_x86_64.c | 37 +++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
1
0