mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-26 08:36:28 +00:00
[idd] driver: pre-calculae addresses of structs and offsets
This commit is contained in:
parent
4e951184f1
commit
f4df3f0ec7
@ -547,6 +547,7 @@ bool CIndirectDeviceContext::SetupLGMP(size_t alignSize)
|
|||||||
DEBUG_INFO("Max Frame Size: %u MiB", (unsigned int)(m_maxFrameSize / 1048576LL));
|
DEBUG_INFO("Max Frame Size: %u MiB", (unsigned int)(m_maxFrameSize / 1048576LL));
|
||||||
|
|
||||||
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)
|
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)
|
||||||
|
{
|
||||||
if ((status = lgmpHostMemAllocAligned(m_lgmp, (uint32_t)m_maxFrameSize,
|
if ((status = lgmpHostMemAllocAligned(m_lgmp, (uint32_t)m_maxFrameSize,
|
||||||
(uint32_t)m_alignSize, &m_frameMemory[i])) != LGMP_OK)
|
(uint32_t)m_alignSize, &m_frameMemory[i])) != LGMP_OK)
|
||||||
{
|
{
|
||||||
@ -554,6 +555,16 @@ bool CIndirectDeviceContext::SetupLGMP(size_t alignSize)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_frame[i] = (KVMFRFrame *)lgmpHostMemPtr(m_frameMemory[i]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* put the framebuffer on the border of the next page, this is to allow for
|
||||||
|
* aligned DMA tranfers by the reciever */
|
||||||
|
const size_t alignOffset = alignSize - sizeof(FrameBuffer);
|
||||||
|
m_frame[i]->offset = (uint32_t)alignOffset;
|
||||||
|
m_frameBuffer[i] = (FrameBuffer*)(((uint8_t*)m_frame[i]) + alignOffset);
|
||||||
|
}
|
||||||
|
|
||||||
WDF_TIMER_CONFIG config;
|
WDF_TIMER_CONFIG config;
|
||||||
WDF_TIMER_CONFIG_INIT_PERIODIC(&config,
|
WDF_TIMER_CONFIG_INIT_PERIODIC(&config,
|
||||||
[](WDFTIMER timer) -> void
|
[](WDFTIMER timer) -> void
|
||||||
@ -658,16 +669,6 @@ void CIndirectDeviceContext::LGMPTimer()
|
|||||||
ResendCursor();
|
ResendCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: this should not really be done here, this is a hack
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable: 4200)
|
|
||||||
struct FrameBuffer
|
|
||||||
{
|
|
||||||
volatile uint32_t wp;
|
|
||||||
uint8_t data[0];
|
|
||||||
};
|
|
||||||
#pragma warning(pop)
|
|
||||||
|
|
||||||
CIndirectDeviceContext::PreparedFrameBuffer CIndirectDeviceContext::PrepareFrameBuffer(int width, int height, int pitch, DXGI_FORMAT format)
|
CIndirectDeviceContext::PreparedFrameBuffer CIndirectDeviceContext::PrepareFrameBuffer(int width, int height, int pitch, DXGI_FORMAT format)
|
||||||
{
|
{
|
||||||
PreparedFrameBuffer result = {};
|
PreparedFrameBuffer result = {};
|
||||||
@ -687,7 +688,7 @@ CIndirectDeviceContext::PreparedFrameBuffer CIndirectDeviceContext::PrepareFrame
|
|||||||
if (++m_frameIndex == LGMP_Q_FRAME_LEN)
|
if (++m_frameIndex == LGMP_Q_FRAME_LEN)
|
||||||
m_frameIndex = 0;
|
m_frameIndex = 0;
|
||||||
|
|
||||||
KVMFRFrame * fi = (KVMFRFrame *)lgmpHostMemPtr(m_frameMemory[m_frameIndex]);
|
KVMFRFrame * fi = m_frame[m_frameIndex];
|
||||||
|
|
||||||
// wait until there is room in the queue
|
// wait until there is room in the queue
|
||||||
while (lgmpHostQueuePending(m_frameQueue) == LGMP_Q_FRAME_LEN)
|
while (lgmpHostQueuePending(m_frameQueue) == LGMP_Q_FRAME_LEN)
|
||||||
@ -720,12 +721,12 @@ CIndirectDeviceContext::PreparedFrameBuffer CIndirectDeviceContext::PrepareFrame
|
|||||||
fi->frameHeight = height;
|
fi->frameHeight = height;
|
||||||
fi->stride = width * bpp;
|
fi->stride = width * bpp;
|
||||||
fi->pitch = pitch;
|
fi->pitch = pitch;
|
||||||
fi->offset = (uint32_t)(m_alignSize - sizeof(FrameBuffer));
|
// fi->offset is initialized at startup
|
||||||
fi->flags = 0;
|
fi->flags = 0;
|
||||||
fi->rotation = FRAME_ROT_0;
|
fi->rotation = FRAME_ROT_0;
|
||||||
fi->damageRectsCount = 0;
|
fi->damageRectsCount = 0;
|
||||||
|
|
||||||
FrameBuffer* fb = (FrameBuffer*)(((uint8_t*)fi) + fi->offset);
|
FrameBuffer* fb = m_frameBuffer[m_frameIndex];
|
||||||
fb->wp = 0;
|
fb->wp = 0;
|
||||||
|
|
||||||
lgmpHostQueuePost(m_frameQueue, 0, m_frameMemory[m_frameIndex]);
|
lgmpHostQueuePost(m_frameQueue, 0, m_frameMemory[m_frameIndex]);
|
||||||
@ -739,8 +740,7 @@ CIndirectDeviceContext::PreparedFrameBuffer CIndirectDeviceContext::PrepareFrame
|
|||||||
|
|
||||||
void CIndirectDeviceContext::WriteFrameBuffer(unsigned frameIndex, void* src, size_t offset, size_t len, bool setWritePos)
|
void CIndirectDeviceContext::WriteFrameBuffer(unsigned frameIndex, void* src, size_t offset, size_t len, bool setWritePos)
|
||||||
{
|
{
|
||||||
KVMFRFrame * fi = (KVMFRFrame*)lgmpHostMemPtr(m_frameMemory[frameIndex]);
|
FrameBuffer * fb = m_frameBuffer[frameIndex];
|
||||||
FrameBuffer * fb = (FrameBuffer*)(((uint8_t*)fi) + fi->offset);
|
|
||||||
|
|
||||||
memcpy(
|
memcpy(
|
||||||
(void *)((uintptr_t)fb->data + offset),
|
(void *)((uintptr_t)fb->data + offset),
|
||||||
@ -753,8 +753,7 @@ void CIndirectDeviceContext::WriteFrameBuffer(unsigned frameIndex, void* src, si
|
|||||||
|
|
||||||
void CIndirectDeviceContext::FinalizeFrameBuffer(unsigned frameIndex)
|
void CIndirectDeviceContext::FinalizeFrameBuffer(unsigned frameIndex)
|
||||||
{
|
{
|
||||||
KVMFRFrame * fi = (KVMFRFrame*)lgmpHostMemPtr(m_frameMemory[frameIndex]);
|
FrameBuffer * fb = m_frameBuffer[frameIndex];
|
||||||
FrameBuffer * fb = (FrameBuffer *)(((uint8_t*)fi) + fi->offset);
|
|
||||||
fb->wp = m_height * m_pitch;
|
fb->wp = m_height * m_pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,16 @@ extern "C" {
|
|||||||
#define MAX_POINTER_SIZE (sizeof(KVMFRCursor) + (512 * 512 * 4))
|
#define MAX_POINTER_SIZE (sizeof(KVMFRCursor) + (512 * 512 * 4))
|
||||||
#define POINTER_SHAPE_BUFFERS 3
|
#define POINTER_SHAPE_BUFFERS 3
|
||||||
|
|
||||||
|
//FIXME: this should not really be done here, this is a hack
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4200)
|
||||||
|
struct FrameBuffer
|
||||||
|
{
|
||||||
|
volatile uint32_t wp;
|
||||||
|
uint8_t data[0];
|
||||||
|
};
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
class CIndirectDeviceContext
|
class CIndirectDeviceContext
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -64,6 +74,8 @@ private:
|
|||||||
uint32_t m_formatVer = 0;
|
uint32_t m_formatVer = 0;
|
||||||
uint32_t m_frameSerial = 0;
|
uint32_t m_frameSerial = 0;
|
||||||
PLGMPMemory m_frameMemory[LGMP_Q_FRAME_LEN] = {};
|
PLGMPMemory m_frameMemory[LGMP_Q_FRAME_LEN] = {};
|
||||||
|
KVMFRFrame * m_frame [LGMP_Q_FRAME_LEN] = {};
|
||||||
|
FrameBuffer * m_frameBuffer[LGMP_Q_FRAME_LEN] = {};
|
||||||
|
|
||||||
int m_width = 0;
|
int m_width = 0;
|
||||||
int m_height = 0;
|
int m_height = 0;
|
||||||
|
@ -250,12 +250,7 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
|||||||
D3D12_TEXTURE_COPY_LOCATION dstLoc = {};
|
D3D12_TEXTURE_COPY_LOCATION dstLoc = {};
|
||||||
dstLoc.pResource = fbRes->Get().Get();
|
dstLoc.pResource = fbRes->Get().Get();
|
||||||
dstLoc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
dstLoc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||||
dstLoc.PlacedFootprint.Offset = 0;
|
dstLoc.PlacedFootprint = layout;
|
||||||
dstLoc.PlacedFootprint.Footprint.Format = desc.Format;
|
|
||||||
dstLoc.PlacedFootprint.Footprint.Width = (UINT)desc.Width;
|
|
||||||
dstLoc.PlacedFootprint.Footprint.Height = (UINT)desc.Height;
|
|
||||||
dstLoc.PlacedFootprint.Footprint.Depth = 1;
|
|
||||||
dstLoc.PlacedFootprint.Footprint.RowPitch = layout.Footprint.RowPitch;
|
|
||||||
|
|
||||||
srcRes->Sync(*copyQueue);
|
srcRes->Sync(*copyQueue);
|
||||||
copyQueue->GetGfxList()->CopyTextureRegion(
|
copyQueue->GetGfxList()->CopyTextureRegion(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user