mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[host] d12: Use the gpu reported pitch instead of assuming w * 4
This commit is contained in:
parent
66049cf763
commit
2f3ca443cf
@ -62,6 +62,7 @@ struct D12Interface
|
|||||||
// capture format tracking
|
// capture format tracking
|
||||||
D3D12_RESOURCE_DESC captureFormat;
|
D3D12_RESOURCE_DESC captureFormat;
|
||||||
unsigned formatVer;
|
unsigned formatVer;
|
||||||
|
unsigned pitch;
|
||||||
|
|
||||||
// output format tracking
|
// output format tracking
|
||||||
D3D12_RESOURCE_DESC dstFormat;
|
D3D12_RESOURCE_DESC dstFormat;
|
||||||
@ -441,7 +442,6 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
D3D12_RESOURCE_DESC srcFormat = ID3D12Resource_GetDesc(*src);
|
D3D12_RESOURCE_DESC srcFormat = ID3D12Resource_GetDesc(*src);
|
||||||
D3D12_RESOURCE_DESC dstFormat = this->dstFormat;
|
D3D12_RESOURCE_DESC dstFormat = this->dstFormat;
|
||||||
|
|
||||||
@ -475,7 +475,19 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int maxRows = maxFrameSize / (dstFormat.Width * 4);
|
D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout;
|
||||||
|
ID3D12Device3_GetCopyableFootprints(*this->device,
|
||||||
|
&srcFormat,
|
||||||
|
0 , // FirstSubresource
|
||||||
|
1 , // NumSubresources
|
||||||
|
0 , // BaseOffset,
|
||||||
|
&layout , // pLayouts
|
||||||
|
NULL , // pNumRows,
|
||||||
|
NULL , // pRowSizeInBytes,
|
||||||
|
NULL); // pTotalBytes
|
||||||
|
this->pitch = layout.Footprint.RowPitch;
|
||||||
|
|
||||||
|
const unsigned int maxRows = maxFrameSize / layout.Footprint.RowPitch;
|
||||||
|
|
||||||
frame->formatVer = this->formatVer;
|
frame->formatVer = this->formatVer;
|
||||||
frame->screenWidth = srcFormat.Width;
|
frame->screenWidth = srcFormat.Width;
|
||||||
@ -485,8 +497,8 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex,
|
|||||||
frame->frameWidth = srcFormat.Width;
|
frame->frameWidth = srcFormat.Width;
|
||||||
frame->frameHeight = srcFormat.Height;
|
frame->frameHeight = srcFormat.Height;
|
||||||
frame->truncated = maxRows < dstFormat.Height;
|
frame->truncated = maxRows < dstFormat.Height;
|
||||||
frame->pitch = dstFormat.Width * 4;
|
frame->pitch = layout.Footprint.RowPitch;
|
||||||
frame->stride = dstFormat.Width;
|
frame->stride = layout.Footprint.RowPitch / 4;
|
||||||
frame->format = this->allowRGB24 ?
|
frame->format = this->allowRGB24 ?
|
||||||
CAPTURE_FMT_BGR_32 : CAPTURE_FMT_BGRA;
|
CAPTURE_FMT_BGR_32 : CAPTURE_FMT_BGRA;
|
||||||
frame->hdr = false;
|
frame->hdr = false;
|
||||||
@ -584,7 +596,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
|||||||
.Width = this->dstFormat.Width,
|
.Width = this->dstFormat.Width,
|
||||||
.Height = this->dstFormat.Height,
|
.Height = this->dstFormat.Height,
|
||||||
.Depth = 1,
|
.Depth = 1,
|
||||||
.RowPitch = this->dstFormat.Width * 4
|
.RowPitch = this->pitch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -678,7 +690,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex,
|
|||||||
|
|
||||||
// signal the frame is complete
|
// signal the frame is complete
|
||||||
framebuffer_set_write_ptr(frameBuffer,
|
framebuffer_set_write_ptr(frameBuffer,
|
||||||
this->dstFormat.Height * this->dstFormat.Width * 4);
|
this->dstFormat.Height * this->pitch);
|
||||||
|
|
||||||
// reset the command queues
|
// reset the command queues
|
||||||
if (this->allowRGB24)
|
if (this->allowRGB24)
|
||||||
|
Loading…
Reference in New Issue
Block a user