Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e2866d6f
Commit
e2866d6f
authored
May 08, 2012
by
Matteo Bruni
Committed by
Alexandre Julliard
May 08, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dcompiler: Generalize message reporting function.
parent
555f6349
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
50 deletions
+73
-50
asmshader.y
dlls/d3dcompiler_43/asmshader.y
+19
-46
d3dcompiler_private.h
dlls/d3dcompiler_43/d3dcompiler_private.h
+11
-4
utils.c
dlls/d3dcompiler_43/utils.c
+43
-0
No files found.
dlls/d3dcompiler_43/asmshader.y
View file @
e2866d6f
...
...
@@ -26,49 +26,17 @@
#include "d3dcompiler_private.h"
#include <stdio.h>
WINE_DEFAULT_DEBUG_CHANNEL(asmshader);
struct asm_parser asm_ctx;
/* Error reporting function */
void asmparser_message(struct asm_parser *ctx, const char *fmt, ...)
{
void asmparser_message(struct asm_parser *ctx, const char *fmt, ...)
{
va_list args;
char* newbuffer;
int rc, newsize;
if(ctx->messagecapacity == 0) {
ctx->messages = asm_alloc(MESSAGEBUFFER_INITIAL_SIZE);
if(ctx->messages == NULL) {
ERR("Error allocating memory for parser messages\n");
return;
}
ctx->messagecapacity = MESSAGEBUFFER_INITIAL_SIZE;
}
while(1) {
va_start(args, fmt);
rc = vsnprintf(ctx->messages + ctx->messagesize,
ctx->messagecapacity - ctx->messagesize, fmt, args);
va_end(args);
if (rc < 0 || /* C89 */
rc >= ctx->messagecapacity - ctx->messagesize) { /* C99 */
/* Resize the buffer */
newsize = ctx->messagecapacity * 2;
newbuffer = asm_realloc(ctx->messages, newsize);
if(newbuffer == NULL){
ERR("Error reallocating memory for parser messages\n");
return;
}
ctx->messages = newbuffer;
ctx->messagecapacity = newsize;
} else {
ctx->messagesize += rc;
return;
}
}
va_start(args, fmt);
compilation_message(&ctx->messages, fmt, args);
va_end(args);
}
static void asmshader_error(char const *s) {
...
...
@@ -1704,32 +1672,37 @@ predicate: '(' REG_PREDICATE swizzle ')'
%%
struct bwriter_shader *parse_asm_shader(char **messages) {
struct bwriter_shader *parse_asm_shader(char **messages)
{
struct bwriter_shader *ret = NULL;
asm_ctx.shader = NULL;
asm_ctx.status = PARSE_SUCCESS;
asm_ctx.messages
ize = asm_ctx.message
capacity = 0;
asm_ctx.messages
.size = asm_ctx.messages.
capacity = 0;
asm_ctx.line_no = 1;
asmshader_parse();
if(asm_ctx.status != PARSE_ERR) ret = asm_ctx.shader;
else if(asm_ctx.shader) SlDeleteShader(asm_ctx.shader);
if (asm_ctx.status != PARSE_ERR)
ret = asm_ctx.shader;
else if (asm_ctx.shader)
SlDeleteShader(asm_ctx.shader);
if(messages) {
if(asm_ctx.messagesize) {
if (messages)
{
if (asm_ctx.messages.size)
{
/* Shrink the buffer to the used size */
*messages = asm_realloc(asm_ctx.messages
, asm_ctx.message
size + 1);
*messages = asm_realloc(asm_ctx.messages
.string, asm_ctx.messages.
size + 1);
if(!*messages) {
ERR("Out of memory, no messages reported\n");
asm_free(asm_ctx.messages);
asm_free(asm_ctx.messages
.string
);
}
} else {
*messages = NULL;
}
} else {
if(asm_ctx.message
capacity) asm_free(asm_ctx.messages
);
if(asm_ctx.message
s.capacity) asm_free(asm_ctx.messages.string
);
}
return ret;
...
...
dlls/d3dcompiler_43/d3dcompiler_private.h
View file @
e2866d6f
...
...
@@ -216,7 +216,15 @@ enum parse_status
PARSE_ERR
=
2
};
struct
asm_parser
{
struct
compilation_messages
{
char
*
string
;
unsigned
int
size
;
unsigned
int
capacity
;
};
struct
asm_parser
{
/* The function table of the parser implementation */
const
struct
asmparser_backend
*
funcs
;
...
...
@@ -225,9 +233,7 @@ struct asm_parser {
unsigned
int
m3x3pad_count
;
enum
parse_status
status
;
char
*
messages
;
unsigned
int
messagesize
;
unsigned
int
messagecapacity
;
struct
compilation_messages
messages
;
unsigned
int
line_no
;
};
...
...
@@ -255,6 +261,7 @@ struct bwriter_shader *parse_asm_shader(char **messages) DECLSPEC_HIDDEN;
#define PRINTF_ATTR(fmt,args)
#endif
void
compilation_message
(
struct
compilation_messages
*
msg
,
const
char
*
fmt
,
va_list
args
)
DECLSPEC_HIDDEN
;
void
asmparser_message
(
struct
asm_parser
*
ctx
,
const
char
*
fmt
,
...)
PRINTF_ATTR
(
2
,
3
)
DECLSPEC_HIDDEN
;
static
inline
void
set_parse_status
(
enum
parse_status
*
current
,
enum
parse_status
update
)
{
...
...
dlls/d3dcompiler_43/utils.c
View file @
e2866d6f
...
...
@@ -23,6 +23,8 @@
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include "d3dcompiler_private.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
d3dcompiler
);
...
...
@@ -715,3 +717,44 @@ HRESULT dxbc_write_blob(struct dxbc *dxbc, ID3DBlob **blob)
return
S_OK
;
}
void
compilation_message
(
struct
compilation_messages
*
msg
,
const
char
*
fmt
,
va_list
args
)
{
char
*
buffer
;
int
rc
,
size
;
if
(
msg
->
capacity
==
0
)
{
msg
->
string
=
asm_alloc
(
MESSAGEBUFFER_INITIAL_SIZE
);
if
(
msg
->
string
==
NULL
)
{
ERR
(
"Error allocating memory for parser messages
\n
"
);
return
;
}
msg
->
capacity
=
MESSAGEBUFFER_INITIAL_SIZE
;
}
while
(
1
)
{
rc
=
vsnprintf
(
msg
->
string
+
msg
->
size
,
msg
->
capacity
-
msg
->
size
,
fmt
,
args
);
if
(
rc
<
0
||
rc
>=
msg
->
capacity
-
msg
->
size
)
{
size
=
msg
->
capacity
*
2
;
buffer
=
asm_realloc
(
msg
->
string
,
size
);
if
(
buffer
==
NULL
)
{
ERR
(
"Error reallocating memory for parser messages
\n
"
);
return
;
}
msg
->
string
=
buffer
;
msg
->
capacity
=
size
;
}
else
{
msg
->
size
+=
rc
;
return
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment