Skip to content

Commit

Permalink
[host] downsample: fix failure to match only the backend selected
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Nov 8, 2023
1 parent 46781ee commit 5e93b70
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion host/include/downsample_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

typedef struct
{
const char * module;
unsigned int id;
bool greater;
unsigned int x;
Expand All @@ -37,7 +38,7 @@ extern Vector downsampleRules;

bool downsampleParser(struct Option * opt, const char * str);

DownsampleRule * downsampleRule_match(int x, int y);
DownsampleRule * downsampleRule_match(const char * module, int x, int y);

#define DOWNSAMPLE_PARSER(moduleName) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion host/platform/Windows/capture/DXGI/src/pp/downsample.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static bool downsample_configure(void * opaque,

if (!this.pshader)
{
DownsampleRule * rule = downsampleRule_match(*width, *height);
DownsampleRule * rule = downsampleRule_match("dxgi", *width, *height);
if (!rule || (rule->targetX == *width && rule->targetY == *height))
{
this.disabled = true;
Expand Down
3 changes: 2 additions & 1 deletion host/platform/Windows/capture/NVFBC/src/nvfbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ static bool nvfbc_create(

static void updateScale(void)
{
DownsampleRule * rule = downsampleRule_match(this->width, this->height);
DownsampleRule * rule = downsampleRule_match("nvfbc",
this->width, this->height);
if (rule)
{
this->scale = true;
Expand Down
10 changes: 6 additions & 4 deletions host/src/downsample_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ bool downsampleParser(struct Option * opt, const char * str)
++token;
}

rule.module = opt->module;
if (sscanf(token, "%ux%u:%ux%u",
&rule.x,
&rule.y,
Expand Down Expand Up @@ -85,14 +86,15 @@ bool downsampleParser(struct Option * opt, const char * str)
return true;
}

DownsampleRule * downsampleRule_match(int x, int y)
DownsampleRule * downsampleRule_match(const char * module, int x, int y)
{
DownsampleRule * rule, * match = NULL;
vector_forEachRef(rule, &downsampleRules)
{
if (
( rule->greater && (x > rule->x || y > rule->y)) ||
(!rule->greater && (x == rule->x && y == rule->y)))
if (strcmp(rule->module, module) == 0 && (
( rule->greater && (x > rule->x || y > rule->y)) ||
(!rule->greater && (x == rule->x && y == rule->y)))
)
{
match = rule;
}
Expand Down

0 comments on commit 5e93b70

Please sign in to comment.