mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 22:01:46 +00:00
[host] all: don't combine the downsampler rules
This commit is contained in:
parent
905fea57f0
commit
d592f13f88
6 changed files with 43 additions and 19 deletions
|
@ -51,6 +51,7 @@ struct Option
|
||||||
char * description;
|
char * description;
|
||||||
const char shortopt;
|
const char shortopt;
|
||||||
bool preset;
|
bool preset;
|
||||||
|
void * opaque;
|
||||||
|
|
||||||
enum OptionType type;
|
enum OptionType type;
|
||||||
union
|
union
|
||||||
|
@ -67,6 +68,7 @@ struct Option
|
||||||
bool (*validator)(struct Option * opt, const char ** error);
|
bool (*validator)(struct Option * opt, const char ** error);
|
||||||
char * (*toString )(struct Option * opt);
|
char * (*toString )(struct Option * opt);
|
||||||
StringList (*getValues)(struct Option * opt);
|
StringList (*getValues)(struct Option * opt);
|
||||||
|
void (*cleanup )(struct Option * opt);
|
||||||
|
|
||||||
void (*printHelp)(void);
|
void (*printHelp)(void);
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,9 @@ void option_free(void)
|
||||||
for(int i = 0; i < state.oCount; ++i)
|
for(int i = 0; i < state.oCount; ++i)
|
||||||
{
|
{
|
||||||
struct Option * o = state.options[i];
|
struct Option * o = state.options[i];
|
||||||
|
if (o->cleanup)
|
||||||
|
o->cleanup(o);
|
||||||
|
|
||||||
if (o->type == OPTION_TYPE_STRING && o->value.x_string)
|
if (o->type == OPTION_TYPE_STRING && o->value.x_string)
|
||||||
free(o->value.x_string);
|
free(o->value.x_string);
|
||||||
free(o);
|
free(o);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
const char * module;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
bool greater;
|
bool greater;
|
||||||
unsigned int x;
|
unsigned int x;
|
||||||
|
@ -33,18 +34,19 @@ typedef struct
|
||||||
}
|
}
|
||||||
DownsampleRule;
|
DownsampleRule;
|
||||||
|
|
||||||
extern Vector downsampleRules;
|
|
||||||
|
|
||||||
bool downsampleParser(struct Option * opt, const char * str);
|
bool downsampleParser(struct Option * opt, const char * str);
|
||||||
|
void downsampleCleanup(struct Option * opt);
|
||||||
|
|
||||||
DownsampleRule * downsampleRule_match(int x, int y);
|
DownsampleRule * downsampleRule_match(Vector * rules, int x, int y);
|
||||||
|
|
||||||
#define DOWNSAMPLE_PARSER(moduleName) \
|
#define DOWNSAMPLE_PARSER(moduleName, vector) \
|
||||||
{ \
|
{ \
|
||||||
.module = moduleName, \
|
.module = moduleName, \
|
||||||
.name = "downsample", \
|
.name = "downsample", \
|
||||||
.description = "Downsample rules, format: [>](width)x(height):(toWidth)x(toHeight)", \
|
.description = "Downsample rules, format: [>](width)x(height):(toWidth)x(toHeight)", \
|
||||||
.type = OPTION_TYPE_STRING, \
|
.type = OPTION_TYPE_STRING, \
|
||||||
.value.x_string = NULL, \
|
.value.x_string = NULL, \
|
||||||
.parser = downsampleParser \
|
.parser = downsampleParser, \
|
||||||
|
.cleanup = downsampleCleanup, \
|
||||||
|
.opaque = (void*)(vector) \
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,13 @@ typedef struct
|
||||||
}
|
}
|
||||||
DownsampleInst;
|
DownsampleInst;
|
||||||
|
|
||||||
|
static Vector downsampleRules = {0};
|
||||||
|
|
||||||
static void downsample_earlyInit(void)
|
static void downsample_earlyInit(void)
|
||||||
{
|
{
|
||||||
struct Option options[] =
|
struct Option options[] =
|
||||||
{
|
{
|
||||||
DOWNSAMPLE_PARSER("dxgi"),
|
DOWNSAMPLE_PARSER("dxgi", &downsampleRules),
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +100,9 @@ static bool downsample_configure(void * opaque,
|
||||||
|
|
||||||
if (!this.pshader)
|
if (!this.pshader)
|
||||||
{
|
{
|
||||||
DownsampleRule * rule = downsampleRule_match(*width, *height);
|
DownsampleRule * rule = downsampleRule_match(&downsampleRules,
|
||||||
|
*width, *height);
|
||||||
|
|
||||||
if (!rule || (rule->targetX == *width && rule->targetY == *height))
|
if (!rule || (rule->targetX == *width && rule->targetY == *height))
|
||||||
{
|
{
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
|
|
|
@ -136,11 +136,13 @@ static const char * nvfbc_getName(void)
|
||||||
return "NVFBC";
|
return "NVFBC";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Vector downsampleRules = {0};
|
||||||
|
|
||||||
static void nvfbc_initOptions(void)
|
static void nvfbc_initOptions(void)
|
||||||
{
|
{
|
||||||
struct Option options[] =
|
struct Option options[] =
|
||||||
{
|
{
|
||||||
DOWNSAMPLE_PARSER("nvfbc"),
|
DOWNSAMPLE_PARSER("nvfbc", &downsampleRules),
|
||||||
{
|
{
|
||||||
.module = "nvfbc",
|
.module = "nvfbc",
|
||||||
.name = "decoupleCursor",
|
.name = "decoupleCursor",
|
||||||
|
@ -202,12 +204,14 @@ static bool nvfbc_create(
|
||||||
|
|
||||||
static void updateScale(void)
|
static void updateScale(void)
|
||||||
{
|
{
|
||||||
DownsampleRule * rule = downsampleRule_match(this->width, this->height);
|
DownsampleRule * rule = downsampleRule_match(&downsampleRules,
|
||||||
|
this->width, this->height);
|
||||||
if (rule)
|
if (rule)
|
||||||
{
|
{
|
||||||
this->scale = true;
|
this->scale = true;
|
||||||
this->targetWidth = rule->targetX;
|
this->targetWidth = rule->targetX;
|
||||||
this->targetHeight = rule->targetY;
|
this->targetHeight = rule->targetY;
|
||||||
|
DEBUG_INFO("Downsampling to %dx%d", this->targetWidth, this->targetHeight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,11 @@ bool downsampleParser(struct Option * opt, const char * str)
|
||||||
|
|
||||||
opt->value.x_string = strdup(str);
|
opt->value.x_string = strdup(str);
|
||||||
|
|
||||||
if (downsampleRules.data)
|
Vector * downsampleRules = (Vector *)opt->opaque;
|
||||||
vector_destroy(&downsampleRules);
|
if (downsampleRules->data)
|
||||||
|
vector_destroy(downsampleRules);
|
||||||
|
|
||||||
if (!vector_create(&downsampleRules, sizeof(DownsampleRule), 10))
|
if (!vector_create(downsampleRules, sizeof(DownsampleRule), 10))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to allocate ram");
|
DEBUG_ERROR("Failed to allocate ram");
|
||||||
return false;
|
return false;
|
||||||
|
@ -53,6 +54,7 @@ bool downsampleParser(struct Option * opt, const char * str)
|
||||||
++token;
|
++token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rule.module = opt->module;
|
||||||
if (sscanf(token, "%ux%u:%ux%u",
|
if (sscanf(token, "%ux%u:%ux%u",
|
||||||
&rule.x,
|
&rule.x,
|
||||||
&rule.y,
|
&rule.y,
|
||||||
|
@ -66,7 +68,9 @@ bool downsampleParser(struct Option * opt, const char * str)
|
||||||
rule.id = count++;
|
rule.id = count++;
|
||||||
|
|
||||||
DEBUG_INFO(
|
DEBUG_INFO(
|
||||||
"Rule %u: %ux%u IF X %s %4u %s Y %s %4u",
|
"%s:%s rule %u: %ux%u IF X %s %4u %s Y %s %4u",
|
||||||
|
opt->module,
|
||||||
|
opt->name,
|
||||||
rule.id,
|
rule.id,
|
||||||
rule.targetX,
|
rule.targetX,
|
||||||
rule.targetY,
|
rule.targetY,
|
||||||
|
@ -76,7 +80,7 @@ bool downsampleParser(struct Option * opt, const char * str)
|
||||||
rule.greater ? "> " : "==",
|
rule.greater ? "> " : "==",
|
||||||
rule.y
|
rule.y
|
||||||
);
|
);
|
||||||
vector_push(&downsampleRules, &rule);
|
vector_push(downsampleRules, &rule);
|
||||||
|
|
||||||
token = strtok(NULL, ",");
|
token = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
@ -85,13 +89,19 @@ bool downsampleParser(struct Option * opt, const char * str)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DownsampleRule * downsampleRule_match(int x, int y)
|
void downsampleCleanup(struct Option * opt)
|
||||||
|
{
|
||||||
|
Vector * downsampleRules = (Vector *)opt->opaque;
|
||||||
|
if (downsampleRules->data)
|
||||||
|
vector_destroy(downsampleRules);
|
||||||
|
}
|
||||||
|
|
||||||
|
DownsampleRule * downsampleRule_match(Vector * rules, int x, int y)
|
||||||
{
|
{
|
||||||
DownsampleRule * rule, * match = NULL;
|
DownsampleRule * rule, * match = NULL;
|
||||||
vector_forEachRef(rule, &downsampleRules)
|
vector_forEachRef(rule, rules)
|
||||||
{
|
{
|
||||||
if (
|
if (( rule->greater && (x > rule->x || y > rule->y)) ||
|
||||||
( rule->greater && (x > rule->x || y > rule->y)) ||
|
|
||||||
(!rule->greater && (x == rule->x && y == rule->y)))
|
(!rule->greater && (x == rule->x && y == rule->y)))
|
||||||
{
|
{
|
||||||
match = rule;
|
match = rule;
|
||||||
|
|
Loading…
Reference in a new issue