[dxvk] Implement proper graphics and compute state validation

Fixes crashes in various games, including Fallout 4.
This commit is contained in:
Philip Rebohle 2018-02-24 23:56:12 +01:00
parent eadf74264b
commit e8c98eac95
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 25 additions and 6 deletions

View File

@ -644,7 +644,7 @@ namespace dxvk {
uint32_t z) {
this->commitComputeState();
if (m_cpActivePipeline != VK_NULL_HANDLE) {
if (this->validateComputeState()) {
m_cmd->cmdDispatch(x, y, z);
this->commitComputeBarriers();
@ -658,7 +658,7 @@ namespace dxvk {
auto physicalSlice = buffer.physicalSlice();
if (m_cpActivePipeline != VK_NULL_HANDLE) {
if (this->validateComputeState()) {
m_cmd->cmdDispatchIndirect(
physicalSlice.handle(),
physicalSlice.offset());
@ -675,7 +675,7 @@ namespace dxvk {
uint32_t firstInstance) {
this->commitGraphicsState();
if (m_gpActivePipeline != VK_NULL_HANDLE) {
if (this->validateGraphicsState()) {
m_cmd->cmdDraw(
vertexCount, instanceCount,
firstVertex, firstInstance);
@ -689,7 +689,7 @@ namespace dxvk {
uint32_t stride) {
this->commitGraphicsState();
if (m_gpActivePipeline != VK_NULL_HANDLE) {
if (this->validateGraphicsState()) {
auto physicalSlice = buffer.physicalSlice();
m_cmd->cmdDrawIndirect(
@ -708,7 +708,7 @@ namespace dxvk {
uint32_t firstInstance) {
this->commitGraphicsState();
if (m_gpActivePipeline != VK_NULL_HANDLE) {
if (this->validateGraphicsState()) {
m_cmd->cmdDrawIndexed(
indexCount, instanceCount,
firstIndex, vertexOffset,
@ -723,7 +723,7 @@ namespace dxvk {
uint32_t stride) {
this->commitGraphicsState();
if (m_gpActivePipeline != VK_NULL_HANDLE) {
if (this->validateGraphicsState()) {
auto physicalSlice = buffer.physicalSlice();
m_cmd->cmdDrawIndexedIndirect(
@ -1644,6 +1644,22 @@ namespace dxvk {
}
bool DxvkContext::validateComputeState() {
return m_cpActivePipeline != nullptr;
}
bool DxvkContext::validateGraphicsState() {
if (m_gpActivePipeline == nullptr)
return false;
if (!m_flags.test(DxvkContextFlag::GpRenderPassBound))
return false;
return true;
}
void DxvkContext::commitComputeState() {
this->renderPassEnd();
this->updateComputePipeline();

View File

@ -616,6 +616,9 @@ namespace dxvk {
void updateIndexBufferBinding();
void updateVertexBufferBindings();
bool validateComputeState();
bool validateGraphicsState();
void commitComputeState();
void commitGraphicsState();