New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -53,12 +53,12 @@ enum gs_sample_filter get_sample_filter(const char *filter)
|
|||
if (astrcmpi(filter, "Anisotropy") == 0)
|
||||
return GS_FILTER_ANISOTROPIC;
|
||||
|
||||
else if (astrcmpi(filter, "Point") == 0 ||
|
||||
strcmp(filter, "MIN_MAG_MIP_POINT") == 0)
|
||||
else if (astrcmpi(filter, "Point") == 0 ||
|
||||
strcmp(filter, "MIN_MAG_MIP_POINT") == 0)
|
||||
return GS_FILTER_POINT;
|
||||
|
||||
else if (astrcmpi(filter, "Linear") == 0 ||
|
||||
strcmp(filter, "MIN_MAG_MIP_LINEAR") == 0)
|
||||
else if (astrcmpi(filter, "Linear") == 0 ||
|
||||
strcmp(filter, "MIN_MAG_MIP_LINEAR") == 0)
|
||||
return GS_FILTER_LINEAR;
|
||||
|
||||
else if (strcmp(filter, "MIN_MAG_POINT_MIP_LINEAR") == 0)
|
||||
|
|
@ -99,7 +99,7 @@ extern enum gs_address_mode get_address_mode(const char *mode)
|
|||
}
|
||||
|
||||
void shader_sampler_convert(struct shader_sampler *ss,
|
||||
struct gs_sampler_info *info)
|
||||
struct gs_sampler_info *info)
|
||||
{
|
||||
size_t i;
|
||||
memset(info, 0, sizeof(struct gs_sampler_info));
|
||||
|
|
@ -128,22 +128,26 @@ void shader_sampler_convert(struct shader_sampler *ss,
|
|||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int sp_parse_sampler_state_item(struct shader_parser *sp,
|
||||
struct shader_sampler *ss)
|
||||
struct shader_sampler *ss)
|
||||
{
|
||||
int ret;
|
||||
char *state = NULL, *value = NULL;
|
||||
|
||||
ret = cf_next_name(&sp->cfp, &state, "state name", ";");
|
||||
if (ret != PARSE_SUCCESS) goto fail;
|
||||
if (ret != PARSE_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
ret = cf_next_token_should_be(&sp->cfp, "=", ";", NULL);
|
||||
if (ret != PARSE_SUCCESS) goto fail;
|
||||
if (ret != PARSE_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
ret = cf_next_token_copy(&sp->cfp, &value);
|
||||
if (ret != PARSE_SUCCESS) goto fail;
|
||||
if (ret != PARSE_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
ret = cf_next_token_should_be(&sp->cfp, ";", ";", NULL);
|
||||
if (ret != PARSE_SUCCESS) goto fail;
|
||||
if (ret != PARSE_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
da_push_back(ss->states, &state);
|
||||
da_push_back(ss->values, &value);
|
||||
|
|
@ -191,17 +195,20 @@ error:
|
|||
}
|
||||
|
||||
static inline int sp_parse_struct_var(struct shader_parser *sp,
|
||||
struct shader_var *var)
|
||||
struct shader_var *var)
|
||||
{
|
||||
int code;
|
||||
|
||||
/* -------------------------------------- */
|
||||
/* variable type */
|
||||
|
||||
if (!cf_next_valid_token(&sp->cfp)) return PARSE_EOF;
|
||||
if (!cf_next_valid_token(&sp->cfp))
|
||||
return PARSE_EOF;
|
||||
|
||||
if (cf_token_is(&sp->cfp, ";")) return PARSE_CONTINUE;
|
||||
if (cf_token_is(&sp->cfp, "}")) return PARSE_BREAK;
|
||||
if (cf_token_is(&sp->cfp, ";"))
|
||||
return PARSE_CONTINUE;
|
||||
if (cf_token_is(&sp->cfp, "}"))
|
||||
return PARSE_BREAK;
|
||||
|
||||
code = cf_token_is_type(&sp->cfp, CFTOKEN_NAME, "type name", ";");
|
||||
if (code != PARSE_SUCCESS)
|
||||
|
|
@ -212,13 +219,15 @@ static inline int sp_parse_struct_var(struct shader_parser *sp,
|
|||
/* -------------------------------------- */
|
||||
/* variable name */
|
||||
|
||||
if (!cf_next_valid_token(&sp->cfp)) return PARSE_EOF;
|
||||
if (!cf_next_valid_token(&sp->cfp))
|
||||
return PARSE_EOF;
|
||||
|
||||
if (cf_token_is(&sp->cfp, ";")) return PARSE_UNEXPECTED_CONTINUE;
|
||||
if (cf_token_is(&sp->cfp, "}")) return PARSE_UNEXPECTED_BREAK;
|
||||
if (cf_token_is(&sp->cfp, ";"))
|
||||
return PARSE_UNEXPECTED_CONTINUE;
|
||||
if (cf_token_is(&sp->cfp, "}"))
|
||||
return PARSE_UNEXPECTED_BREAK;
|
||||
|
||||
code = cf_token_is_type(&sp->cfp, CFTOKEN_NAME, "variable name",
|
||||
";");
|
||||
code = cf_token_is_type(&sp->cfp, CFTOKEN_NAME, "variable name", ";");
|
||||
if (code != PARSE_SUCCESS)
|
||||
return code;
|
||||
|
||||
|
|
@ -227,24 +236,27 @@ static inline int sp_parse_struct_var(struct shader_parser *sp,
|
|||
/* -------------------------------------- */
|
||||
/* variable mapping if any (POSITION, TEXCOORD, etc) */
|
||||
|
||||
if (!cf_next_valid_token(&sp->cfp)) return PARSE_EOF;
|
||||
if (!cf_next_valid_token(&sp->cfp))
|
||||
return PARSE_EOF;
|
||||
|
||||
if (cf_token_is(&sp->cfp, ":")) {
|
||||
if (!cf_next_valid_token(&sp->cfp)) return PARSE_EOF;
|
||||
if (!cf_next_valid_token(&sp->cfp))
|
||||
return PARSE_EOF;
|
||||
|
||||
if (cf_token_is(&sp->cfp, ";"))
|
||||
return PARSE_UNEXPECTED_CONTINUE;
|
||||
if (cf_token_is(&sp->cfp, "}"))
|
||||
return PARSE_UNEXPECTED_BREAK;
|
||||
|
||||
code = cf_token_is_type(&sp->cfp, CFTOKEN_NAME,
|
||||
"mapping name", ";");
|
||||
code = cf_token_is_type(&sp->cfp, CFTOKEN_NAME, "mapping name",
|
||||
";");
|
||||
if (code != PARSE_SUCCESS)
|
||||
return code;
|
||||
|
||||
cf_copy_token(&sp->cfp, &var->mapping);
|
||||
|
||||
if (!cf_next_valid_token(&sp->cfp)) return PARSE_EOF;
|
||||
if (!cf_next_valid_token(&sp->cfp))
|
||||
return PARSE_EOF;
|
||||
}
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
|
@ -314,7 +326,7 @@ error:
|
|||
}
|
||||
|
||||
static inline int sp_check_for_keyword(struct shader_parser *sp,
|
||||
const char *keyword, bool *val)
|
||||
const char *keyword, bool *val)
|
||||
{
|
||||
bool new_val = cf_token_is(&sp->cfp, keyword);
|
||||
if (new_val) {
|
||||
|
|
@ -323,7 +335,7 @@ static inline int sp_check_for_keyword(struct shader_parser *sp,
|
|||
|
||||
if (new_val && *val)
|
||||
cf_adderror(&sp->cfp, "'$1' keyword already specified",
|
||||
LEX_WARNING, keyword, NULL, NULL);
|
||||
LEX_WARNING, keyword, NULL, NULL);
|
||||
*val = new_val;
|
||||
|
||||
return PARSE_CONTINUE;
|
||||
|
|
@ -333,7 +345,7 @@ static inline int sp_check_for_keyword(struct shader_parser *sp,
|
|||
}
|
||||
|
||||
static inline int sp_parse_func_param(struct shader_parser *sp,
|
||||
struct shader_var *var)
|
||||
struct shader_var *var)
|
||||
{
|
||||
int code;
|
||||
bool var_type_keyword = false;
|
||||
|
|
@ -384,7 +396,7 @@ static inline int sp_parse_func_param(struct shader_parser *sp,
|
|||
|
||||
if (cf_token_is(&sp->cfp, ":")) {
|
||||
code = cf_next_name(&sp->cfp, &var->mapping,
|
||||
"mapping specifier", ")");
|
||||
"mapping specifier", ")");
|
||||
if (code != PARSE_SUCCESS)
|
||||
return code;
|
||||
|
||||
|
|
@ -396,7 +408,7 @@ static inline int sp_parse_func_param(struct shader_parser *sp,
|
|||
}
|
||||
|
||||
static bool sp_parse_func_params(struct shader_parser *sp,
|
||||
struct shader_func *func)
|
||||
struct shader_func *func)
|
||||
{
|
||||
struct cf_token peek;
|
||||
int code;
|
||||
|
|
@ -449,8 +461,8 @@ static void sp_parse_function(struct shader_parser *sp, char *type, char *name)
|
|||
/* if function is mapped to something, for example COLOR */
|
||||
if (cf_token_is(&sp->cfp, ":")) {
|
||||
char *mapping = NULL;
|
||||
int errorcode = cf_next_name(&sp->cfp, &mapping, "mapping",
|
||||
"{");
|
||||
int errorcode =
|
||||
cf_next_name(&sp->cfp, &mapping, "mapping", "{");
|
||||
if (errorcode != PARSE_SUCCESS)
|
||||
goto error;
|
||||
|
||||
|
|
@ -482,17 +494,18 @@ error:
|
|||
|
||||
/* parses "array[count]" */
|
||||
static bool sp_parse_param_array(struct shader_parser *sp,
|
||||
struct shader_var *param)
|
||||
struct shader_var *param)
|
||||
{
|
||||
if (!cf_next_valid_token(&sp->cfp))
|
||||
return false;
|
||||
|
||||
if (sp->cfp.cur_token->type != CFTOKEN_NUM ||
|
||||
!valid_int_str(sp->cfp.cur_token->str.array,
|
||||
sp->cfp.cur_token->str.len))
|
||||
sp->cfp.cur_token->str.len))
|
||||
return false;
|
||||
|
||||
param->array_count =(int)strtol(sp->cfp.cur_token->str.array, NULL, 10);
|
||||
param->array_count =
|
||||
(int)strtol(sp->cfp.cur_token->str.array, NULL, 10);
|
||||
|
||||
if (cf_next_token_should_be(&sp->cfp, "]", ";", NULL) == PARSE_EOF)
|
||||
return false;
|
||||
|
|
@ -504,7 +517,8 @@ static bool sp_parse_param_array(struct shader_parser *sp,
|
|||
}
|
||||
|
||||
static inline int sp_parse_param_assign_intfloat(struct shader_parser *sp,
|
||||
struct shader_var *param, bool is_float)
|
||||
struct shader_var *param,
|
||||
bool is_float)
|
||||
{
|
||||
int code;
|
||||
bool is_negative = false;
|
||||
|
|
@ -525,11 +539,13 @@ static inline int sp_parse_param_assign_intfloat(struct shader_parser *sp,
|
|||
|
||||
if (is_float) {
|
||||
float f = (float)os_strtod(sp->cfp.cur_token->str.array);
|
||||
if (is_negative) f = -f;
|
||||
if (is_negative)
|
||||
f = -f;
|
||||
da_push_back_array(param->default_val, &f, sizeof(float));
|
||||
} else {
|
||||
long l = strtol(sp->cfp.cur_token->str.array, NULL, 10);
|
||||
if (is_negative) l = -l;
|
||||
if (is_negative)
|
||||
l = -l;
|
||||
da_push_back_array(param->default_val, &l, sizeof(long));
|
||||
}
|
||||
|
||||
|
|
@ -541,47 +557,50 @@ static inline int sp_parse_param_assign_intfloat(struct shader_parser *sp,
|
|||
* for float3x3, float4x4, etc
|
||||
*/
|
||||
static inline int sp_parse_param_assign_float_array(struct shader_parser *sp,
|
||||
struct shader_var *param)
|
||||
struct shader_var *param)
|
||||
{
|
||||
const char *float_type = param->type+5;
|
||||
const char *float_type = param->type + 5;
|
||||
int float_count = 0, code, i;
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
if (float_type[0] < '1' || float_type[0] > '4')
|
||||
cf_adderror(&sp->cfp, "Invalid row count", LEX_ERROR,
|
||||
NULL, NULL, NULL);
|
||||
cf_adderror(&sp->cfp, "Invalid row count", LEX_ERROR, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
float_count = float_type[0]-'0';
|
||||
float_count = float_type[0] - '0';
|
||||
|
||||
if (float_type[1] == 'x') {
|
||||
if (float_type[2] < '1' || float_type[2] > '4')
|
||||
cf_adderror(&sp->cfp, "Invalid column count",
|
||||
LEX_ERROR, NULL, NULL, NULL);
|
||||
cf_adderror(&sp->cfp, "Invalid column count", LEX_ERROR,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
float_count *= float_type[2]-'0';
|
||||
float_count *= float_type[2] - '0';
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
code = cf_next_token_should_be(&sp->cfp, "{", ";", NULL);
|
||||
if (code != PARSE_SUCCESS) return code;
|
||||
if (code != PARSE_SUCCESS)
|
||||
return code;
|
||||
|
||||
for (i = 0; i < float_count; i++) {
|
||||
char *next = ((i+1) < float_count) ? "," : "}";
|
||||
char *next = ((i + 1) < float_count) ? "," : "}";
|
||||
|
||||
code = sp_parse_param_assign_intfloat(sp, param, true);
|
||||
if (code != PARSE_SUCCESS) return code;
|
||||
if (code != PARSE_SUCCESS)
|
||||
return code;
|
||||
|
||||
code = cf_next_token_should_be(&sp->cfp, next, ";", NULL);
|
||||
if (code != PARSE_SUCCESS) return code;
|
||||
if (code != PARSE_SUCCESS)
|
||||
return code;
|
||||
}
|
||||
|
||||
return PARSE_SUCCESS;
|
||||
}
|
||||
|
||||
static int sp_parse_param_assignment_val(struct shader_parser *sp,
|
||||
struct shader_var *param)
|
||||
struct shader_var *param)
|
||||
{
|
||||
if (strcmp(param->type, "int") == 0)
|
||||
return sp_parse_param_assign_intfloat(sp, param, false);
|
||||
|
|
@ -591,13 +610,13 @@ static int sp_parse_param_assignment_val(struct shader_parser *sp,
|
|||
return sp_parse_param_assign_float_array(sp, param);
|
||||
|
||||
cf_adderror(&sp->cfp, "Invalid type '$1' used for assignment",
|
||||
LEX_ERROR, param->type, NULL, NULL);
|
||||
LEX_ERROR, param->type, NULL, NULL);
|
||||
|
||||
return PARSE_CONTINUE;
|
||||
}
|
||||
|
||||
static inline bool sp_parse_param_assign(struct shader_parser *sp,
|
||||
struct shader_var *param)
|
||||
struct shader_var *param)
|
||||
{
|
||||
if (sp_parse_param_assignment_val(sp, param) != PARSE_SUCCESS)
|
||||
return false;
|
||||
|
|
@ -608,8 +627,8 @@ static inline bool sp_parse_param_assign(struct shader_parser *sp,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void sp_parse_param(struct shader_parser *sp,
|
||||
char *type, char *name, bool is_const, bool is_uniform)
|
||||
static void sp_parse_param(struct shader_parser *sp, char *type, char *name,
|
||||
bool is_const, bool is_uniform)
|
||||
{
|
||||
struct shader_var param;
|
||||
shader_var_init_param(¶m, type, name, is_uniform, is_const);
|
||||
|
|
@ -631,10 +650,10 @@ error:
|
|||
shader_var_free(¶m);
|
||||
}
|
||||
|
||||
static bool sp_get_var_specifiers(struct shader_parser *sp,
|
||||
bool *is_const, bool *is_uniform)
|
||||
static bool sp_get_var_specifiers(struct shader_parser *sp, bool *is_const,
|
||||
bool *is_uniform)
|
||||
{
|
||||
while(true) {
|
||||
while (true) {
|
||||
int code = sp_check_for_keyword(sp, "const", is_const);
|
||||
if (code == PARSE_EOF)
|
||||
return false;
|
||||
|
|
@ -654,12 +673,13 @@ static bool sp_get_var_specifiers(struct shader_parser *sp,
|
|||
}
|
||||
|
||||
static inline void report_invalid_func_keyword(struct shader_parser *sp,
|
||||
const char *name, bool val)
|
||||
const char *name, bool val)
|
||||
{
|
||||
if (val)
|
||||
cf_adderror(&sp->cfp, "'$1' keyword cannot be used with a "
|
||||
"function", LEX_ERROR,
|
||||
name, NULL, NULL);
|
||||
cf_adderror(&sp->cfp,
|
||||
"'$1' keyword cannot be used with a "
|
||||
"function",
|
||||
LEX_ERROR, name, NULL, NULL);
|
||||
}
|
||||
|
||||
static void sp_parse_other(struct shader_parser *sp)
|
||||
|
|
@ -679,8 +699,8 @@ static void sp_parse_other(struct shader_parser *sp)
|
|||
goto error;
|
||||
|
||||
if (cf_token_is(&sp->cfp, "(")) {
|
||||
report_invalid_func_keyword(sp, "const", is_const);
|
||||
report_invalid_func_keyword(sp, "uniform", is_uniform);
|
||||
report_invalid_func_keyword(sp, "const", is_const);
|
||||
report_invalid_func_keyword(sp, "uniform", is_uniform);
|
||||
|
||||
sp_parse_function(sp, type, name);
|
||||
return;
|
||||
|
|
@ -695,7 +715,7 @@ error:
|
|||
}
|
||||
|
||||
bool shader_parse(struct shader_parser *sp, const char *shader,
|
||||
const char *file)
|
||||
const char *file)
|
||||
{
|
||||
if (!cf_parser_parse(&sp->cfp, shader, file))
|
||||
return false;
|
||||
|
|
@ -713,7 +733,7 @@ bool shader_parse(struct shader_parser *sp, const char *shader,
|
|||
|
||||
} else if (cf_token_is(&sp->cfp, "{")) {
|
||||
cf_adderror(&sp->cfp, "Unexpected code segment",
|
||||
LEX_ERROR, NULL, NULL, NULL);
|
||||
LEX_ERROR, NULL, NULL, NULL);
|
||||
cf_pass_pair(&sp->cfp, '{', '}');
|
||||
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue