Commit 555f6349 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dcompiler: Make set_parse_status() more general.

parent 167612ae
...@@ -79,7 +79,7 @@ static void asmparser_constF(struct asm_parser *This, DWORD reg, float x, float ...@@ -79,7 +79,7 @@ static void asmparser_constF(struct asm_parser *This, DWORD reg, float x, float
TRACE_(parsed_shader)("def c%u, %f, %f, %f, %f\n", reg, x, y, z, w); TRACE_(parsed_shader)("def c%u, %f, %f, %f, %f\n", reg, x, y, z, w);
if(!add_constF(This->shader, reg, x, y, z, w)) { if(!add_constF(This->shader, reg, x, y, z, w)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -89,7 +89,7 @@ static void asmparser_constB(struct asm_parser *This, DWORD reg, BOOL x) { ...@@ -89,7 +89,7 @@ static void asmparser_constB(struct asm_parser *This, DWORD reg, BOOL x) {
TRACE_(parsed_shader)("def b%u, %s\n", reg, x ? "true" : "false"); TRACE_(parsed_shader)("def b%u, %s\n", reg, x ? "true" : "false");
if(!add_constB(This->shader, reg, x)) { if(!add_constB(This->shader, reg, x)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -99,7 +99,7 @@ static void asmparser_constI(struct asm_parser *This, DWORD reg, INT x, INT y, I ...@@ -99,7 +99,7 @@ static void asmparser_constI(struct asm_parser *This, DWORD reg, INT x, INT y, I
TRACE_(parsed_shader)("def i%u, %d, %d, %d, %d\n", reg, x, y, z, w); TRACE_(parsed_shader)("def i%u, %d, %d, %d, %d\n", reg, x, y, z, w);
if(!add_constI(This->shader, reg, x, y, z, w)) { if(!add_constI(This->shader, reg, x, y, z, w)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -108,18 +108,18 @@ static void asmparser_dcl_output(struct asm_parser *This, DWORD usage, DWORD num ...@@ -108,18 +108,18 @@ static void asmparser_dcl_output(struct asm_parser *This, DWORD usage, DWORD num
if(!This->shader) return; if(!This->shader) return;
if(This->shader->type == ST_PIXEL) { if(This->shader->type == ST_PIXEL) {
asmparser_message(This, "Line %u: Output register declared in a pixel shader\n", This->line_no); asmparser_message(This, "Line %u: Output register declared in a pixel shader\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
if(!record_declaration(This->shader, usage, num, 0, TRUE, reg->regnum, reg->u.writemask, FALSE)) { if(!record_declaration(This->shader, usage, num, 0, TRUE, reg->regnum, reg->u.writemask, FALSE)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
static void asmparser_dcl_output_unsupported(struct asm_parser *This, DWORD usage, DWORD num, static void asmparser_dcl_output_unsupported(struct asm_parser *This, DWORD usage, DWORD num,
const struct shader_reg *reg) { const struct shader_reg *reg) {
asmparser_message(This, "Line %u: Output declaration unsupported in this shader version\n", This->line_no); asmparser_message(This, "Line %u: Output declaration unsupported in this shader version\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
static void asmparser_dcl_input(struct asm_parser *This, DWORD usage, DWORD num, static void asmparser_dcl_input(struct asm_parser *This, DWORD usage, DWORD num,
...@@ -132,7 +132,7 @@ static void asmparser_dcl_input(struct asm_parser *This, DWORD usage, DWORD num, ...@@ -132,7 +132,7 @@ static void asmparser_dcl_input(struct asm_parser *This, DWORD usage, DWORD num,
(mod != BWRITERSPDM_MSAMPCENTROID && (mod != BWRITERSPDM_MSAMPCENTROID &&
mod != BWRITERSPDM_PARTIALPRECISION))) { mod != BWRITERSPDM_PARTIALPRECISION))) {
asmparser_message(This, "Line %u: Unsupported modifier in dcl instruction\n", This->line_no); asmparser_message(This, "Line %u: Unsupported modifier in dcl instruction\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -143,7 +143,7 @@ static void asmparser_dcl_input(struct asm_parser *This, DWORD usage, DWORD num, ...@@ -143,7 +143,7 @@ static void asmparser_dcl_input(struct asm_parser *This, DWORD usage, DWORD num,
if(!record_declaration(This->shader, usage, num, mod, FALSE, reg->regnum, reg->u.writemask, FALSE)) { if(!record_declaration(This->shader, usage, num, mod, FALSE, reg->regnum, reg->u.writemask, FALSE)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -157,7 +157,7 @@ static void asmparser_dcl_input_ps_2(struct asm_parser *This, DWORD usage, DWORD ...@@ -157,7 +157,7 @@ static void asmparser_dcl_input_ps_2(struct asm_parser *This, DWORD usage, DWORD
This->funcs->dstreg(This, &instr, reg); This->funcs->dstreg(This, &instr, reg);
if(!record_declaration(This->shader, usage, num, mod, FALSE, instr.dst.regnum, instr.dst.u.writemask, FALSE)) { if(!record_declaration(This->shader, usage, num, mod, FALSE, instr.dst.regnum, instr.dst.u.writemask, FALSE)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -165,7 +165,7 @@ static void asmparser_dcl_input_unsupported(struct asm_parser *This, ...@@ -165,7 +165,7 @@ static void asmparser_dcl_input_unsupported(struct asm_parser *This,
DWORD usage, DWORD num, DWORD mod, const struct shader_reg *reg) DWORD usage, DWORD num, DWORD mod, const struct shader_reg *reg)
{ {
asmparser_message(This, "Line %u: Input declaration unsupported in this shader version\n", This->line_no); asmparser_message(This, "Line %u: Input declaration unsupported in this shader version\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
static void asmparser_dcl_sampler(struct asm_parser *This, DWORD samptype, static void asmparser_dcl_sampler(struct asm_parser *This, DWORD samptype,
...@@ -177,12 +177,12 @@ static void asmparser_dcl_sampler(struct asm_parser *This, DWORD samptype, ...@@ -177,12 +177,12 @@ static void asmparser_dcl_sampler(struct asm_parser *This, DWORD samptype,
(mod != BWRITERSPDM_MSAMPCENTROID && (mod != BWRITERSPDM_MSAMPCENTROID &&
mod != BWRITERSPDM_PARTIALPRECISION))) { mod != BWRITERSPDM_PARTIALPRECISION))) {
asmparser_message(This, "Line %u: Unsupported modifier in dcl instruction\n", This->line_no); asmparser_message(This, "Line %u: Unsupported modifier in dcl instruction\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
if(!record_sampler(This->shader, samptype, mod, regnum)) { if(!record_sampler(This->shader, samptype, mod, regnum)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -190,7 +190,7 @@ static void asmparser_dcl_sampler_unsupported(struct asm_parser *This, ...@@ -190,7 +190,7 @@ static void asmparser_dcl_sampler_unsupported(struct asm_parser *This,
DWORD samptype, DWORD mod, DWORD regnum, unsigned int line_no) DWORD samptype, DWORD mod, DWORD regnum, unsigned int line_no)
{ {
asmparser_message(This, "Line %u: Sampler declaration unsupported in this shader version\n", This->line_no); asmparser_message(This, "Line %u: Sampler declaration unsupported in this shader version\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
static void asmparser_sincos(struct asm_parser *This, DWORD mod, DWORD shift, static void asmparser_sincos(struct asm_parser *This, DWORD mod, DWORD shift,
...@@ -200,14 +200,14 @@ static void asmparser_sincos(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -200,14 +200,14 @@ static void asmparser_sincos(struct asm_parser *This, DWORD mod, DWORD shift,
if(!srcs || srcs->count != 3) { if(!srcs || srcs->count != 3) {
asmparser_message(This, "Line %u: sincos (vs 2) has an incorrect number of source registers\n", This->line_no); asmparser_message(This, "Line %u: sincos (vs 2) has an incorrect number of source registers\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
instr = alloc_instr(3); instr = alloc_instr(3);
if(!instr) { if(!instr) {
ERR("Error allocating memory for the instruction\n"); ERR("Error allocating memory for the instruction\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -223,7 +223,7 @@ static void asmparser_sincos(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -223,7 +223,7 @@ static void asmparser_sincos(struct asm_parser *This, DWORD mod, DWORD shift,
if(!add_instruction(This->shader, instr)) { if(!add_instruction(This->shader, instr)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -277,14 +277,14 @@ static void asmparser_texcoord(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -277,14 +277,14 @@ static void asmparser_texcoord(struct asm_parser *This, DWORD mod, DWORD shift,
if(srcs) { if(srcs) {
asmparser_message(This, "Line %u: Source registers in texcoord instruction\n", This->line_no); asmparser_message(This, "Line %u: Source registers in texcoord instruction\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
instr = alloc_instr(1); instr = alloc_instr(1);
if(!instr) { if(!instr) {
ERR("Error allocating memory for the instruction\n"); ERR("Error allocating memory for the instruction\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -303,7 +303,7 @@ static void asmparser_texcoord(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -303,7 +303,7 @@ static void asmparser_texcoord(struct asm_parser *This, DWORD mod, DWORD shift,
if(!add_instruction(This->shader, instr)) { if(!add_instruction(This->shader, instr)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -314,14 +314,14 @@ static void asmparser_texcrd(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -314,14 +314,14 @@ static void asmparser_texcrd(struct asm_parser *This, DWORD mod, DWORD shift,
if(!srcs || srcs->count != 1) { if(!srcs || srcs->count != 1) {
asmparser_message(This, "Line %u: Wrong number of source registers in texcrd instruction\n", This->line_no); asmparser_message(This, "Line %u: Wrong number of source registers in texcrd instruction\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
instr = alloc_instr(1); instr = alloc_instr(1);
if(!instr) { if(!instr) {
ERR("Error allocating memory for the instruction\n"); ERR("Error allocating memory for the instruction\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -336,7 +336,7 @@ static void asmparser_texcrd(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -336,7 +336,7 @@ static void asmparser_texcrd(struct asm_parser *This, DWORD mod, DWORD shift,
if(!add_instruction(This->shader, instr)) { if(!add_instruction(This->shader, instr)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -346,7 +346,7 @@ static void asmparser_texkill(struct asm_parser *This, ...@@ -346,7 +346,7 @@ static void asmparser_texkill(struct asm_parser *This,
if(!instr) { if(!instr) {
ERR("Error allocating memory for the instruction\n"); ERR("Error allocating memory for the instruction\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -367,7 +367,7 @@ static void asmparser_texkill(struct asm_parser *This, ...@@ -367,7 +367,7 @@ static void asmparser_texkill(struct asm_parser *This,
if(!add_instruction(This->shader, instr)) { if(!add_instruction(This->shader, instr)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -378,7 +378,7 @@ static void asmparser_texhelper(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -378,7 +378,7 @@ static void asmparser_texhelper(struct asm_parser *This, DWORD mod, DWORD shift,
if(!instr) { if(!instr) {
ERR("Error allocating memory for the instruction\n"); ERR("Error allocating memory for the instruction\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -403,7 +403,7 @@ static void asmparser_texhelper(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -403,7 +403,7 @@ static void asmparser_texhelper(struct asm_parser *This, DWORD mod, DWORD shift,
if(!add_instruction(This->shader, instr)) { if(!add_instruction(This->shader, instr)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -423,14 +423,14 @@ static void asmparser_texld14(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -423,14 +423,14 @@ static void asmparser_texld14(struct asm_parser *This, DWORD mod, DWORD shift,
if(!srcs || srcs->count != 1) { if(!srcs || srcs->count != 1) {
asmparser_message(This, "Line %u: texld (PS 1.4) has a wrong number of source registers\n", This->line_no); asmparser_message(This, "Line %u: texld (PS 1.4) has a wrong number of source registers\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
instr = alloc_instr(2); instr = alloc_instr(2);
if(!instr) { if(!instr) {
ERR("Error allocating memory for the instruction\n"); ERR("Error allocating memory for the instruction\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -457,7 +457,7 @@ static void asmparser_texld14(struct asm_parser *This, DWORD mod, DWORD shift, ...@@ -457,7 +457,7 @@ static void asmparser_texld14(struct asm_parser *This, DWORD mod, DWORD shift,
if(!add_instruction(This->shader, instr)) { if(!add_instruction(This->shader, instr)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -565,7 +565,7 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode, ...@@ -565,7 +565,7 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode,
if(src_count != expectednsrcs) { if(src_count != expectednsrcs) {
asmparser_message(This, "Line %u: Wrong number of source registers\n", This->line_no); asmparser_message(This, "Line %u: Wrong number of source registers\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -588,7 +588,7 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode, ...@@ -588,7 +588,7 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode,
instr = alloc_instr(src_count); instr = alloc_instr(src_count);
if(!instr) { if(!instr) {
ERR("Error allocating memory for the instruction\n"); ERR("Error allocating memory for the instruction\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
return; return;
} }
...@@ -603,7 +603,7 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode, ...@@ -603,7 +603,7 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode,
if(!add_instruction(This->shader, instr)) { if(!add_instruction(This->shader, instr)) {
ERR("Out of memory\n"); ERR("Out of memory\n");
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -676,7 +676,7 @@ static void check_legacy_srcmod(struct asm_parser *This, DWORD srcmod) { ...@@ -676,7 +676,7 @@ static void check_legacy_srcmod(struct asm_parser *This, DWORD srcmod) {
asmparser_message(This, "Line %u: Source modifier %s not supported in this shader version\n", asmparser_message(This, "Line %u: Source modifier %s not supported in this shader version\n",
This->line_no, This->line_no,
debug_print_srcmod(srcmod)); debug_print_srcmod(srcmod));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -685,7 +685,7 @@ static void check_abs_srcmod(struct asm_parser *This, DWORD srcmod) { ...@@ -685,7 +685,7 @@ static void check_abs_srcmod(struct asm_parser *This, DWORD srcmod) {
asmparser_message(This, "Line %u: Source modifier %s not supported in this shader version\n", asmparser_message(This, "Line %u: Source modifier %s not supported in this shader version\n",
This->line_no, This->line_no,
debug_print_srcmod(srcmod)); debug_print_srcmod(srcmod));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -695,7 +695,7 @@ static void check_loop_swizzle(struct asm_parser *This, ...@@ -695,7 +695,7 @@ static void check_loop_swizzle(struct asm_parser *This,
(src->rel_reg && src->rel_reg->type == BWRITERSPR_LOOP && (src->rel_reg && src->rel_reg->type == BWRITERSPR_LOOP &&
src->rel_reg->u.swizzle != BWRITERVS_NOSWIZZLE)) { src->rel_reg->u.swizzle != BWRITERVS_NOSWIZZLE)) {
asmparser_message(This, "Line %u: Swizzle not allowed on aL register\n", This->line_no); asmparser_message(This, "Line %u: Swizzle not allowed on aL register\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -703,7 +703,7 @@ static void check_shift_dstmod(struct asm_parser *This, DWORD shift) { ...@@ -703,7 +703,7 @@ static void check_shift_dstmod(struct asm_parser *This, DWORD shift) {
if(shift != 0) { if(shift != 0) {
asmparser_message(This, "Line %u: Shift modifiers not supported in this shader version\n", asmparser_message(This, "Line %u: Shift modifiers not supported in this shader version\n",
This->line_no); This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -713,7 +713,7 @@ static void check_ps_dstmod(struct asm_parser *This, DWORD dstmod) { ...@@ -713,7 +713,7 @@ static void check_ps_dstmod(struct asm_parser *This, DWORD dstmod) {
asmparser_message(This, "Line %u: Instruction modifier %s not supported in this shader version\n", asmparser_message(This, "Line %u: Instruction modifier %s not supported in this shader version\n",
This->line_no, This->line_no,
debug_print_dstmod(dstmod)); debug_print_dstmod(dstmod));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
} }
...@@ -777,7 +777,7 @@ static void asmparser_srcreg_vs_1(struct asm_parser *This, ...@@ -777,7 +777,7 @@ static void asmparser_srcreg_vs_1(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in VS 1\n", asmparser_message(This, "Line %u: Source register %s not supported in VS 1\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_legacy_srcmod(This, src->srcmod); check_legacy_srcmod(This, src->srcmod);
check_abs_srcmod(This, src->srcmod); check_abs_srcmod(This, src->srcmod);
...@@ -810,7 +810,7 @@ static void asmparser_srcreg_vs_2(struct asm_parser *This, ...@@ -810,7 +810,7 @@ static void asmparser_srcreg_vs_2(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in VS 2\n", asmparser_message(This, "Line %u: Source register %s not supported in VS 2\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_loop_swizzle(This, src); check_loop_swizzle(This, src);
check_legacy_srcmod(This, src->srcmod); check_legacy_srcmod(This, src->srcmod);
...@@ -841,7 +841,7 @@ static void asmparser_srcreg_vs_3(struct asm_parser *This, ...@@ -841,7 +841,7 @@ static void asmparser_srcreg_vs_3(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in VS 3.0\n", asmparser_message(This, "Line %u: Source register %s not supported in VS 3.0\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_loop_swizzle(This, src); check_loop_swizzle(This, src);
check_legacy_srcmod(This, src->srcmod); check_legacy_srcmod(This, src->srcmod);
...@@ -865,7 +865,7 @@ static void asmparser_srcreg_ps_1_0123(struct asm_parser *This, ...@@ -865,7 +865,7 @@ static void asmparser_srcreg_ps_1_0123(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in <== PS 1.3\n", asmparser_message(This, "Line %u: Source register %s not supported in <== PS 1.3\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_abs_srcmod(This, src->srcmod); check_abs_srcmod(This, src->srcmod);
reg = map_oldps_register(src, FALSE); reg = map_oldps_register(src, FALSE);
...@@ -889,7 +889,7 @@ static void asmparser_srcreg_ps_1_4(struct asm_parser *This, ...@@ -889,7 +889,7 @@ static void asmparser_srcreg_ps_1_4(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in PS 1.4\n", asmparser_message(This, "Line %u: Source register %s not supported in PS 1.4\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_abs_srcmod(This, src->srcmod); check_abs_srcmod(This, src->srcmod);
reg = map_oldps_register(src, TRUE); reg = map_oldps_register(src, TRUE);
...@@ -918,7 +918,7 @@ static void asmparser_srcreg_ps_2(struct asm_parser *This, ...@@ -918,7 +918,7 @@ static void asmparser_srcreg_ps_2(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in PS 2.0\n", asmparser_message(This, "Line %u: Source register %s not supported in PS 2.0\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_legacy_srcmod(This, src->srcmod); check_legacy_srcmod(This, src->srcmod);
check_abs_srcmod(This, src->srcmod); check_abs_srcmod(This, src->srcmod);
...@@ -950,7 +950,7 @@ static void asmparser_srcreg_ps_2_x(struct asm_parser *This, ...@@ -950,7 +950,7 @@ static void asmparser_srcreg_ps_2_x(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in PS 2.x\n", asmparser_message(This, "Line %u: Source register %s not supported in PS 2.x\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_legacy_srcmod(This, src->srcmod); check_legacy_srcmod(This, src->srcmod);
check_abs_srcmod(This, src->srcmod); check_abs_srcmod(This, src->srcmod);
...@@ -981,7 +981,7 @@ static void asmparser_srcreg_ps_3(struct asm_parser *This, ...@@ -981,7 +981,7 @@ static void asmparser_srcreg_ps_3(struct asm_parser *This,
asmparser_message(This, "Line %u: Source register %s not supported in PS 3.0\n", asmparser_message(This, "Line %u: Source register %s not supported in PS 3.0\n",
This->line_no, This->line_no,
debug_print_srcreg(src)); debug_print_srcreg(src));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_loop_swizzle(This, src); check_loop_swizzle(This, src);
check_legacy_srcmod(This, src->srcmod); check_legacy_srcmod(This, src->srcmod);
...@@ -997,7 +997,7 @@ static void asmparser_dstreg_vs_1(struct asm_parser *This, ...@@ -997,7 +997,7 @@ static void asmparser_dstreg_vs_1(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in VS 1\n", asmparser_message(This, "Line %u: Destination register %s not supported in VS 1\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_ps_dstmod(This, instr->dstmod); check_ps_dstmod(This, instr->dstmod);
check_shift_dstmod(This, instr->shift); check_shift_dstmod(This, instr->shift);
...@@ -1015,7 +1015,7 @@ static void asmparser_dstreg_vs_2(struct asm_parser *This, ...@@ -1015,7 +1015,7 @@ static void asmparser_dstreg_vs_2(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in VS 2.0\n", asmparser_message(This, "Line %u: Destination register %s not supported in VS 2.0\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_ps_dstmod(This, instr->dstmod); check_ps_dstmod(This, instr->dstmod);
check_shift_dstmod(This, instr->shift); check_shift_dstmod(This, instr->shift);
...@@ -1031,7 +1031,7 @@ static void asmparser_dstreg_vs_3(struct asm_parser *This, ...@@ -1031,7 +1031,7 @@ static void asmparser_dstreg_vs_3(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in VS 3.0\n", asmparser_message(This, "Line %u: Destination register %s not supported in VS 3.0\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_ps_dstmod(This, instr->dstmod); check_ps_dstmod(This, instr->dstmod);
check_shift_dstmod(This, instr->shift); check_shift_dstmod(This, instr->shift);
...@@ -1048,7 +1048,7 @@ static void asmparser_dstreg_ps_1_0123(struct asm_parser *This, ...@@ -1048,7 +1048,7 @@ static void asmparser_dstreg_ps_1_0123(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in PS 1\n", asmparser_message(This, "Line %u: Destination register %s not supported in PS 1\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
reg = map_oldps_register(dst, FALSE); reg = map_oldps_register(dst, FALSE);
memcpy(&instr->dst, &reg, sizeof(reg)); memcpy(&instr->dst, &reg, sizeof(reg));
...@@ -1064,7 +1064,7 @@ static void asmparser_dstreg_ps_1_4(struct asm_parser *This, ...@@ -1064,7 +1064,7 @@ static void asmparser_dstreg_ps_1_4(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in PS 1\n", asmparser_message(This, "Line %u: Destination register %s not supported in PS 1\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
reg = map_oldps_register(dst, TRUE); reg = map_oldps_register(dst, TRUE);
memcpy(&instr->dst, &reg, sizeof(reg)); memcpy(&instr->dst, &reg, sizeof(reg));
...@@ -1080,7 +1080,7 @@ static void asmparser_dstreg_ps_2(struct asm_parser *This, ...@@ -1080,7 +1080,7 @@ static void asmparser_dstreg_ps_2(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in PS 2.0\n", asmparser_message(This, "Line %u: Destination register %s not supported in PS 2.0\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_shift_dstmod(This, instr->shift); check_shift_dstmod(This, instr->shift);
reg = map_oldps_register(dst, TRUE); reg = map_oldps_register(dst, TRUE);
...@@ -1097,7 +1097,7 @@ static void asmparser_dstreg_ps_2_x(struct asm_parser *This, ...@@ -1097,7 +1097,7 @@ static void asmparser_dstreg_ps_2_x(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in PS 2.x\n", asmparser_message(This, "Line %u: Destination register %s not supported in PS 2.x\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_shift_dstmod(This, instr->shift); check_shift_dstmod(This, instr->shift);
reg = map_oldps_register(dst, TRUE); reg = map_oldps_register(dst, TRUE);
...@@ -1112,7 +1112,7 @@ static void asmparser_dstreg_ps_3(struct asm_parser *This, ...@@ -1112,7 +1112,7 @@ static void asmparser_dstreg_ps_3(struct asm_parser *This,
asmparser_message(This, "Line %u: Destination register %s not supported in PS 3.0\n", asmparser_message(This, "Line %u: Destination register %s not supported in PS 3.0\n",
This->line_no, This->line_no,
debug_print_dstreg(dst)); debug_print_dstreg(dst));
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
check_shift_dstmod(This, instr->shift); check_shift_dstmod(This, instr->shift);
memcpy(&instr->dst, dst, sizeof(*dst)); memcpy(&instr->dst, dst, sizeof(*dst));
...@@ -1131,7 +1131,7 @@ static void asmparser_predicate_supported(struct asm_parser *This, ...@@ -1131,7 +1131,7 @@ static void asmparser_predicate_supported(struct asm_parser *This,
static void asmparser_predicate_unsupported(struct asm_parser *This, static void asmparser_predicate_unsupported(struct asm_parser *This,
const struct shader_reg *predicate) { const struct shader_reg *predicate) {
asmparser_message(This, "Line %u: Predicate not supported in < VS 2.0 or PS 2.x\n", This->line_no); asmparser_message(This, "Line %u: Predicate not supported in < VS 2.0 or PS 2.x\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
static void asmparser_coissue_supported(struct asm_parser *This) { static void asmparser_coissue_supported(struct asm_parser *This) {
...@@ -1139,14 +1139,14 @@ static void asmparser_coissue_supported(struct asm_parser *This) { ...@@ -1139,14 +1139,14 @@ static void asmparser_coissue_supported(struct asm_parser *This) {
if(!This->shader) return; if(!This->shader) return;
if(This->shader->num_instrs == 0){ if(This->shader->num_instrs == 0){
asmparser_message(This, "Line %u: Coissue flag on the first shader instruction\n", This->line_no); asmparser_message(This, "Line %u: Coissue flag on the first shader instruction\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
This->shader->instr[This->shader->num_instrs-1]->coissue = TRUE; This->shader->instr[This->shader->num_instrs-1]->coissue = TRUE;
} }
static void asmparser_coissue_unsupported(struct asm_parser *This) { static void asmparser_coissue_unsupported(struct asm_parser *This) {
asmparser_message(This, "Line %u: Coissue is only supported in pixel shaders versions <= 1.4\n", This->line_no); asmparser_message(This, "Line %u: Coissue is only supported in pixel shaders versions <= 1.4\n", This->line_no);
set_parse_status(This, PARSE_ERR); set_parse_status(&This->status, PARSE_ERR);
} }
static const struct asmparser_backend parser_vs_1 = { static const struct asmparser_backend parser_vs_1 = {
...@@ -1353,7 +1353,7 @@ void create_vs10_parser(struct asm_parser *ret) { ...@@ -1353,7 +1353,7 @@ void create_vs10_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1369,7 +1369,7 @@ void create_vs11_parser(struct asm_parser *ret) { ...@@ -1369,7 +1369,7 @@ void create_vs11_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1385,7 +1385,7 @@ void create_vs20_parser(struct asm_parser *ret) { ...@@ -1385,7 +1385,7 @@ void create_vs20_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1401,7 +1401,7 @@ void create_vs2x_parser(struct asm_parser *ret) { ...@@ -1401,7 +1401,7 @@ void create_vs2x_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1417,7 +1417,7 @@ void create_vs30_parser(struct asm_parser *ret) { ...@@ -1417,7 +1417,7 @@ void create_vs30_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1432,7 +1432,7 @@ void create_ps10_parser(struct asm_parser *ret) { ...@@ -1432,7 +1432,7 @@ void create_ps10_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1448,7 +1448,7 @@ void create_ps11_parser(struct asm_parser *ret) { ...@@ -1448,7 +1448,7 @@ void create_ps11_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1464,7 +1464,7 @@ void create_ps12_parser(struct asm_parser *ret) { ...@@ -1464,7 +1464,7 @@ void create_ps12_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1480,7 +1480,7 @@ void create_ps13_parser(struct asm_parser *ret) { ...@@ -1480,7 +1480,7 @@ void create_ps13_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1496,7 +1496,7 @@ void create_ps14_parser(struct asm_parser *ret) { ...@@ -1496,7 +1496,7 @@ void create_ps14_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1512,7 +1512,7 @@ void create_ps20_parser(struct asm_parser *ret) { ...@@ -1512,7 +1512,7 @@ void create_ps20_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1528,7 +1528,7 @@ void create_ps2x_parser(struct asm_parser *ret) { ...@@ -1528,7 +1528,7 @@ void create_ps2x_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
...@@ -1544,7 +1544,7 @@ void create_ps30_parser(struct asm_parser *ret) { ...@@ -1544,7 +1544,7 @@ void create_ps30_parser(struct asm_parser *ret) {
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = asm_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(ret, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
return; return;
} }
......
...@@ -480,7 +480,7 @@ false { ...@@ -480,7 +480,7 @@ false {
{ANY} { {ANY} {
asmparser_message(&asm_ctx, "Line %u: Unexpected input %s\n", asm_ctx.line_no, yytext); asmparser_message(&asm_ctx, "Line %u: Unexpected input %s\n", asm_ctx.line_no, yytext);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
%% %%
......
/* /*
* Direct3D shader assembler * Direct3D shader assembler
* *
* Copyright 2008 Stefan Dösinger * Copyright 2008 Stefan Dösinger
...@@ -73,7 +73,7 @@ void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) { ...@@ -73,7 +73,7 @@ void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) {
static void asmshader_error(char const *s) { static void asmshader_error(char const *s) {
asmparser_message(&asm_ctx, "Line %u: Error \"%s\" from bison\n", asm_ctx.line_no, s); asmparser_message(&asm_ctx, "Line %u: Error \"%s\" from bison\n", asm_ctx.line_no, s);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
static void set_rel_reg(struct shader_reg *reg, struct rel_reg *rel) { static void set_rel_reg(struct shader_reg *reg, struct rel_reg *rel) {
...@@ -623,13 +623,13 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -623,13 +623,13 @@ instruction: INSTR_ADD omods dreg ',' sregs
if($3.shift != 0) { if($3.shift != 0) {
asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n", asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) || if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) ||
asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) { asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) {
asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n", asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
ZeroMemory(&reg, sizeof(reg)); ZeroMemory(&reg, sizeof(reg));
reg.type = $4.type; reg.type = $4.type;
...@@ -646,13 +646,13 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -646,13 +646,13 @@ instruction: INSTR_ADD omods dreg ',' sregs
if($3.shift != 0) { if($3.shift != 0) {
asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n", asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) || if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) ||
asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) { asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) {
asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n", asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
ZeroMemory(&reg, sizeof(reg)); ZeroMemory(&reg, sizeof(reg));
reg.type = $4.type; reg.type = $4.type;
...@@ -669,12 +669,12 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -669,12 +669,12 @@ instruction: INSTR_ADD omods dreg ',' sregs
if($2.shift != 0) { if($2.shift != 0) {
asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n", asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
if(asm_ctx.shader->type != ST_PIXEL) { if(asm_ctx.shader->type != ST_PIXEL) {
asmparser_message(&asm_ctx, "Line %u: Declaration needs a semantic\n", asmparser_message(&asm_ctx, "Line %u: Declaration needs a semantic\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
ZeroMemory(&reg, sizeof(reg)); ZeroMemory(&reg, sizeof(reg));
reg.type = $3.type; reg.type = $3.type;
...@@ -691,12 +691,12 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -691,12 +691,12 @@ instruction: INSTR_ADD omods dreg ',' sregs
if($2.shift != 0) { if($2.shift != 0) {
asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n", asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
if(asm_ctx.shader->type != ST_PIXEL) { if(asm_ctx.shader->type != ST_PIXEL) {
asmparser_message(&asm_ctx, "Line %u: Declaration needs a semantic\n", asmparser_message(&asm_ctx, "Line %u: Declaration needs a semantic\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
ZeroMemory(&reg, sizeof(reg)); ZeroMemory(&reg, sizeof(reg));
reg.type = $3.type; reg.type = $3.type;
...@@ -712,7 +712,7 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -712,7 +712,7 @@ instruction: INSTR_ADD omods dreg ',' sregs
if($3.shift != 0) { if($3.shift != 0) {
asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n", asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
asm_ctx.funcs->dcl_sampler(&asm_ctx, $2, $3.mod, $4, asm_ctx.line_no); asm_ctx.funcs->dcl_sampler(&asm_ctx, $2, $3.mod, $4, asm_ctx.line_no);
} }
...@@ -722,12 +722,12 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -722,12 +722,12 @@ instruction: INSTR_ADD omods dreg ',' sregs
if($2.shift != 0) { if($2.shift != 0) {
asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n", asmparser_message(&asm_ctx, "Line %u: Shift modifier not allowed here\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
if(asm_ctx.shader->type != ST_PIXEL) { if(asm_ctx.shader->type != ST_PIXEL) {
asmparser_message(&asm_ctx, "Line %u: Declaration needs a sampler type\n", asmparser_message(&asm_ctx, "Line %u: Declaration needs a sampler type\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
asm_ctx.funcs->dcl_sampler(&asm_ctx, BWRITERSTT_UNKNOWN, $2.mod, $3, asm_ctx.line_no); asm_ctx.funcs->dcl_sampler(&asm_ctx, BWRITERSTT_UNKNOWN, $2.mod, $3, asm_ctx.line_no);
} }
...@@ -736,14 +736,14 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -736,14 +736,14 @@ instruction: INSTR_ADD omods dreg ',' sregs
TRACE("Error rule: sampler decl of input reg\n"); TRACE("Error rule: sampler decl of input reg\n");
asmparser_message(&asm_ctx, "Line %u: Sampler declarations of input regs is not valid\n", asmparser_message(&asm_ctx, "Line %u: Sampler declarations of input regs is not valid\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| INSTR_DCL sampdcl omods REG_OUTPUT | INSTR_DCL sampdcl omods REG_OUTPUT
{ {
TRACE("Error rule: sampler decl of output reg\n"); TRACE("Error rule: sampler decl of output reg\n");
asmparser_message(&asm_ctx, "Line %u: Sampler declarations of output regs is not valid\n", asmparser_message(&asm_ctx, "Line %u: Sampler declarations of output regs is not valid\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| INSTR_DEF REG_CONSTFLOAT ',' IMMVAL ',' IMMVAL ',' IMMVAL ',' IMMVAL | INSTR_DEF REG_CONSTFLOAT ',' IMMVAL ',' IMMVAL ',' IMMVAL ',' IMMVAL
{ {
...@@ -1049,19 +1049,19 @@ dreg_name: REG_TEMP ...@@ -1049,19 +1049,19 @@ dreg_name: REG_TEMP
{ {
asmparser_message(&asm_ctx, "Line %u: Register c%u is not a valid destination register\n", asmparser_message(&asm_ctx, "Line %u: Register c%u is not a valid destination register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_CONSTINT | REG_CONSTINT
{ {
asmparser_message(&asm_ctx, "Line %u: Register i%u is not a valid destination register\n", asmparser_message(&asm_ctx, "Line %u: Register i%u is not a valid destination register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_CONSTBOOL | REG_CONSTBOOL
{ {
asmparser_message(&asm_ctx, "Line %u: Register b%u is not a valid destination register\n", asmparser_message(&asm_ctx, "Line %u: Register b%u is not a valid destination register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_TEXTURE | REG_TEXTURE
{ {
...@@ -1075,7 +1075,7 @@ dreg_name: REG_TEMP ...@@ -1075,7 +1075,7 @@ dreg_name: REG_TEMP
{ {
asmparser_message(&asm_ctx, "Line %u: Register s%u is not a valid destination register\n", asmparser_message(&asm_ctx, "Line %u: Register s%u is not a valid destination register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_OPOS | REG_OPOS
{ {
...@@ -1109,13 +1109,13 @@ dreg_name: REG_TEMP ...@@ -1109,13 +1109,13 @@ dreg_name: REG_TEMP
{ {
asmparser_message(&asm_ctx, "Line %u: Register vPos is not a valid destination register\n", asmparser_message(&asm_ctx, "Line %u: Register vPos is not a valid destination register\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_VFACE | REG_VFACE
{ {
asmparser_message(&asm_ctx, "Line %u: Register vFace is not a valid destination register\n", asmparser_message(&asm_ctx, "Line %u: Register vFace is not a valid destination register\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_ADDRESS | REG_ADDRESS
{ {
...@@ -1126,7 +1126,7 @@ dreg_name: REG_TEMP ...@@ -1126,7 +1126,7 @@ dreg_name: REG_TEMP
{ {
asmparser_message(&asm_ctx, "Line %u: Register aL is not a valid destination register\n", asmparser_message(&asm_ctx, "Line %u: Register aL is not a valid destination register\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
writemask: '.' wm_components writemask: '.' wm_components
...@@ -1134,7 +1134,7 @@ writemask: '.' wm_components ...@@ -1134,7 +1134,7 @@ writemask: '.' wm_components
if($2.writemask == SWIZZLE_ERR) { if($2.writemask == SWIZZLE_ERR) {
asmparser_message(&asm_ctx, "Line %u: Invalid writemask specified\n", asmparser_message(&asm_ctx, "Line %u: Invalid writemask specified\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
/* Provide a correct writemask to prevent following complaints */ /* Provide a correct writemask to prevent following complaints */
$$ = BWRITERSP_WRITEMASK_ALL; $$ = BWRITERSP_WRITEMASK_ALL;
} }
...@@ -1175,7 +1175,7 @@ swizzle: /* empty */ ...@@ -1175,7 +1175,7 @@ swizzle: /* empty */
if($2.swizzle == SWIZZLE_ERR) { if($2.swizzle == SWIZZLE_ERR) {
asmparser_message(&asm_ctx, "Line %u: Invalid swizzle\n", asmparser_message(&asm_ctx, "Line %u: Invalid swizzle\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
/* Provide a correct swizzle to prevent following complaints */ /* Provide a correct swizzle to prevent following complaints */
$$ = BWRITERVS_NOSWIZZLE; $$ = BWRITERVS_NOSWIZZLE;
} }
...@@ -1221,7 +1221,7 @@ omods: /* Empty */ ...@@ -1221,7 +1221,7 @@ omods: /* Empty */
if($1.shift && $2.shift) { if($1.shift && $2.shift) {
asmparser_message(&asm_ctx, "Line %u: More than one shift flag\n", asmparser_message(&asm_ctx, "Line %u: More than one shift flag\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
$$.shift = $1.shift; $$.shift = $1.shift;
} else { } else {
$$.shift = $1.shift | $2.shift; $$.shift = $1.shift | $2.shift;
...@@ -1284,7 +1284,7 @@ sregs: sreg ...@@ -1284,7 +1284,7 @@ sregs: sreg
if($$.count == MAX_SRC_REGS){ if($$.count == MAX_SRC_REGS){
asmparser_message(&asm_ctx, "Line %u: Too many source registers in this instruction\n", asmparser_message(&asm_ctx, "Line %u: Too many source registers in this instruction\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
else else
$$.reg[$$.count++] = $3; $$.reg[$$.count++] = $3;
...@@ -1327,12 +1327,12 @@ sreg: sreg_name rel_reg swizzle ...@@ -1327,12 +1327,12 @@ sreg: sreg_name rel_reg swizzle
case BWRITERSPSM_DZ: case BWRITERSPSM_DZ:
asmparser_message(&asm_ctx, "Line %u: Incompatible source modifiers: NEG and DZ\n", asmparser_message(&asm_ctx, "Line %u: Incompatible source modifiers: NEG and DZ\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
break; break;
case BWRITERSPSM_DW: case BWRITERSPSM_DW:
asmparser_message(&asm_ctx, "Line %u: Incompatible source modifiers: NEG and DW\n", asmparser_message(&asm_ctx, "Line %u: Incompatible source modifiers: NEG and DW\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
break; break;
default: default:
FIXME("Unhandled combination of NEGATE and %u\n", $4); FIXME("Unhandled combination of NEGATE and %u\n", $4);
...@@ -1344,7 +1344,7 @@ sreg: sreg_name rel_reg swizzle ...@@ -1344,7 +1344,7 @@ sreg: sreg_name rel_reg swizzle
if($1.val != 1.0 || (!$1.integer)) { if($1.val != 1.0 || (!$1.integer)) {
asmparser_message(&asm_ctx, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP, " asmparser_message(&asm_ctx, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP, "
"%g - reg found\n", asm_ctx.line_no, $1.val); "%g - reg found\n", asm_ctx.line_no, $1.val);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
/* Complement - not compatible with other source modifiers */ /* Complement - not compatible with other source modifiers */
$$.type = $3.type; $$.type = $3.type;
...@@ -1359,12 +1359,12 @@ sreg: sreg_name rel_reg swizzle ...@@ -1359,12 +1359,12 @@ sreg: sreg_name rel_reg swizzle
if($1.val != 1.0 || (!$1.integer)) { if($1.val != 1.0 || (!$1.integer)) {
asmparser_message(&asm_ctx, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP\n", asmparser_message(&asm_ctx, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} else { } else {
asmparser_message(&asm_ctx, "Line %u: Incompatible source modifiers: D3DSPSM_COMP and %s\n", asmparser_message(&asm_ctx, "Line %u: Incompatible source modifiers: D3DSPSM_COMP and %s\n",
asm_ctx.line_no, asm_ctx.line_no,
debug_print_srcmod($5)); debug_print_srcmod($5));
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
} }
| SMOD_NOT sreg_name swizzle | SMOD_NOT sreg_name swizzle
...@@ -1424,7 +1424,7 @@ immsum: IMMVAL ...@@ -1424,7 +1424,7 @@ immsum: IMMVAL
if(!$1.integer) { if(!$1.integer) {
asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n", asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n",
asm_ctx.line_no, $1.val); asm_ctx.line_no, $1.val);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
$$.val = $1.val; $$.val = $1.val;
} }
...@@ -1433,7 +1433,7 @@ immsum: IMMVAL ...@@ -1433,7 +1433,7 @@ immsum: IMMVAL
if(!$3.integer) { if(!$3.integer) {
asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n", asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n",
asm_ctx.line_no, $3.val); asm_ctx.line_no, $3.val);
set_parse_status(&asm_ctx, PARSE_ERR); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
$$.val = $1.val + $3.val; $$.val = $1.val + $3.val;
} }
...@@ -1480,7 +1480,7 @@ sreg_name: REG_TEMP ...@@ -1480,7 +1480,7 @@ sreg_name: REG_TEMP
{ {
asmparser_message(&asm_ctx, "Line %u: Register o%u is not a valid source register\n", asmparser_message(&asm_ctx, "Line %u: Register o%u is not a valid source register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_INPUT | REG_INPUT
{ {
...@@ -1506,7 +1506,7 @@ sreg_name: REG_TEMP ...@@ -1506,7 +1506,7 @@ sreg_name: REG_TEMP
{ {
asmparser_message(&asm_ctx, "Line %u: Register oT%u is not a valid source register\n", asmparser_message(&asm_ctx, "Line %u: Register oT%u is not a valid source register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_SAMPLER | REG_SAMPLER
{ {
...@@ -1516,31 +1516,31 @@ sreg_name: REG_TEMP ...@@ -1516,31 +1516,31 @@ sreg_name: REG_TEMP
{ {
asmparser_message(&asm_ctx, "Line %u: Register oPos is not a valid source register\n", asmparser_message(&asm_ctx, "Line %u: Register oPos is not a valid source register\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_OFOG | REG_OFOG
{ {
asmparser_message(&asm_ctx, "Line %u: Register oFog is not a valid source register\n", asmparser_message(&asm_ctx, "Line %u: Register oFog is not a valid source register\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_VERTEXCOLOR | REG_VERTEXCOLOR
{ {
asmparser_message(&asm_ctx, "Line %u: Register oD%u is not a valid source register\n", asmparser_message(&asm_ctx, "Line %u: Register oD%u is not a valid source register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_FRAGCOLOR | REG_FRAGCOLOR
{ {
asmparser_message(&asm_ctx, "Line %u: Register oC%u is not a valid source register\n", asmparser_message(&asm_ctx, "Line %u: Register oC%u is not a valid source register\n",
asm_ctx.line_no, $1); asm_ctx.line_no, $1);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_FRAGDEPTH | REG_FRAGDEPTH
{ {
asmparser_message(&asm_ctx, "Line %u: Register oDepth is not a valid source register\n", asmparser_message(&asm_ctx, "Line %u: Register oDepth is not a valid source register\n",
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx, PARSE_WARN); set_parse_status(&asm_ctx.status, PARSE_WARN);
} }
| REG_PREDICATE | REG_PREDICATE
{ {
...@@ -1704,12 +1704,6 @@ predicate: '(' REG_PREDICATE swizzle ')' ...@@ -1704,12 +1704,6 @@ predicate: '(' REG_PREDICATE swizzle ')'
%% %%
/* New status is the worst between current status and parameter value */
void set_parse_status(struct asm_parser *ctx, enum parse_status status) {
if(status == PARSE_ERR) ctx->status = PARSE_ERR;
else if(status == PARSE_WARN && ctx->status == PARSE_SUCCESS) ctx->status = PARSE_WARN;
}
struct bwriter_shader *parse_asm_shader(char **messages) { struct bwriter_shader *parse_asm_shader(char **messages) {
struct bwriter_shader *ret = NULL; struct bwriter_shader *ret = NULL;
......
...@@ -209,6 +209,13 @@ BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD mod, DW ...@@ -209,6 +209,13 @@ BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD mod, DW
#define MESSAGEBUFFER_INITIAL_SIZE 256 #define MESSAGEBUFFER_INITIAL_SIZE 256
enum parse_status
{
PARSE_SUCCESS = 0,
PARSE_WARN = 1,
PARSE_ERR = 2
};
struct asm_parser { struct asm_parser {
/* The function table of the parser implementation */ /* The function table of the parser implementation */
const struct asmparser_backend *funcs; const struct asmparser_backend *funcs;
...@@ -217,11 +224,7 @@ struct asm_parser { ...@@ -217,11 +224,7 @@ struct asm_parser {
struct bwriter_shader *shader; struct bwriter_shader *shader;
unsigned int m3x3pad_count; unsigned int m3x3pad_count;
enum parse_status { enum parse_status status;
PARSE_SUCCESS = 0,
PARSE_WARN = 1,
PARSE_ERR = 2
} status;
char *messages; char *messages;
unsigned int messagesize; unsigned int messagesize;
unsigned int messagecapacity; unsigned int messagecapacity;
...@@ -253,7 +256,13 @@ struct bwriter_shader *parse_asm_shader(char **messages) DECLSPEC_HIDDEN; ...@@ -253,7 +256,13 @@ struct bwriter_shader *parse_asm_shader(char **messages) DECLSPEC_HIDDEN;
#endif #endif
void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN; void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
void set_parse_status(struct asm_parser *ctx, enum parse_status status) DECLSPEC_HIDDEN; static inline void set_parse_status(enum parse_status *current, enum parse_status update)
{
if (update == PARSE_ERR)
*current = PARSE_ERR;
else if (update == PARSE_WARN && *current == PARSE_SUCCESS)
*current = PARSE_WARN;
}
/* A reasonable value as initial size */ /* A reasonable value as initial size */
#define BYTECODEBUFFER_INITIAL_SIZE 32 #define BYTECODEBUFFER_INITIAL_SIZE 32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment