Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
February 2020
- 80 participants
- 745 discussions
18 Feb '20
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/urlmon/tests/protocol.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c
index 84dd5345be..6fc864f777 100644
--- a/dlls/urlmon/tests/protocol.c
+++ b/dlls/urlmon/tests/protocol.c
@@ -223,13 +223,6 @@ static LONG obj_refcount(void *obj)
return IUnknown_Release((IUnknown *)obj);
}
-static int strcmp_wa(LPCWSTR strw, const char *stra)
-{
- CHAR buf[512];
- WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
- return lstrcmpA(stra, buf);
-}
-
static const char *w2a(LPCWSTR str)
{
static char buf[INTERNET_MAX_URL_LENGTH];
@@ -859,7 +852,7 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
!memcmp(szStatusText, text_plain, lstrlenW(text_plain)*sizeof(WCHAR)),
"szStatusText != text/plain\n");
else if(empty_file)
- ok(!strcmp_wa(szStatusText, "application/javascript"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
+ ok(!lstrcmpW(szStatusText, L"application/javascript"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
else if((pi & PI_MIMEVERIFICATION) && emulate_prot && !mimefilter_test
&& tested_protocol==HTTP_TEST && !short_read)
ok(lstrlenW(gifW) <= lstrlenW(szStatusText) &&
@@ -915,7 +908,7 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
ok(szStatusText != NULL, "szStatusText == NULL\n");
if(szStatusText)
- ok(!strcmp_wa(szStatusText, "text/html"), "szStatusText != text/html\n");
+ ok(!lstrcmpW(szStatusText, L"text/html"), "szStatusText != text/html\n");
break;
case BINDSTATUS_PROTOCOLCLASSID:
CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID);
@@ -929,13 +922,13 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
case BINDSTATUS_REDIRECTING:
CHECK_EXPECT(ReportProgress_REDIRECTING);
if(test_redirect)
- ok(!strcmp_wa(szStatusText, "http://test.winehq.org/tests/hello.html"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
+ ok(!lstrcmpW(szStatusText, L"http://test.winehq.org/tests/hello.html"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
else
ok(szStatusText == NULL, "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
break;
case BINDSTATUS_ENCODING:
CHECK_EXPECT(ReportProgress_ENCODING);
- ok(!strcmp_wa(szStatusText, "gzip"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
+ ok(!lstrcmpW(szStatusText, L"gzip"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
break;
case BINDSTATUS_ACCEPTRANGES:
CHECK_EXPECT(ReportProgress_ACCEPTRANGES);
@@ -1200,7 +1193,7 @@ static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HR
"dwError == ERROR_SUCCESS\n");
if(hrResult == INET_E_REDIRECT_FAILED)
- ok(!strcmp_wa(szResult, "http://test.winehq.org/tests/hello.html"), "szResult = %s\n", wine_dbgstr_w(szResult));
+ ok(!lstrcmpW(szResult, L"http://test.winehq.org/tests/hello.html"), "szResult = %s\n", wine_dbgstr_w(szResult));
else
ok(!szResult, "szResult = %s\n", wine_dbgstr_w(szResult));
--
2.24.1
3
2
18 Feb '20
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/vbscript/vbscript.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index f37b0ce..589abc3 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -55,14 +55,6 @@ typedef struct _vbscode_t vbscode_t;
typedef struct _script_ctx_t script_ctx_t;
typedef struct _vbdisp_t vbdisp_t;
-typedef struct named_item_t {
- IDispatch *disp;
- DWORD flags;
- LPWSTR name;
-
- struct list entry;
-} named_item_t;
-
typedef enum {
VBDISP_CALLGET,
VBDISP_LET,
@@ -156,6 +148,14 @@ typedef struct {
script_ctx_t *ctx;
} BuiltinDisp;
+typedef struct named_item_t {
+ IDispatch *disp;
+ DWORD flags;
+ LPWSTR name;
+
+ struct list entry;
+} named_item_t;
+
HRESULT create_vbdisp(const class_desc_t*,vbdisp_t**) DECLSPEC_HIDDEN;
HRESULT disp_get_id(IDispatch*,BSTR,vbdisp_invoke_type_t,BOOL,DISPID*) DECLSPEC_HIDDEN;
HRESULT vbdisp_get_id(vbdisp_t*,BSTR,vbdisp_invoke_type_t,BOOL,DISPID*) DECLSPEC_HIDDEN;
--
2.21.0
2
7
18 Feb '20
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
v3: Fix test error
---
programs/find/tests/find.c | 42 ++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/programs/find/tests/find.c b/programs/find/tests/find.c
index b8345034b5..55896baeaf 100644
--- a/programs/find/tests/find.c
+++ b/programs/find/tests/find.c
@@ -264,6 +264,47 @@ static void run_find_unicode_(const BYTE *input, int input_len, const BYTE *out_
run_find_stdin_(wstr_quoted_test, input, input_len, out_expected_mangled, out_expected_mangled_len, exitcode_expected, file, line);
}
+static void run_find_file_multi(void)
+{
+ char path_temp_file1[MAX_PATH];
+ char path_temp_file2[MAX_PATH];
+ char path_temp_dir[MAX_PATH];
+ HANDLE handle_file;
+ WCHAR commandline_new[MAX_PATH];
+ char out_expected[500];
+ const char* input = "ab\nbd";
+
+ GetTempPathA(ARRAY_SIZE(path_temp_dir), path_temp_dir);
+ GetTempFileNameA(path_temp_dir, "", 0, path_temp_file1);
+ GetTempFileNameA(path_temp_dir, "", 0, path_temp_file2);
+ handle_file = CreateFileA(path_temp_file1, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+ write_to_handle(handle_file, (BYTE*)input, strlen(input));
+ CloseHandle(handle_file);
+ handle_file = CreateFileA(path_temp_file2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+ write_to_handle(handle_file, (BYTE*)input, strlen(input));
+ CloseHandle(handle_file);
+
+ wsprintfW(commandline_new, L"\"b\" C:\\doesnotexist1 %hs C:\\doesnotexist1 %hs C:\\doesnotexist1", path_temp_file1, path_temp_file2);
+
+ CharUpperA(path_temp_file1);
+ CharUpperA(path_temp_file2);
+ wsprintfA(out_expected,
+ "File not found - C:\\DOESNOTEXIST1\r\n"
+ "\r\n---------- %s\r\n"
+ "ab\r\nbd\r\n"
+ "File not found - C:\\DOESNOTEXIST1\r\n"
+ "\r\n---------- %s\r\n"
+ "ab\r\nbd\r\n"
+ "File not found - C:\\DOESNOTEXIST1\r\n",
+ path_temp_file1, path_temp_file2);
+
+ todo_wine
+ run_find_stdin_(commandline_new, (BYTE*)"", 0, (BYTE*)out_expected, strlen(out_expected), 0, __FILE__, __LINE__);
+
+ DeleteFileA(path_temp_file1);
+ DeleteFileA(path_temp_file2);
+}
+
static void test_errors(void)
{
run_find_stdin_str("", "", "FIND: Parameter format not correct\r\n", 2);
@@ -411,6 +452,7 @@ START_TEST(find)
else
{
test_errors();
+ run_find_file_multi();
}
test_singleline_without_switches();
test_multiline();
--
2.25.1
3
4
[PATCH v5] d3dcompiler: Return an instruction list instead of a single instruction from nodes representing expressions.
by Zebediah Figura 18 Feb '20
by Zebediah Figura 18 Feb '20
18 Feb '20
From: Zebediah Figura <zfigura(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
v2: don't drop all of the struct initializer elements on the floor
v3: style tweak, clarify loop_condition()
v4: fix append_conditional_break(); remove confusing uses of append_unop()
v5: don't drop all of the variable initializer instructions on the floor
This supersedes <https://source.winehq.org/patches/data/178616>; other patches
in that series should still apply.
dlls/d3dcompiler_43/d3dcompiler_private.h | 6 +
dlls/d3dcompiler_43/hlsl.y | 328 ++++++++++++----------
dlls/d3dcompiler_43/utils.c | 46 +--
3 files changed, 185 insertions(+), 195 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 5fc3161f5f0..9c58830ffe2 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -984,6 +984,7 @@ struct parse_initializer
{
struct hlsl_ir_node **args;
unsigned int args_count;
+ struct list *instrs;
};
struct parse_variable_def
@@ -1120,6 +1121,11 @@ static inline struct hlsl_ir_loop *loop_from_node(const struct hlsl_ir_node *nod
return CONTAINING_RECORD(node, struct hlsl_ir_loop, node);
}
+static inline struct hlsl_ir_node *node_from_list(struct list *list)
+{
+ return LIST_ENTRY(list_tail(list), struct hlsl_ir_node, entry);
+}
+
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index d81d6afa9cc..f9e091af51c 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -255,56 +255,49 @@ static void declare_predefined_types(struct hlsl_scope *scope)
add_type_to_scope(scope, type);
}
-static struct hlsl_ir_if *loop_condition(struct list *cond_list)
+static BOOL append_conditional_break(struct list *cond_list)
{
- struct hlsl_ir_node *cond, *not_cond;
- struct hlsl_ir_if *out_cond;
+ struct hlsl_ir_node *condition, *not;
struct hlsl_ir_jump *jump;
- unsigned int count = list_count(cond_list);
+ struct hlsl_ir_if *iff;
- if (!count)
- return NULL;
- if (count != 1)
- ERR("Got multiple expressions in a for condition.\n");
+ /* E.g. "for (i = 0; ; ++i)". */
+ if (!list_count(cond_list))
+ return TRUE;
- cond = LIST_ENTRY(list_head(cond_list), struct hlsl_ir_node, entry);
- out_cond = d3dcompiler_alloc(sizeof(*out_cond));
- if (!out_cond)
+ condition = node_from_list(cond_list);
+ if (!(not = new_unary_expr(HLSL_IR_UNOP_LOGIC_NOT, condition, condition->loc)))
{
ERR("Out of memory.\n");
- return NULL;
+ return FALSE;
}
- out_cond->node.type = HLSL_IR_IF;
- if (!(not_cond = new_unary_expr(HLSL_IR_UNOP_LOGIC_NOT, cond, cond->loc)))
+ list_add_tail(cond_list, ¬->entry);
+
+ if (!(iff = d3dcompiler_alloc(sizeof(*iff))))
{
ERR("Out of memory.\n");
- d3dcompiler_free(out_cond);
- return NULL;
+ return FALSE;
}
- out_cond->condition = not_cond;
- jump = d3dcompiler_alloc(sizeof(*jump));
- if (!jump)
+ iff->node.type = HLSL_IR_IF;
+ iff->condition = not;
+ list_add_tail(cond_list, &iff->node.entry);
+
+ if (!(iff->then_instrs = d3dcompiler_alloc(sizeof(*iff->then_instrs))))
{
ERR("Out of memory.\n");
- d3dcompiler_free(out_cond);
- d3dcompiler_free(not_cond);
- return NULL;
+ return FALSE;
}
- jump->node.type = HLSL_IR_JUMP;
- jump->type = HLSL_IR_JUMP_BREAK;
- out_cond->then_instrs = d3dcompiler_alloc(sizeof(*out_cond->then_instrs));
- if (!out_cond->then_instrs)
+ list_init(iff->then_instrs);
+
+ if (!(jump = d3dcompiler_alloc(sizeof(*jump))))
{
ERR("Out of memory.\n");
- d3dcompiler_free(out_cond);
- d3dcompiler_free(not_cond);
- d3dcompiler_free(jump);
- return NULL;
+ return FALSE;
}
- list_init(out_cond->then_instrs);
- list_add_head(out_cond->then_instrs, &jump->node.entry);
-
- return out_cond;
+ jump->node.type = HLSL_IR_JUMP;
+ jump->type = HLSL_IR_JUMP_BREAK;
+ list_add_head(iff->then_instrs, &jump->node.entry);
+ return TRUE;
}
enum loop_type
@@ -315,7 +308,7 @@ enum loop_type
};
static struct list *create_loop(enum loop_type type, struct list *init, struct list *cond,
- struct hlsl_ir_node *iter, struct list *body, struct source_location *loc)
+ struct list *iter, struct list *body, struct source_location *loc)
{
struct list *list = NULL;
struct hlsl_ir_loop *loop = NULL;
@@ -340,20 +333,19 @@ static struct list *create_loop(enum loop_type type, struct list *init, struct l
goto oom;
list_init(loop->body);
- cond_jump = loop_condition(cond);
- if (!cond_jump)
+ if (!append_conditional_break(cond))
goto oom;
if (type != LOOP_DO_WHILE)
- list_add_tail(loop->body, &cond_jump->node.entry);
+ list_move_tail(loop->body, cond);
list_move_tail(loop->body, body);
if (iter)
- list_add_tail(loop->body, &iter->entry);
+ list_move_tail(loop->body, iter);
if (type == LOOP_DO_WHILE)
- list_add_tail(loop->body, &cond_jump->node.entry);
+ list_move_tail(loop->body, cond);
d3dcompiler_free(init);
d3dcompiler_free(cond);
@@ -369,7 +361,7 @@ oom:
d3dcompiler_free(list);
free_instr_list(init);
free_instr_list(cond);
- free_instr(iter);
+ free_instr_list(iter);
free_instr_list(body);
return NULL;
}
@@ -388,9 +380,7 @@ static unsigned int initializer_size(const struct parse_initializer *initializer
static void free_parse_initializer(struct parse_initializer *initializer)
{
- unsigned int i;
- for (i = 0; i < initializer->args_count; ++i)
- free_instr(initializer->args[i]);
+ free_instr_list(initializer->instrs);
d3dcompiler_free(initializer->args);
}
@@ -508,6 +498,9 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
return;
}
+ list_move_tail(list, initializer->instrs);
+ d3dcompiler_free(initializer->instrs);
+
LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
{
struct hlsl_ir_node *node = initializer->args[i];
@@ -526,6 +519,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
break;
}
deref->node.loc = node->loc;
+ list_add_tail(list, &deref->node.entry);
assignment = make_assignment(&deref->node, ASSIGN_OP_ASSIGN, BWRITERSP_WRITEMASK_ALL, node);
list_add_tail(list, &assignment->entry);
}
@@ -533,9 +527,6 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
FIXME("Initializing with \"mismatched\" fields is not supported yet.\n");
}
- /* Free initializer elements in excess. */
- for (; i < initializer->args_count; ++i)
- free_instr(initializer->args[i]);
d3dcompiler_free(initializer->args);
}
@@ -609,6 +600,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
if (v->initializer.args_count)
{
unsigned int size = initializer_size(&v->initializer);
+ struct hlsl_ir_deref *deref;
TRACE("Variable with initializer.\n");
if (type->type <= HLSL_CLASS_LAST_NUMERIC
@@ -661,7 +653,12 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
continue;
}
- assignment = make_assignment(&new_var_deref(var)->node, ASSIGN_OP_ASSIGN,
+ list_move_tail(statements_list, v->initializer.instrs);
+ d3dcompiler_free(v->initializer.instrs);
+
+ deref = new_var_deref(var);
+ list_add_tail(statements_list, &deref->node.entry);
+ assignment = make_assignment(&deref->node, ASSIGN_OP_ASSIGN,
BWRITERSP_WRITEMASK_ALL, v->initializer.args[0]);
d3dcompiler_free(v->initializer.args);
list_add_tail(statements_list, &assignment->entry);
@@ -880,6 +877,35 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr
return NULL;
}
+static struct list *append_unop(struct list *list, struct hlsl_ir_node *node)
+{
+ list_add_tail(list, &node->entry);
+ return list;
+}
+
+static struct list *append_binop(struct list *first, struct list *second, struct hlsl_ir_node *node)
+{
+ list_move_tail(first, second);
+ d3dcompiler_free(second);
+ list_add_tail(first, &node->entry);
+ return first;
+}
+
+static struct list *make_list(struct hlsl_ir_node *node)
+{
+ struct list *list;
+
+ if (!(list = d3dcompiler_alloc(sizeof(*list))))
+ {
+ ERR("Out of memory.\n");
+ free_instr(node);
+ return NULL;
+ }
+ list_init(list);
+ list_add_tail(list, &node->entry);
+ return list;
+}
+
%}
%locations
@@ -1024,12 +1050,12 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr
%type <variable_def> type_spec
%type <initializer> complex_initializer
%type <initializer> initializer_expr_list
-%type <instr> initializer_expr
+%type <list> initializer_expr
%type <modifiers> var_modifiers
%type <list> field
%type <list> parameters
%type <list> param_list
-%type <instr> expr
+%type <list> expr
%type <intval> array
%type <list> statement
%type <list> statement_list
@@ -1048,21 +1074,21 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr
%type <list> variables_def
%type <list> variables_def_optional
%type <if_body> if_body
-%type <instr> primary_expr
-%type <instr> postfix_expr
-%type <instr> unary_expr
-%type <instr> mul_expr
-%type <instr> add_expr
-%type <instr> shift_expr
-%type <instr> relational_expr
-%type <instr> equality_expr
-%type <instr> bitand_expr
-%type <instr> bitxor_expr
-%type <instr> bitor_expr
-%type <instr> logicand_expr
-%type <instr> logicor_expr
-%type <instr> conditional_expr
-%type <instr> assignment_expr
+%type <list> primary_expr
+%type <list> postfix_expr
+%type <list> unary_expr
+%type <list> mul_expr
+%type <list> add_expr
+%type <list> shift_expr
+%type <list> relational_expr
+%type <list> equality_expr
+%type <list> bitand_expr
+%type <list> bitxor_expr
+%type <list> bitor_expr
+%type <list> logicand_expr
+%type <list> logicor_expr
+%type <list> conditional_expr
+%type <list> assignment_expr
%type <list> expr_statement
%type <unary_op> unary_op
%type <assign_op> assign_op
@@ -1615,7 +1641,7 @@ array: /* Empty */
{
FIXME("Array.\n");
$$ = 0;
- free_instr($2);
+ free_instr_list($2);
}
var_modifiers: /* Empty */
@@ -1672,7 +1698,8 @@ complex_initializer: initializer_expr
$$.args_count = 1;
if (!($$.args = d3dcompiler_alloc(sizeof(*$$.args))))
YYABORT;
- $$.args[0] = $1;
+ $$.args[0] = node_from_list($1);
+ $$.instrs = $1;
}
| '{' initializer_expr_list '}'
{
@@ -1693,14 +1720,17 @@ initializer_expr_list: initializer_expr
$$.args_count = 1;
if (!($$.args = d3dcompiler_alloc(sizeof(*$$.args))))
YYABORT;
- $$.args[0] = $1;
+ $$.args[0] = node_from_list($1);
+ $$.instrs = $1;
}
| initializer_expr_list ',' initializer_expr
{
$$ = $1;
if (!($$.args = d3dcompiler_realloc($$.args, ($$.args_count + 1) * sizeof(*$$.args))))
YYABORT;
- $$.args[$$.args_count++] = $3;
+ $$.args[$$.args_count++] = node_from_list($3);
+ list_move_tail($$.instrs, $3);
+ d3dcompiler_free($3);
}
boolean: KW_TRUE
@@ -1742,15 +1772,14 @@ jump_statement: KW_RETURN expr ';'
jump->node.type = HLSL_IR_JUMP;
set_location(&jump->node.loc, &@1);
jump->type = HLSL_IR_JUMP_RETURN;
- jump->node.data_type = $2->data_type;
- jump->return_value = $2;
+ jump->node.data_type = node_from_list($2)->data_type;
+ jump->return_value = node_from_list($2);
FIXME("Check for valued return on void function.\n");
FIXME("Implicit conversion to the return type if needed, "
"error out if conversion not possible.\n");
- $$ = d3dcompiler_alloc(sizeof(*$$));
- list_init($$);
+ $$ = $2;
list_add_tail($$, &jump->node.entry);
}
@@ -1764,18 +1793,17 @@ selection_statement: KW_IF '(' expr ')' if_body
}
instr->node.type = HLSL_IR_IF;
set_location(&instr->node.loc, &@1);
- instr->condition = $3;
+ instr->condition = node_from_list($3);
instr->then_instrs = $5.then_instrs;
instr->else_instrs = $5.else_instrs;
- if ($3->data_type->dimx > 1 || $3->data_type->dimy > 1)
+ if (instr->condition->data_type->dimx > 1 || instr->condition->data_type->dimy > 1)
{
hlsl_report_message(instr->node.loc.file, instr->node.loc.line,
instr->node.loc.col, HLSL_LEVEL_ERROR,
"if condition requires a scalar");
}
- $$ = d3dcompiler_alloc(sizeof(*$$));
- list_init($$);
- list_add_head($$, &instr->node.entry);
+ $$ = $3;
+ list_add_tail($$, &instr->node.entry);
}
if_body: statement
@@ -1792,32 +1820,14 @@ if_body: statement
loop_statement: KW_WHILE '(' expr ')' statement
{
struct source_location loc;
- struct list *cond = d3dcompiler_alloc(sizeof(*cond));
-
- if (!cond)
- {
- ERR("Out of memory.\n");
- YYABORT;
- }
- list_init(cond);
- list_add_head(cond, &$3->entry);
set_location(&loc, &@1);
- $$ = create_loop(LOOP_WHILE, NULL, cond, NULL, $5, &loc);
+ $$ = create_loop(LOOP_WHILE, NULL, $3, NULL, $5, &loc);
}
| KW_DO statement KW_WHILE '(' expr ')' ';'
{
struct source_location loc;
- struct list *cond = d3dcompiler_alloc(sizeof(*cond));
-
- if (!cond)
- {
- ERR("Out of memory.\n");
- YYABORT;
- }
- list_init(cond);
- list_add_head(cond, &$5->entry);
set_location(&loc, &@1);
- $$ = create_loop(LOOP_DO_WHILE, NULL, cond, NULL, $2, &loc);
+ $$ = create_loop(LOOP_DO_WHILE, NULL, $5, NULL, $2, &loc);
}
| KW_FOR '(' scope_start expr_statement expr_statement expr ')' statement
{
@@ -1846,10 +1856,7 @@ expr_statement: ';'
}
| expr ';'
{
- $$ = d3dcompiler_alloc(sizeof(*$$));
- list_init($$);
- if ($1)
- list_add_head($$, &$1->entry);
+ $$ = $1;
}
primary_expr: C_FLOAT
@@ -1864,7 +1871,8 @@ primary_expr: C_FLOAT
set_location(&c->node.loc, &yylloc);
c->node.data_type = new_hlsl_type(d3dcompiler_strdup("float"), HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1);
c->v.value.f[0] = $1;
- $$ = &c->node;
+ if (!($$ = make_list(&c->node)))
+ YYABORT;
}
| C_INTEGER
{
@@ -1878,7 +1886,8 @@ primary_expr: C_FLOAT
set_location(&c->node.loc, &yylloc);
c->node.data_type = new_hlsl_type(d3dcompiler_strdup("int"), HLSL_CLASS_SCALAR, HLSL_TYPE_INT, 1, 1);
c->v.value.i[0] = $1;
- $$ = &c->node;
+ if (!($$ = make_list(&c->node)))
+ YYABORT;
}
| boolean
{
@@ -1892,7 +1901,8 @@ primary_expr: C_FLOAT
set_location(&c->node.loc, &yylloc);
c->node.data_type = new_hlsl_type(d3dcompiler_strdup("bool"), HLSL_CLASS_SCALAR, HLSL_TYPE_BOOL, 1, 1);
c->v.value.b[0] = $1;
- $$ = &c->node;
+ if (!($$ = make_list(&c->node)))
+ YYABORT;
}
| VAR_IDENTIFIER
{
@@ -1908,8 +1918,9 @@ primary_expr: C_FLOAT
}
if ((deref = new_var_deref(var)))
{
- $$ = &deref->node;
- set_location(&$$->loc, &@1);
+ set_location(&deref->node.loc, &@1);
+ if (!($$ = make_list(&deref->node)))
+ YYABORT;
}
else
$$ = NULL;
@@ -1926,43 +1937,48 @@ postfix_expr: primary_expr
| postfix_expr OP_INC
{
struct source_location loc;
+ struct hlsl_ir_node *inc;
set_location(&loc, &@2);
- if ($1->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_POSTINC, $1, loc);
+ inc = new_unary_expr(HLSL_IR_UNOP_POSTINC, node_from_list($1), loc);
/* Post increment/decrement expressions are considered const */
- $$->data_type = clone_hlsl_type($$->data_type);
- $$->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ inc->data_type = clone_hlsl_type(inc->data_type);
+ inc->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ $$ = append_unop($1, inc);
}
| postfix_expr OP_DEC
{
struct source_location loc;
+ struct hlsl_ir_node *inc;
set_location(&loc, &@2);
- if ($1->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_POSTDEC, $1, loc);
+ inc = new_unary_expr(HLSL_IR_UNOP_POSTDEC, node_from_list($1), loc);
/* Post increment/decrement expressions are considered const */
- $$->data_type = clone_hlsl_type($$->data_type);
- $$->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ inc->data_type = clone_hlsl_type(inc->data_type);
+ inc->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ $$ = append_unop($1, inc);
}
| postfix_expr '.' any_identifier
{
+ struct hlsl_ir_node *node = node_from_list($1);
struct source_location loc;
set_location(&loc, &@2);
- if ($1->data_type->type == HLSL_CLASS_STRUCT)
+ if (node->data_type->type == HLSL_CLASS_STRUCT)
{
- struct hlsl_type *type = $1->data_type;
+ struct hlsl_type *type = node->data_type;
struct hlsl_struct_field *field;
$$ = NULL;
@@ -1970,7 +1986,7 @@ postfix_expr: primary_expr
{
if (!strcmp($3, field->name))
{
- struct hlsl_ir_deref *deref = new_record_deref($1, field);
+ struct hlsl_ir_deref *deref = new_record_deref(node, field);
if (!deref)
{
@@ -1978,7 +1994,7 @@ postfix_expr: primary_expr
YYABORT;
}
deref->node.loc = loc;
- $$ = &deref->node;
+ $$ = append_unop($1, &deref->node);
break;
}
}
@@ -1989,18 +2005,18 @@ postfix_expr: primary_expr
YYABORT;
}
}
- else if ($1->data_type->type <= HLSL_CLASS_LAST_NUMERIC)
+ else if (node->data_type->type <= HLSL_CLASS_LAST_NUMERIC)
{
struct hlsl_ir_swizzle *swizzle;
- swizzle = get_swizzle($1, $3, &loc);
+ swizzle = get_swizzle(node, $3, &loc);
if (!swizzle)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"invalid swizzle %s", debugstr_a($3));
YYABORT;
}
- $$ = &swizzle->node;
+ $$ = append_unop($1, &swizzle->node);
}
else
{
@@ -2015,7 +2031,7 @@ postfix_expr: primary_expr
* subcomponent access.
* We store it as an array dereference in any case. */
struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref));
- struct hlsl_type *expr_type = $1->data_type;
+ struct hlsl_type *expr_type = node_from_list($1)->data_type;
struct source_location loc;
TRACE("Array dereference from type %s\n", debug_hlsl_type(expr_type));
@@ -2048,24 +2064,24 @@ postfix_expr: primary_expr
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"expression is not array-indexable");
d3dcompiler_free(deref);
- free_instr($1);
- free_instr($3);
+ free_instr_list($1);
+ free_instr_list($3);
YYABORT;
}
- if ($3->data_type->type != HLSL_CLASS_SCALAR)
+ if (node_from_list($3)->data_type->type != HLSL_CLASS_SCALAR)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"array index is not scalar");
d3dcompiler_free(deref);
- free_instr($1);
- free_instr($3);
+ free_instr_list($1);
+ free_instr_list($3);
YYABORT;
}
deref->type = HLSL_IR_DEREF_ARRAY;
- deref->v.array.array = $1;
- deref->v.array.index = $3;
+ deref->v.array.array = node_from_list($1);
+ deref->v.array.index = node_from_list($3);
- $$ = &deref->node;
+ $$ = append_binop($1, $3, &deref->node);
}
/* "var_modifiers" doesn't make sense in this case, but it's needed
in the grammar to avoid shift/reduce conflicts. */
@@ -2104,7 +2120,7 @@ postfix_expr: primary_expr
constructor->args_count = $4.args_count;
memcpy(constructor->args, $4.args, $4.args_count * sizeof(*$4.args));
d3dcompiler_free($4.args);
- $$ = &constructor->node;
+ $$ = append_unop($4.instrs, &constructor->node);
}
unary_expr: postfix_expr
@@ -2116,26 +2132,26 @@ unary_expr: postfix_expr
struct source_location loc;
set_location(&loc, &@1);
- if ($2->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_PREINC, $2, loc);
+ $$ = append_unop($2, new_unary_expr(HLSL_IR_UNOP_PREINC, node_from_list($2), loc));
}
| OP_DEC unary_expr
{
struct source_location loc;
set_location(&loc, &@1);
- if ($2->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_PREDEC, $2, loc);
+ $$ = append_unop($2, new_unary_expr(HLSL_IR_UNOP_PREDEC, node_from_list($2), loc));
}
| unary_op unary_expr
{
@@ -2150,14 +2166,13 @@ unary_expr: postfix_expr
else
{
set_location(&loc, &@1);
- $$ = new_unary_expr(ops[$1], $2, loc);
+ $$ = append_unop($2, new_unary_expr(ops[$1], node_from_list($2), loc));
}
}
/* var_modifiers just to avoid shift/reduce conflicts */
| '(' var_modifiers type array ')' unary_expr
{
- struct hlsl_ir_expr *expr;
- struct hlsl_type *src_type = $6->data_type;
+ struct hlsl_type *src_type = node_from_list($6)->data_type;
struct hlsl_type *dst_type;
struct source_location loc;
@@ -2182,8 +2197,7 @@ unary_expr: postfix_expr
YYABORT;
}
- expr = new_cast($6, dst_type, &loc);
- $$ = expr ? &expr->node : NULL;
+ $$ = append_unop($6, &new_cast(node_from_list($6), dst_type, &loc)->node);
}
unary_op: '+'
@@ -2212,21 +2226,21 @@ mul_expr: unary_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_MUL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MUL, node_from_list($1), node_from_list($3), loc));
}
| mul_expr '/' unary_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_DIV, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_DIV, node_from_list($1), node_from_list($3), loc));
}
| mul_expr '%' unary_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_MOD, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MOD, node_from_list($1), node_from_list($3), loc));
}
add_expr: mul_expr
@@ -2238,14 +2252,14 @@ add_expr: mul_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_ADD, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_ADD, node_from_list($1), node_from_list($3), loc));
}
| add_expr '-' mul_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_SUB, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_SUB, node_from_list($1), node_from_list($3), loc));
}
shift_expr: add_expr
@@ -2270,28 +2284,28 @@ relational_expr: shift_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_LESS, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LESS, node_from_list($1), node_from_list($3), loc));
}
| relational_expr '>' shift_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_GREATER, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GREATER, node_from_list($1), node_from_list($3), loc));
}
| relational_expr OP_LE shift_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_LEQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LEQUAL, node_from_list($1), node_from_list($3), loc));
}
| relational_expr OP_GE shift_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_GEQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GEQUAL, node_from_list($1), node_from_list($3), loc));
}
equality_expr: relational_expr
@@ -2303,14 +2317,14 @@ equality_expr: relational_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_EQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_EQUAL, node_from_list($1), node_from_list($3), loc));
}
| equality_expr OP_NE relational_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_NEQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_NEQUAL, node_from_list($1), node_from_list($3), loc));
}
bitand_expr: equality_expr
@@ -2374,18 +2388,20 @@ assignment_expr: conditional_expr
| unary_expr assign_op assignment_expr
{
struct source_location loc;
+ struct hlsl_ir_node *instr;
set_location(&loc, &@2);
- if ($1->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"l-value is const");
YYABORT;
}
- $$ = make_assignment($1, $2, BWRITERSP_WRITEMASK_ALL, $3);
- if (!$$)
+ if (!(instr = make_assignment(node_from_list($1), $2,
+ BWRITERSP_WRITEMASK_ALL, node_from_list($3))))
YYABORT;
- $$->loc = loc;
+ instr->loc = loc;
+ $$ = append_binop($3, $1, instr);
}
assign_op: '='
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 0cae62b60fc..3f5a57ffa40 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1278,10 +1278,14 @@ static struct hlsl_type *expr_common_type(struct hlsl_type *t1, struct hlsl_type
static struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type,
struct source_location *loc)
{
+ struct hlsl_ir_expr *cast;
+
if (compare_hlsl_types(node->data_type, type))
return node;
TRACE("Implicit conversion of expression to %s\n", debug_hlsl_type(type));
- return &new_cast(node, type, loc)->node;
+ if ((cast = new_cast(node, type, loc)))
+ list_add_after(&node->entry, &cast->node.entry);
+ return &cast->node;
}
struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands,
@@ -1468,8 +1472,6 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
hlsl_report_message(rhs->loc.file, rhs->loc.line, rhs->loc.col, HLSL_LEVEL_ERROR,
"can't implicitly convert %s to %s",
debug_hlsl_type(rhs->data_type), debug_hlsl_type(type));
- free_instr(lhs);
- free_instr(rhs);
d3dcompiler_free(assign);
return NULL;
}
@@ -1481,8 +1483,6 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
if (!converted_rhs)
{
ERR("Couldn't implicitly convert expression to %s.\n", debug_hlsl_type(type));
- free_instr(lhs);
- free_instr(rhs);
d3dcompiler_free(assign);
return NULL;
}
@@ -1502,11 +1502,9 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
}
else
{
- struct hlsl_ir_deref *lhs_deref = deref_from_node(lhs), *new_deref;
-
TRACE("Adding an expression for the compound assignment.\n");
- new_deref = new_var_deref(lhs_deref->v.var);
- expr = new_binary_expr(op, &new_deref->node, rhs, left->loc);
+ expr = new_binary_expr(op, lhs, rhs, lhs->loc);
+ list_add_after(&rhs->entry, &expr->entry);
assign->rhs = expr;
}
}
@@ -2173,60 +2171,32 @@ static void free_ir_constant(struct hlsl_ir_constant *constant)
static void free_ir_deref(struct hlsl_ir_deref *deref)
{
- switch (deref->type)
- {
- case HLSL_IR_DEREF_VAR:
- /* Variables are shared among nodes in the tree. */
- break;
- case HLSL_IR_DEREF_ARRAY:
- free_instr(deref->v.array.array);
- free_instr(deref->v.array.index);
- break;
- case HLSL_IR_DEREF_RECORD:
- free_instr(deref->v.record.record);
- break;
- }
d3dcompiler_free(deref);
}
static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
{
- free_instr(swizzle->val);
d3dcompiler_free(swizzle);
}
static void free_ir_constructor(struct hlsl_ir_constructor *constructor)
{
- unsigned int i;
- for (i = 0; i < constructor->args_count; ++i)
- free_instr(constructor->args[i]);
d3dcompiler_free(constructor);
}
static void free_ir_expr(struct hlsl_ir_expr *expr)
{
- unsigned int i;
-
- for (i = 0; i < 3; ++i)
- {
- if (!expr->operands[i])
- break;
- free_instr(expr->operands[i]);
- }
free_instr_list(expr->subexpressions);
d3dcompiler_free(expr);
}
static void free_ir_assignment(struct hlsl_ir_assignment *assignment)
{
- free_instr(assignment->lhs);
- free_instr(assignment->rhs);
d3dcompiler_free(assignment);
}
static void free_ir_if(struct hlsl_ir_if *if_node)
{
- free_instr(if_node->condition);
free_instr_list(if_node->then_instrs);
free_instr_list(if_node->else_instrs);
d3dcompiler_free(if_node);
@@ -2234,8 +2204,6 @@ static void free_ir_if(struct hlsl_ir_if *if_node)
static void free_ir_jump(struct hlsl_ir_jump *jump)
{
- if (jump->type == HLSL_IR_JUMP_RETURN)
- free_instr(jump->return_value);
d3dcompiler_free(jump);
}
--
2.25.0
4
3
[PATCH 5/5] d3d9/tests: Do not use NVIDIA mode in test_alpha_to_coverage() if the reported GPU is AMD.
by Henri Verbeet 18 Feb '20
by Henri Verbeet 18 Feb '20
18 Feb '20
From: Paul Gofman <gofmanp(a)gmail.com>
Otherwise, if Wine exposes the ATOC format the test will always trigger the
NVIDIA path regardless of the reported GPU.
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/d3d9/tests/visual.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 7379d5db5a1..cb84ef6f284 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -26591,19 +26591,20 @@ static void test_alpha_to_coverage(void)
return;
}
- if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0,
- D3DRTYPE_SURFACE, MAKEFOURCC('A','T','O','C')) == D3D_OK)
+
+ hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ if (adapter_is_amd(&identifier))
{
- /* ATOC pseudo format is introduced by Nvidia. Some Intel GPUs support
- * alpha to coverage the same way as Nvidia. */
- nvidia_mode = TRUE;
+ nvidia_mode = FALSE;
}
else
{
- nvidia_mode = FALSE;
- hr = IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
- ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- if (!adapter_is_amd(&identifier))
+ /* The ATOC pseudo format is introduced by NVIDIA. Some Intel GPUs
+ * support alpha to coverage the same way as NVIDIA. */
+ if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0,
+ D3DRTYPE_SURFACE, MAKEFOURCC('A','T','O','C')) != D3D_OK)
{
win_skip("Alpha to coverage is not supported.\n");
refcount = IDirect3DDevice9_Release(device);
@@ -26612,6 +26613,7 @@ static void test_alpha_to_coverage(void)
DestroyWindow(window);
return;
}
+ nvidia_mode = TRUE;
}
hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
--
2.20.1
1
0
18 Feb '20
From: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/d3d9/tests/visual.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 8db30467ee5..7379d5db5a1 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -26560,6 +26560,7 @@ static void test_alpha_to_coverage(void)
D3DADAPTER_IDENTIFIER9 identifier;
struct surface_readback rb;
IDirect3DTexture9 *texture;
+ IDirect3DStateBlock9 *sb;
IDirect3DDevice9 *device;
DWORD quality_levels;
BOOL nvidia_mode;
@@ -26669,6 +26670,9 @@ static void test_alpha_to_coverage(void)
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
}
+ hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_VERTEXSTATE, &sb);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
fill_surface(surface, 0x40608000, 0);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
@@ -26705,6 +26709,23 @@ static void test_alpha_to_coverage(void)
ok(colour == 0x40608000, "Got unexpected colour %08x.\n", colour);
release_surface_readback(&rb);
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff2000ff, 0.0f, 0);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ IDirect3DStateBlock9_Apply(sb);
+ IDirect3DStateBlock9_Release(sb);
+
+ hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, D3DTEXF_POINT);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ get_rt_readback(rt, &rb);
+ colour = get_readback_color(&rb, 64, 64);
+ ok(color_match(colour, 0x9f404080, 1) || color_match(colour, 0x9f485cbc, 1) /* Nvidia */,
+ "Got unexpected colour %08x.\n", colour);
+ release_surface_readback(&rb);
+
hr = IDirect3DDevice9_EndScene(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
--
2.20.1
1
0
From: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/d3d9/tests/visual.c | 2 +-
dlls/wined3d/device.c | 11 ++++++++---
dlls/wined3d/stateblock.c | 17 +++++++++++------
dlls/wined3d/utils.c | 10 ++++++++++
include/wine/wined3d.h | 1 +
5 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 3151efaf330..8db30467ee5 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -26604,7 +26604,7 @@ static void test_alpha_to_coverage(void)
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
if (!adapter_is_amd(&identifier))
{
- skip("Alpha to coverage is not supported.\n");
+ win_skip("Alpha to coverage is not supported.\n");
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1e6ec5d0981..17d71b3b1a3 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3842,6 +3842,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
struct wined3d_blend_state *blend_state;
struct wined3d_color colour;
unsigned int i, j, count;
+ BOOL set_blend_state;
TRACE("device %p, stateblock %p.\n", device, stateblock);
@@ -3945,14 +3946,18 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
}
}
- if (changed->blend_state)
+ if ((set_blend_state = changed->blend_state
+ || wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_ADAPTIVETESS_Y)))
{
+ blend_state = state->rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC
+ ? device->blend_state_atoc_enabled : state->blend_state;
+
if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR))
wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[WINED3D_RS_BLENDFACTOR]);
else
wined3d_device_get_blend_state(device, &colour);
- wined3d_device_set_blend_state(device, state->blend_state, &colour);
+ wined3d_device_set_blend_state(device, blend_state, &colour);
}
for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
@@ -3966,7 +3971,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
continue;
}
- if (!changed->blend_state)
+ if (!set_blend_state)
{
blend_state = wined3d_device_get_blend_state(device, &colour);
wined3d_color_from_d3dcolor(&colour, state->rs[i]);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 71d88bf1949..a09c020f3f7 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1052,6 +1052,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
struct wined3d_device *device = stateblock->device;
struct wined3d_blend_state *blend_state;
struct wined3d_color colour;
+ BOOL set_blend_state;
unsigned int i;
DWORD map;
@@ -1140,21 +1141,25 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
wined3d_device_set_ps_consts_b(device, idx, 1, &stateblock->stateblock_state.ps_consts_b[idx]);
}
- if (stateblock->changed.blend_state)
+ if ((set_blend_state = stateblock->changed.blend_state
+ || wined3d_bitmap_is_set(stateblock->changed.renderState, WINED3D_RS_ADAPTIVETESS_Y)))
{
- if (stateblock->stateblock_state.blend_state)
- wined3d_blend_state_incref(stateblock->stateblock_state.blend_state);
+ blend_state = stateblock->stateblock_state.rs[WINED3D_RS_ADAPTIVETESS_Y] == WINED3DFMT_ATOC
+ ? device->blend_state_atoc_enabled : stateblock->stateblock_state.blend_state;
+
+ if (blend_state)
+ wined3d_blend_state_incref(blend_state);
if (state->blend_state)
wined3d_blend_state_decref(state->blend_state);
- state->blend_state = stateblock->stateblock_state.blend_state;
+ state->blend_state = blend_state;
if (wined3d_bitmap_is_set(stateblock->changed.renderState, WINED3D_RS_BLENDFACTOR))
wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[WINED3D_RS_BLENDFACTOR]);
else
wined3d_device_get_blend_state(device, &colour);
- wined3d_device_set_blend_state(device, stateblock->stateblock_state.blend_state, &colour);
+ wined3d_device_set_blend_state(device, blend_state, &colour);
}
/* Render states. */
@@ -1169,7 +1174,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
continue;
}
- if (!stateblock->changed.blend_state)
+ if (!set_blend_state)
{
blend_state = wined3d_device_get_blend_state(device, &colour);
wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[rs]);
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index bd239d7659f..f696b922140 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -65,6 +65,7 @@ format_index_remap[] =
{WINED3DFMT_R16, WINED3D_FORMAT_FOURCC_BASE + 20},
{WINED3DFMT_AL16, WINED3D_FORMAT_FOURCC_BASE + 21},
{WINED3DFMT_NV12, WINED3D_FORMAT_FOURCC_BASE + 22},
+ {WINED3DFMT_ATOC, WINED3D_FORMAT_FOURCC_BASE + 23},
};
#define WINED3D_FORMAT_COUNT (WINED3D_FORMAT_FOURCC_BASE + ARRAY_SIZE(format_index_remap))
@@ -135,6 +136,7 @@ static const struct wined3d_format_channels formats[] =
{WINED3DFMT_ATI1N, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_ATI2N, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_NVDB, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {WINED3DFMT_ATOC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{WINED3DFMT_INST, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{WINED3DFMT_INTZ, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 8},
{WINED3DFMT_RESZ, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -339,6 +341,7 @@ static const struct wined3d_format_base_flags format_base_flags[] =
{WINED3DFMT_INST, WINED3DFMT_FLAG_EXTENSION},
{WINED3DFMT_NULL, WINED3DFMT_FLAG_EXTENSION},
{WINED3DFMT_NVDB, WINED3DFMT_FLAG_EXTENSION},
+ {WINED3DFMT_ATOC, WINED3DFMT_FLAG_EXTENSION},
{WINED3DFMT_RESZ, WINED3DFMT_FLAG_EXTENSION},
};
@@ -3673,6 +3676,12 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
format_set_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
}
+ if (gl_info->supported[ARB_MULTISAMPLE])
+ {
+ format = get_format_gl_internal(adapter, WINED3DFMT_ATOC);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
+ }
+
/* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
* support by checking for availability of MAKEFOURCC('R','E','S','Z') surfaces with
* RENDERTARGET usage. */
@@ -4591,6 +4600,7 @@ const char *debug_d3dformat(enum wined3d_format_id format_id)
FMT_TO_STR(WINED3DFMT_R16);
FMT_TO_STR(WINED3DFMT_AL16);
FMT_TO_STR(WINED3DFMT_NV12);
+ FMT_TO_STR(WINED3DFMT_ATOC);
#undef FMT_TO_STR
default:
{
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d783e64a26d..734380b0adc 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -269,6 +269,7 @@ enum wined3d_format_id
WINED3DFMT_NV12 = WINEMAKEFOURCC('N','V','1','2'),
WINED3DFMT_DF16 = WINEMAKEFOURCC('D','F','1','6'),
WINED3DFMT_DF24 = WINEMAKEFOURCC('D','F','2','4'),
+ WINED3DFMT_ATOC = WINEMAKEFOURCC('A','T','O','C'),
WINED3DFMT_FORCE_DWORD = 0xffffffff
};
--
2.20.1
1
0
From: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/d3d9/tests/visual.c | 4 +-
dlls/wined3d/device.c | 49 ++++++++++++++++++----
dlls/wined3d/stateblock.c | 77 +++++++++++++++++++++++++++++++---
dlls/wined3d/wined3d_private.h | 7 +++-
include/wine/wined3d.h | 1 +
5 files changed, 120 insertions(+), 18 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 366862a05aa..3151efaf330 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -26679,8 +26679,8 @@ static void test_alpha_to_coverage(void)
get_rt_readback(rt, &rb);
colour = get_readback_color(&rb, 64, 64);
- /* Nvidia is probably using some proprietary algorithm for averaging sample colour values. */
- todo_wine ok(color_match(colour, 0x9f404080, 1) || color_match(colour, 0x9f485cbc, 1) /* Nvidia */,
+ /* NVIDIA is probably using some proprietary algorithm for averaging sample colour values. */
+ ok(color_match(colour, 0x9f404080, 1) || color_match(colour, 0x9f485cbc, 1) /* NVIDIA */,
"Got unexpected colour %08x.\n", colour);
release_surface_readback(&rb);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d709ca189c2..1e6ec5d0981 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -529,6 +529,8 @@ void wined3d_device_cleanup(struct wined3d_device *device)
if (device->swapchain_count)
wined3d_device_uninit_3d(device);
+ wined3d_blend_state_decref(device->blend_state_atoc_enabled);
+
wined3d_cs_destroy(device->cs);
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
@@ -3837,6 +3839,8 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
const struct wined3d_stateblock_state *state = &stateblock->stateblock_state;
const struct wined3d_saved_states *changed = &stateblock->changed;
+ struct wined3d_blend_state *blend_state;
+ struct wined3d_color colour;
unsigned int i, j, count;
TRACE("device %p, stateblock %p.\n", device, stateblock);
@@ -3941,18 +3945,32 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
}
}
+ if (changed->blend_state)
+ {
+ if (wined3d_bitmap_is_set(changed->renderState, WINED3D_RS_BLENDFACTOR))
+ wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[WINED3D_RS_BLENDFACTOR]);
+ else
+ wined3d_device_get_blend_state(device, &colour);
+
+ wined3d_device_set_blend_state(device, state->blend_state, &colour);
+ }
+
for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
{
- if (wined3d_bitmap_is_set(changed->renderState, i))
+ if (!wined3d_bitmap_is_set(changed->renderState, i))
+ continue;
+
+ if (i != WINED3D_RS_BLENDFACTOR)
{
- if (i == WINED3D_RS_BLENDFACTOR)
- {
- struct wined3d_color color;
- wined3d_color_from_d3dcolor(&color, state->rs[i]);
- wined3d_device_set_blend_state(device, NULL, &color);
- }
- else
- wined3d_device_set_render_state(device, i, state->rs[i]);
+ wined3d_device_set_render_state(device, i, state->rs[i]);
+ continue;
+ }
+
+ if (!changed->blend_state)
+ {
+ blend_state = wined3d_device_get_blend_state(device, &colour);
+ wined3d_color_from_d3dcolor(&colour, state->rs[i]);
+ wined3d_device_set_blend_state(device, blend_state, &colour);
}
}
@@ -5760,6 +5778,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_blend_state_desc blend_state_desc;
unsigned int i;
HRESULT hr;
@@ -5814,6 +5833,18 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
goto err;
}
+ memset(&blend_state_desc, 0, sizeof(blend_state_desc));
+ blend_state_desc.alpha_to_coverage = TRUE;
+
+ if (FAILED(hr = wined3d_blend_state_create(device, &blend_state_desc,
+ NULL, &wined3d_null_parent_ops, &device->blend_state_atoc_enabled)))
+ {
+ ERR("Failed to create blend state object, hr %#x.\n", hr);
+ wined3d_cs_destroy(device->cs);
+ state_cleanup(&device->state);
+ goto err;
+ }
+
return WINED3D_OK;
err:
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 499d23fbbd3..71d88bf1949 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -209,6 +209,7 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states,
states->pixelShader = 1;
states->vertexShader = 1;
states->scissorRect = 1;
+ states->blend_state = 1;
/* Fixed size arrays */
states->streamSource = 0xffff;
@@ -263,6 +264,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
states->vertexDecl = 1;
states->vertexShader = 1;
+ states->blend_state = 1;
for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i)
{
@@ -426,6 +428,7 @@ void state_unbind_resources(struct wined3d_state *state)
struct wined3d_unordered_access_view *uav;
struct wined3d_shader_resource_view *srv;
struct wined3d_vertex_declaration *decl;
+ struct wined3d_blend_state *blend_state;
struct wined3d_sampler *sampler;
struct wined3d_texture *texture;
struct wined3d_buffer *buffer;
@@ -519,12 +522,19 @@ void state_unbind_resources(struct wined3d_state *state)
}
}
}
+
+ if ((blend_state = state->blend_state))
+ {
+ state->blend_state = NULL;
+ wined3d_blend_state_decref(blend_state);
+ }
}
void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
{
struct wined3d_light_info *light, *cursor;
struct wined3d_vertex_declaration *decl;
+ struct wined3d_blend_state *blend_state;
struct wined3d_texture *texture;
struct wined3d_buffer *buffer;
struct wined3d_shader *shader;
@@ -580,6 +590,12 @@ void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
heap_free(light);
}
}
+
+ if ((blend_state = state->blend_state))
+ {
+ state->blend_state = NULL;
+ wined3d_blend_state_decref(blend_state);
+ }
}
void state_cleanup(struct wined3d_state *state)
@@ -1017,6 +1033,15 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
wined3d_state_record_lights(stateblock->stateblock_state.light_state, state->light_state);
+ if (stateblock->changed.blend_state && stateblock->stateblock_state.blend_state != state->blend_state)
+ {
+ if (state->blend_state)
+ wined3d_blend_state_incref(state->blend_state);
+ if (stateblock->stateblock_state.blend_state)
+ wined3d_blend_state_decref(stateblock->stateblock_state.blend_state);
+ stateblock->stateblock_state.blend_state = state->blend_state;
+ }
+
TRACE("Capture done.\n");
}
@@ -1025,6 +1050,8 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
{
struct wined3d_stateblock_state *state = &device_state->stateblock_state;
struct wined3d_device *device = stateblock->device;
+ struct wined3d_blend_state *blend_state;
+ struct wined3d_color colour;
unsigned int i;
DWORD map;
@@ -1113,20 +1140,41 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
wined3d_device_set_ps_consts_b(device, idx, 1, &stateblock->stateblock_state.ps_consts_b[idx]);
}
+ if (stateblock->changed.blend_state)
+ {
+ if (stateblock->stateblock_state.blend_state)
+ wined3d_blend_state_incref(stateblock->stateblock_state.blend_state);
+ if (state->blend_state)
+ wined3d_blend_state_decref(state->blend_state);
+
+ state->blend_state = stateblock->stateblock_state.blend_state;
+
+ if (wined3d_bitmap_is_set(stateblock->changed.renderState, WINED3D_RS_BLENDFACTOR))
+ wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[WINED3D_RS_BLENDFACTOR]);
+ else
+ wined3d_device_get_blend_state(device, &colour);
+
+ wined3d_device_set_blend_state(device, stateblock->stateblock_state.blend_state, &colour);
+ }
+
/* Render states. */
for (i = 0; i < stateblock->num_contained_render_states; ++i)
{
enum wined3d_render_state rs = stateblock->contained_render_states[i];
state->rs[rs] = stateblock->stateblock_state.rs[rs];
- if (rs == WINED3D_RS_BLENDFACTOR)
+ if (rs != WINED3D_RS_BLENDFACTOR)
{
- struct wined3d_color color;
- wined3d_color_from_d3dcolor(&color, stateblock->stateblock_state.rs[rs]);
- wined3d_device_set_blend_state(device, NULL, &color);
- }
- else
wined3d_device_set_render_state(device, rs, stateblock->stateblock_state.rs[rs]);
+ continue;
+ }
+
+ if (!stateblock->changed.blend_state)
+ {
+ blend_state = wined3d_device_get_blend_state(device, &colour);
+ wined3d_color_from_d3dcolor(&colour, stateblock->stateblock_state.rs[rs]);
+ wined3d_device_set_blend_state(device, blend_state, &colour);
+ }
}
/* Texture states. */
@@ -1426,6 +1474,23 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb
stateblock->stateblock_state.rs[state] = value;
stateblock->changed.renderState[state >> 5] |= 1u << (state & 0x1f);
+
+ if (state == WINED3D_RS_POINTSIZE
+ && (value == WINED3D_ALPHA_TO_COVERAGE_ENABLE || value == WINED3D_ALPHA_TO_COVERAGE_DISABLE))
+ {
+ stateblock->changed.blend_state = 1;
+
+ if (value == WINED3D_ALPHA_TO_COVERAGE_ENABLE && !stateblock->stateblock_state.blend_state)
+ {
+ wined3d_blend_state_incref(stateblock->device->blend_state_atoc_enabled);
+ stateblock->stateblock_state.blend_state = stateblock->device->blend_state_atoc_enabled;
+ }
+ else if (value == WINED3D_ALPHA_TO_COVERAGE_DISABLE && stateblock->stateblock_state.blend_state)
+ {
+ wined3d_blend_state_decref(stateblock->stateblock_state.blend_state);
+ stateblock->stateblock_state.blend_state = NULL;
+ }
+ }
}
void CDECL wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *stateblock,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 92634b71551..d29dfc312b2 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -76,6 +76,9 @@
#define WINED3D_MAX_DIRTY_REGION_COUNT 7
+#define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
+#define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
+
struct wined3d_fragment_pipe_ops;
struct wined3d_adapter;
struct wined3d_context;
@@ -3314,6 +3317,7 @@ struct wined3d_device
/* Context management */
struct wined3d_context **contexts;
UINT context_count;
+ struct wined3d_blend_state *blend_state_atoc_enabled;
};
void wined3d_device_cleanup(struct wined3d_device *device) DECLSPEC_HIDDEN;
@@ -3932,7 +3936,8 @@ struct wined3d_saved_states
DWORD vertexShader : 1;
DWORD scissorRect : 1;
DWORD store_stream_offset : 1;
- DWORD padding : 4;
+ DWORD blend_state : 1;
+ DWORD padding : 3;
};
struct StageState {
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d313c7aec86..d783e64a26d 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2168,6 +2168,7 @@ struct wined3d_stateblock_state
RECT scissor_rect;
struct wined3d_light_state *light_state;
+ struct wined3d_blend_state *blend_state;
};
struct wined3d_parent_ops
--
2.20.1
1
0
From: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/arb_program_shader.c | 4 +--
dlls/wined3d/device.c | 43 ++++++++++++++++---------------
dlls/wined3d/wined3d_private.h | 5 ++++
3 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 14ca883e761..c39694f441e 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -807,9 +807,7 @@ static void shader_generate_arb_declarations(const struct wined3d_shader *shader
for (i = 0; i < shader->limits->constant_float; ++i)
{
- DWORD idx = i >> 5;
- DWORD shift = i & 0x1f;
- if (reg_maps->constf[idx] & (1u << shift))
+ if (wined3d_bitmap_is_set(reg_maps->constf, i))
highest_constf = i;
}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 84056437414..d709ca189c2 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3836,19 +3836,20 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
{
const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
const struct wined3d_stateblock_state *state = &stateblock->stateblock_state;
+ const struct wined3d_saved_states *changed = &stateblock->changed;
unsigned int i, j, count;
TRACE("device %p, stateblock %p.\n", device, stateblock);
- if (stateblock->changed.vertexShader)
+ if (changed->vertexShader)
wined3d_device_set_vertex_shader(device, state->vs);
- if (stateblock->changed.pixelShader)
+ if (changed->pixelShader)
wined3d_device_set_pixel_shader(device, state->ps);
count = 0;
for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
{
- if (stateblock->changed.vs_consts_f[i])
+ if (changed->vs_consts_f[i])
++count;
else if (count)
{
@@ -3862,7 +3863,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
count = 0;
for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
{
- if (stateblock->changed.vertexShaderConstantsB & (1u << i))
+ if (changed->vertexShaderConstantsB & (1u << i))
++count;
else if (count)
{
@@ -3876,7 +3877,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
count = 0;
for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
{
- if (stateblock->changed.vertexShaderConstantsI & (1u << i))
+ if (changed->vertexShaderConstantsI & (1u << i))
++count;
else if (count)
{
@@ -3890,7 +3891,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
count = 0;
for (i = 0; i < d3d_info->limits.ps_uniform_count; ++i)
{
- if (stateblock->changed.ps_consts_f[i])
+ if (changed->ps_consts_f[i])
++count;
else if (count)
{
@@ -3904,7 +3905,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
count = 0;
for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
{
- if (stateblock->changed.pixelShaderConstantsB & (1u << i))
+ if (changed->pixelShaderConstantsB & (1u << i))
++count;
else if (count)
{
@@ -3918,7 +3919,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
count = 0;
for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
{
- if (stateblock->changed.pixelShaderConstantsI & (1u << i))
+ if (changed->pixelShaderConstantsI & (1u << i))
++count;
else if (count)
{
@@ -3942,7 +3943,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
{
- if (stateblock->changed.renderState[i >> 5] & (1u << (i & 0x1f)))
+ if (wined3d_bitmap_is_set(changed->renderState, i))
{
if (i == WINED3D_RS_BLENDFACTOR)
{
@@ -3959,7 +3960,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
{
for (j = 0; j < ARRAY_SIZE(state->texture_states[i]); ++j)
{
- if (stateblock->changed.textureState[i] & (1u << j))
+ if (changed->textureState[i] & (1u << j))
wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]);
}
}
@@ -3971,35 +3972,35 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
for (j = 0; j < ARRAY_SIZE(state->sampler_states[j]); ++j)
{
- if (stateblock->changed.samplerState[i] & (1 << j))
+ if (changed->samplerState[i] & (1 << j))
wined3d_device_set_sampler_state(device, stage, j, state->sampler_states[i][j]);
}
}
for (i = 0; i < ARRAY_SIZE(state->transforms); ++i)
{
- if (stateblock->changed.transform[i >> 5] & (1u << (i & 0x1f)))
+ if (wined3d_bitmap_is_set(changed->transform, i))
wined3d_device_set_transform(device, i, &state->transforms[i]);
}
- if (stateblock->changed.indices)
+ if (changed->indices)
wined3d_device_set_index_buffer(device, state->index_buffer, state->index_format, 0);
wined3d_device_set_base_vertex_index(device, state->base_vertex_index);
- if (stateblock->changed.vertexDecl)
+ if (changed->vertexDecl)
wined3d_device_set_vertex_declaration(device, state->vertex_declaration);
- if (stateblock->changed.material)
+ if (changed->material)
wined3d_device_set_material(device, &state->material);
- if (stateblock->changed.viewport)
+ if (changed->viewport)
wined3d_device_set_viewports(device, 1, &state->viewport);
- if (stateblock->changed.scissorRect)
+ if (changed->scissorRect)
wined3d_device_set_scissor_rects(device, 1, &state->scissor_rect);
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
{
- if (stateblock->changed.streamSource & (1u << i))
+ if (changed->streamSource & (1u << i))
wined3d_device_set_stream_source(device, i, state->streams[i].buffer,
state->streams[i].offset, state->streams[i].stride);
- if (stateblock->changed.streamFreq & (1u << i))
+ if (changed->streamFreq & (1u << i))
wined3d_device_set_stream_source_freq(device, i,
state->streams[i].frequency | state->streams[i].flags);
}
@@ -4009,13 +4010,13 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
DWORD stage = i;
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
- if (stateblock->changed.textures & (1u << i))
+ if (changed->textures & (1u << i))
wined3d_device_set_texture(device, stage, state->textures[i]);
}
for (i = 0; i < ARRAY_SIZE(state->clip_planes); ++i)
{
- if (stateblock->changed.clipplane & (1u << i))
+ if (changed->clipplane & (1u << i))
wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0e1e55d52bf..92634b71551 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -5327,6 +5327,11 @@ static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *v
*max_z = max(vp->max_z, vp->min_z + 0.001f);
}
+static inline BOOL wined3d_bitmap_is_set(const uint32_t *map, unsigned int idx)
+{
+ return map[idx >> 5] & (1u << (idx & 0x1f));
+}
+
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
--
2.20.1
1
0
18 Feb '20
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/d3d9/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 447aa26844..802a974f34 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2208,7 +2208,7 @@ static HRESULT WINAPI d3d9_device_GetMaterial(IDirect3DDevice9Ex *iface, D3DMATE
/* Note: D3DMATERIAL9 is compatible with struct wined3d_material. */
wined3d_mutex_lock();
- wined3d_device_get_material(device->wined3d_device, (struct wined3d_material *)material);
+ memcpy(material, &wined3d_stateblock_get_state(device->state)->material, sizeof(*material));
wined3d_mutex_unlock();
return D3D_OK;
--
2.25.0
2
7