mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 22:24:15 +01:00
[d3d11] Enabled command stream thread
This commit is contained in:
parent
7d7cc1ceda
commit
6ab7897127
@ -14,7 +14,6 @@ namespace dxvk {
|
||||
Rc<DxvkDevice> device)
|
||||
: m_parent (parent),
|
||||
m_device (device),
|
||||
m_context (m_device->createContext()),
|
||||
m_csChunk (new DxvkCsChunk()) {
|
||||
// Create default state objects. We won't ever return them
|
||||
// to the application, but we'll use them to apply state.
|
||||
|
@ -518,7 +518,6 @@ namespace dxvk {
|
||||
D3D11Device* const m_parent;
|
||||
|
||||
Rc<DxvkDevice> m_device;
|
||||
Rc<DxvkContext> m_context;
|
||||
Rc<DxvkCsChunk> m_csChunk;
|
||||
Rc<DxvkSampler> m_defaultSampler;
|
||||
|
||||
|
@ -7,13 +7,16 @@ namespace dxvk {
|
||||
D3D11ImmediateContext::D3D11ImmediateContext(
|
||||
D3D11Device* parent,
|
||||
Rc<DxvkDevice> device)
|
||||
: D3D11DeviceContext(parent, device) {
|
||||
: D3D11DeviceContext(parent, device),
|
||||
m_csThread(device->createContext()) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
D3D11ImmediateContext::~D3D11ImmediateContext() {
|
||||
|
||||
Flush();
|
||||
SynchronizeCs();
|
||||
Synchronize();
|
||||
}
|
||||
|
||||
|
||||
@ -113,6 +116,7 @@ namespace dxvk {
|
||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
||||
|
||||
Flush();
|
||||
SynchronizeCs();
|
||||
Synchronize();
|
||||
}
|
||||
}
|
||||
@ -189,6 +193,7 @@ namespace dxvk {
|
||||
});
|
||||
|
||||
Flush();
|
||||
SynchronizeCs();
|
||||
Synchronize();
|
||||
|
||||
physicalSlice = textureInfo->imageBuffer->slice();
|
||||
@ -247,16 +252,15 @@ namespace dxvk {
|
||||
|
||||
|
||||
void D3D11ImmediateContext::SynchronizeCs() {
|
||||
// Dispatch recorded commands first,
|
||||
EmitCsChunk();
|
||||
|
||||
// TODO synchronize with CS thread
|
||||
m_csThread.synchronize();
|
||||
}
|
||||
|
||||
|
||||
void D3D11ImmediateContext::EmitCsChunk() {
|
||||
if (m_csChunk->commandCount() > 0) {
|
||||
m_csChunk->executeAll(m_context.ptr());
|
||||
m_csThread.dispatchChunk(std::move(m_csChunk));
|
||||
m_csChunk = new DxvkCsChunk();
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
DxvkCsThread m_csThread;
|
||||
|
||||
void Synchronize();
|
||||
void SynchronizeCs();
|
||||
|
||||
|
@ -43,6 +43,7 @@ namespace dxvk {
|
||||
void DxvkCsThread::dispatchChunk(Rc<DxvkCsChunk>&& chunk) {
|
||||
{ std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_chunks.push(std::move(chunk));
|
||||
m_chunksPending += 1;
|
||||
}
|
||||
|
||||
m_condOnAdd.notify_one();
|
||||
@ -53,7 +54,7 @@ namespace dxvk {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
m_condOnSync.wait(lock, [this] {
|
||||
return m_chunks.size() == 0;
|
||||
return m_chunksPending == 0;
|
||||
});
|
||||
}
|
||||
|
||||
@ -71,14 +72,20 @@ namespace dxvk {
|
||||
if (m_chunks.size() != 0) {
|
||||
chunk = std::move(m_chunks.front());
|
||||
m_chunks.pop();
|
||||
|
||||
if (m_chunks.size() == 0)
|
||||
m_condOnSync.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk != nullptr)
|
||||
if (chunk != nullptr) {
|
||||
chunk->executeAll(m_context.ptr());
|
||||
|
||||
const bool doNotify = [this] {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
return --m_chunksPending == 0;
|
||||
}();
|
||||
|
||||
if (doNotify)
|
||||
m_condOnSync.notify_one();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,6 +174,8 @@ namespace dxvk {
|
||||
std::queue<Rc<DxvkCsChunk>> m_chunks;
|
||||
std::thread m_thread;
|
||||
|
||||
uint32_t m_chunksPending = 0;
|
||||
|
||||
void threadFunc();
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user