feat:: vsync stuff

This commit is contained in:
2026-08-23 17:14:36 -04:00
parent 3df111d9a3
commit d767a810e8
4 changed files with 31 additions and 16 deletions
+9 -12
View File
@@ -55,8 +55,6 @@ D3D11_PRIMITIVE_TOPOLOGY Renderer::g_topologies[C4JRender::PRIMITIVE_TYPE_COUNT]
};
static const unsigned int kVertexBufferSize = 0x100000;
static const unsigned int kScreenGrabWidth = 1920;
static const unsigned int kScreenGrabHeight = 1080;
static const unsigned int kThumbnailSize = 64;
static const unsigned int g_vertexStrides[C4JRender::VERTEX_TYPE_COUNT] = { 32, 16, 32, 32 };
@@ -864,7 +862,7 @@ bool Renderer::IsWidescreen()
return true;
}
void Renderer::Present()
void Renderer::Present(int ScreenWidth, int ScreenHeight)
{
PROFILER_SCOPE("Renderer::Present", "Present", MP_MAGENTA);
@@ -872,7 +870,7 @@ void Renderer::Present()
{
PROFILER_SCOPE("Renderer::Present", "ScreenGrab", MP_MAGENTA);
unsigned char *linearData = new unsigned char[kScreenGrabWidth * kScreenGrabHeight * 4];
unsigned char *linearData = new unsigned char[ScreenWidth * ScreenHeight * 4];
ID3D11Resource *backBufferResource = NULL;
ID3D11Texture2D *backBuffer = NULL;
@@ -898,13 +896,13 @@ void Renderer::Present()
m_pDeviceContext->Map(stagingTexture, 0, D3D11_MAP_READ_WRITE, 0, &mapped);
const unsigned char* src = reinterpret_cast<const unsigned char*>(mapped.pData);
for (UINT y = 0; y < kScreenGrabHeight; ++y)
for (UINT y = 0; y < ScreenHeight; ++y)
{
unsigned char *dstRow = linearData + y * kScreenGrabWidth * 4;
unsigned char *dstRow = linearData + y * ScreenWidth * 4;
const unsigned char *srcRow = src + y * mapped.RowPitch;
std::memcpy(dstRow, srcRow, kScreenGrabWidth * 4);
std::memcpy(dstRow, srcRow, ScreenWidth * 4);
for (UINT x = 0; x < kScreenGrabWidth; ++x)
for (UINT x = 0; x < ScreenWidth; ++x)
dstRow[x * 4 + 3] = 0xFF;
}
@@ -926,8 +924,8 @@ void Renderer::Present()
UTCSysTime.wSecond);
D3DXIMAGE_INFO info;
info.Width = kScreenGrabWidth;
info.Height = kScreenGrabHeight;
info.Width = ScreenWidth;
info.Height = ScreenHeight;
SaveTextureData(fileName, &info, reinterpret_cast<int*>(linearData));
delete[] linearData;
@@ -935,7 +933,7 @@ void Renderer::Present()
m_bShouldScreenGrabNextFrame = false;
}
m_pSwapChain->Present(1, 0);
m_pSwapChain->Present(C4JRender::GetVSync(), 0);
++presentCount;
}
@@ -1046,4 +1044,3 @@ Renderer::Context &Renderer::getContext()
{
return *reinterpret_cast<Renderer::Context*>(TlsGetValue(Renderer::tlsIdx));
}