mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-21 07:22:21 +00:00
Merge 3d6dca1e6d into 80e779afd9
This commit is contained in:
commit
2ddb868e5d
2 changed files with 51 additions and 22 deletions
|
|
@ -1566,6 +1566,10 @@ namespace plume {
|
||||||
auto makeBarrier = [&](ID3D12Resource *resource, D3D12_RESOURCE_STATES stateBefore, D3D12_RESOURCE_STATES stateAfter, bool supportsUAV, D3D12_RESOURCE_BARRIER &resourceBarrier) {
|
auto makeBarrier = [&](ID3D12Resource *resource, D3D12_RESOURCE_STATES stateBefore, D3D12_RESOURCE_STATES stateAfter, bool supportsUAV, D3D12_RESOURCE_BARRIER &resourceBarrier) {
|
||||||
resourceBarrier = {};
|
resourceBarrier = {};
|
||||||
|
|
||||||
|
if (type == RenderCommandListType::COPY) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (stateBefore != stateAfter) {
|
if (stateBefore != stateAfter) {
|
||||||
resourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
resourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||||
resourceBarrier.Transition.StateBefore = stateBefore;
|
resourceBarrier.Transition.StateBefore = stateBefore;
|
||||||
|
|
@ -2228,11 +2232,13 @@ namespace plume {
|
||||||
|
|
||||||
this->device = device;
|
this->device = device;
|
||||||
|
|
||||||
HRESULT res = device->d3d->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d));
|
HRESULT res = device->d3d->CreateFence(1, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d));
|
||||||
if (FAILED(res)) {
|
if (FAILED(res)) {
|
||||||
fprintf(stderr, "CreateFence failed with error code 0x%lX.\n", res);
|
fprintf(stderr, "CreateFence failed with error code 0x%lX.\n", res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
semaphoreValue = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12CommandSemaphore::~D3D12CommandSemaphore() {
|
D3D12CommandSemaphore::~D3D12CommandSemaphore() {
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,10 @@ static std::unique_ptr<RenderCommandQueue> g_copyQueue;
|
||||||
static std::unique_ptr<RenderCommandList> g_copyCommandList;
|
static std::unique_ptr<RenderCommandList> g_copyCommandList;
|
||||||
static std::unique_ptr<RenderCommandFence> g_copyCommandFence;
|
static std::unique_ptr<RenderCommandFence> g_copyCommandFence;
|
||||||
|
|
||||||
|
static Mutex g_discardMutex;
|
||||||
|
static std::unique_ptr<RenderCommandList> g_discardCommandList;
|
||||||
|
static std::unique_ptr<RenderCommandFence> g_discardCommandFence;
|
||||||
|
|
||||||
static std::unique_ptr<RenderSwapChain> g_swapChain;
|
static std::unique_ptr<RenderSwapChain> g_swapChain;
|
||||||
static bool g_swapChainValid;
|
static bool g_swapChainValid;
|
||||||
|
|
||||||
|
|
@ -1725,22 +1729,9 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
|
||||||
{
|
{
|
||||||
bool redirectToVulkan = false;
|
bool redirectToVulkan = false;
|
||||||
|
|
||||||
if (deviceDescription.vendor == RenderDeviceVendor::AMD)
|
// ...
|
||||||
{
|
// There used to be driver redirections here, but they are all free from Vulkan purgatory for now...
|
||||||
// AMD Drivers before this version have a known issue where MSAA resolve targets will fail to work correctly.
|
// ...
|
||||||
// If no specific graphics API was selected, we silently destroy this one and move to the next option as it'll
|
|
||||||
// just work incorrectly otherwise and result in visual glitches and 3D rendering not working in general.
|
|
||||||
constexpr uint64_t MinimumAMDDriverVersion = 0x1F00005DC2005CULL; // 31.0.24002.92
|
|
||||||
if ((Config::GraphicsAPI == EGraphicsAPI::Auto) && (deviceDescription.driverVersion < MinimumAMDDriverVersion))
|
|
||||||
redirectToVulkan = true;
|
|
||||||
}
|
|
||||||
else if (deviceDescription.vendor == RenderDeviceVendor::INTEL)
|
|
||||||
{
|
|
||||||
// Intel drivers on D3D12 are extremely buggy, introducing various graphical glitches.
|
|
||||||
// We will redirect users to Vulkan until a workaround can be found.
|
|
||||||
if (Config::GraphicsAPI == EGraphicsAPI::Auto)
|
|
||||||
redirectToVulkan = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (redirectToVulkan)
|
if (redirectToVulkan)
|
||||||
{
|
{
|
||||||
|
|
@ -1758,10 +1749,6 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hardware resolve seems to be completely bugged on Intel D3D12 drivers.
|
|
||||||
g_hardwareResolve = (deviceDescription.vendor != RenderDeviceVendor::INTEL);
|
|
||||||
g_hardwareDepthResolve = (deviceDescription.vendor != RenderDeviceVendor::INTEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_vulkan = (interfaceFunction == CreateVulkanInterfaceWrapper);
|
g_vulkan = (interfaceFunction == CreateVulkanInterfaceWrapper);
|
||||||
|
|
@ -1850,6 +1837,12 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
|
||||||
g_copyCommandList = g_device->createCommandList(RenderCommandListType::COPY);
|
g_copyCommandList = g_device->createCommandList(RenderCommandListType::COPY);
|
||||||
g_copyCommandFence = g_device->createCommandFence();
|
g_copyCommandFence = g_device->createCommandFence();
|
||||||
|
|
||||||
|
if (!g_vulkan)
|
||||||
|
{
|
||||||
|
g_discardCommandList = g_device->createCommandList(RenderCommandListType::DIRECT);
|
||||||
|
g_discardCommandFence = g_device->createCommandFence();
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t bufferCount = 2;
|
uint32_t bufferCount = 2;
|
||||||
|
|
||||||
switch (Config::TripleBuffering)
|
switch (Config::TripleBuffering)
|
||||||
|
|
@ -3094,6 +3087,27 @@ static RenderFormat ConvertFormat(uint32_t format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DiscardTexture(GuestBaseTexture* texture, RenderTextureLayout layout)
|
||||||
|
{
|
||||||
|
if (!g_vulkan)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(g_discardMutex);
|
||||||
|
|
||||||
|
g_discardCommandList->begin();
|
||||||
|
if (texture->layout != layout)
|
||||||
|
{
|
||||||
|
g_discardCommandList->barriers(RenderBarrierStage::GRAPHICS, RenderTextureBarrier(texture->texture, layout));
|
||||||
|
texture->layout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_discardCommandList->discardTexture(texture->texture);
|
||||||
|
g_discardCommandList->end();
|
||||||
|
|
||||||
|
g_queue->executeCommandLists(g_discardCommandList.get(), g_discardCommandFence.get());
|
||||||
|
g_queue->waitForCommandFence(g_discardCommandFence.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GuestTexture* CreateTexture(uint32_t width, uint32_t height, uint32_t depth, uint32_t levels, uint32_t usage, uint32_t format, uint32_t pool, uint32_t type)
|
static GuestTexture* CreateTexture(uint32_t width, uint32_t height, uint32_t depth, uint32_t levels, uint32_t usage, uint32_t format, uint32_t pool, uint32_t type)
|
||||||
{
|
{
|
||||||
const auto texture = g_userHeap.AllocPhysical<GuestTexture>(type == 17 ? ResourceType::VolumeTexture : ResourceType::Texture);
|
const auto texture = g_userHeap.AllocPhysical<GuestTexture>(type == 17 ? ResourceType::VolumeTexture : ResourceType::Texture);
|
||||||
|
|
@ -3151,6 +3165,12 @@ static GuestTexture* CreateTexture(uint32_t width, uint32_t height, uint32_t dep
|
||||||
texture->texture->setName(fmt::format("Texture {:X}", g_memory.MapVirtual(texture)));
|
texture->texture->setName(fmt::format("Texture {:X}", g_memory.MapVirtual(texture)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (desc.flags != RenderTextureFlag::NONE)
|
||||||
|
{
|
||||||
|
DiscardTexture(texture, desc.flags == RenderTextureFlag::RENDER_TARGET ?
|
||||||
|
RenderTextureLayout::COLOR_WRITE : RenderTextureLayout::DEPTH_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3219,6 +3239,9 @@ static GuestSurface* CreateSurface(uint32_t width, uint32_t height, uint32_t for
|
||||||
surface->texture->setName(fmt::format("{} {:X}", desc.flags & RenderTextureFlag::RENDER_TARGET ? "Render Target" : "Depth Stencil", g_memory.MapVirtual(surface)));
|
surface->texture->setName(fmt::format("{} {:X}", desc.flags & RenderTextureFlag::RENDER_TARGET ? "Render Target" : "Depth Stencil", g_memory.MapVirtual(surface)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DiscardTexture(surface, desc.flags == RenderTextureFlag::RENDER_TARGET ?
|
||||||
|
RenderTextureLayout::COLOR_WRITE : RenderTextureLayout::DEPTH_WRITE);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue