Skip to content

Commit

Permalink
[host] dxgi: fix comRef leak in the downsampler
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Nov 7, 2023
1 parent 9b44b85 commit 646c1db
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions host/platform/Windows/capture/DXGI/src/pp/downsample.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ static bool downsample_configure(void * opaque,
int * cols , int * rows ,
CaptureFormat * format)
{
bool result = false;
DownsampleInst * inst = (DownsampleInst *)opaque;

if (*format == CAPTURE_FMT_BGR)
this.disabled = true;

if (this.disabled)
return true;
{
result = true;
goto exit;
}

HRESULT status;
comRef_scopePush();
Expand All @@ -101,7 +106,8 @@ static bool downsample_configure(void * opaque,
if (!rule || (rule->targetX == *width && rule->targetY == *height))
{
this.disabled = true;
return true;
result = true;
goto exit;
}

this.width = rule->targetX;
Expand All @@ -122,7 +128,7 @@ static bool downsample_configure(void * opaque,

comRef_defineLocal(ID3DBlob, byteCode);
if (!compileShader(byteCode, "main", "ps_5_0", pshaderSrc, NULL))
goto fail;
goto exit;

comRef_defineLocal(ID3D11PixelShader, pshader);
HRESULT status = ID3D11Device_CreatePixelShader(
Expand All @@ -135,7 +141,7 @@ static bool downsample_configure(void * opaque,
if (FAILED(status))
{
DEBUG_WINERROR("Failed to create the pixel shader", status);
goto fail;
goto exit;
}

const D3D11_SAMPLER_DESC samplerDesc =
Expand All @@ -155,7 +161,7 @@ static bool downsample_configure(void * opaque,
if (FAILED(status))
{
DEBUG_WINERROR("Failed to create the sampler state", status);
goto fail;
goto exit;
}

comRef_toGlobal(this.pshader, pshader);
Expand Down Expand Up @@ -191,7 +197,7 @@ static bool downsample_configure(void * opaque,
if (FAILED(status))
{
DEBUG_WINERROR("Failed to create the output texture", status);
goto fail;
goto exit;
}

comRef_defineLocal(ID3D11RenderTargetView, target);
Expand All @@ -201,7 +207,7 @@ static bool downsample_configure(void * opaque,
if (FAILED(status))
{
DEBUG_WINERROR("Failed to create the render target view", status);
goto fail;
goto exit;
}

*width = *cols = this.width;
Expand All @@ -210,12 +216,9 @@ static bool downsample_configure(void * opaque,
comRef_toGlobal(inst->tex , tex );
comRef_toGlobal(inst->target , target );

exit:
comRef_scopePop();
return true;

fail:
comRef_scopePop();
return false;
return result;
}

static bool downsample_init(void ** opaque)
Expand Down

0 comments on commit 646c1db

Please sign in to comment.