mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-01 16:24:12 +01:00
[d3d9] Use bitsets for bool subresource arrays
Also remove lockflag tracking and consolidate that to a bitset
This commit is contained in:
parent
960d2bd158
commit
6e9725a124
@ -6,6 +6,8 @@
|
||||
|
||||
#include "../dxvk/dxvk_device.h"
|
||||
|
||||
#include "../util/util_bit.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class D3D9DeviceEx;
|
||||
@ -86,6 +88,8 @@ namespace dxvk {
|
||||
template <typename T>
|
||||
using D3D9SubresourceArray = std::array<T, caps::MaxSubresources>;
|
||||
|
||||
using D3D9SubresourceBitset = bit::bitset<caps::MaxSubresources>;
|
||||
|
||||
class D3D9CommonTexture {
|
||||
|
||||
public:
|
||||
@ -204,22 +208,6 @@ namespace dxvk {
|
||||
D3D9DeviceEx* pDevice,
|
||||
D3D9_COMMON_TEXTURE_DESC* pDesc);
|
||||
|
||||
/**
|
||||
* \brief Lock Flags
|
||||
* Set the lock flags for a given subresource
|
||||
*/
|
||||
void SetLockFlags(UINT Subresource, DWORD Flags) {
|
||||
m_lockFlags[Subresource] = Flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Lock Flags
|
||||
* \returns The log flags for a given subresource
|
||||
*/
|
||||
DWORD GetLockFlags(UINT Subresource) const {
|
||||
return m_lockFlags[Subresource];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Shadow
|
||||
* \returns Whether the texture is to be depth compared
|
||||
@ -334,10 +322,15 @@ namespace dxvk {
|
||||
|
||||
const D3D9_VK_FORMAT_MAPPING& GetMapping() { return m_mapping; }
|
||||
|
||||
bool MarkLocked(UINT Subresource, bool value) { return std::exchange(m_locked[Subresource], value); }
|
||||
bool MarkLocked(UINT Subresource, bool value) { return m_locked.exchange(Subresource, value); }
|
||||
|
||||
bool SetDirty(UINT Subresource, bool value) { return std::exchange(m_dirty[Subresource], value); }
|
||||
void MarkAllDirty() { for (uint32_t i = 0; i < m_dirty.size(); i++) m_dirty[i] = true; }
|
||||
bool SetDirty(UINT Subresource, bool value) { return m_dirty.exchange(Subresource, value); }
|
||||
|
||||
void MarkAllDirty() { m_dirty.setAll(); }
|
||||
|
||||
void SetReadOnlyLocked(UINT Subresource, bool readOnly) { return m_readOnly.set(Subresource, readOnly); }
|
||||
|
||||
bool GetReadOnlyLocked(UINT Subresource) { return m_readOnly.get(Subresource); }
|
||||
|
||||
const Rc<DxvkImageView>& GetSampleView(bool srgb) const {
|
||||
return m_sampleView.Pick(srgb && IsSrgbCompatible());
|
||||
@ -378,7 +371,6 @@ namespace dxvk {
|
||||
Rc<DxvkBuffer>> m_buffers;
|
||||
D3D9SubresourceArray<
|
||||
DxvkBufferSliceHandle> m_mappedSlices;
|
||||
D3D9SubresourceArray<DWORD> m_lockFlags;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING m_mapping;
|
||||
|
||||
@ -394,11 +386,11 @@ namespace dxvk {
|
||||
|
||||
D3D9ColorView m_sampleView;
|
||||
|
||||
D3D9SubresourceArray<
|
||||
bool> m_locked = { };
|
||||
D3D9SubresourceBitset m_locked = { };
|
||||
|
||||
D3D9SubresourceArray<
|
||||
bool> m_dirty = { };
|
||||
D3D9SubresourceBitset m_readOnly = { };
|
||||
|
||||
D3D9SubresourceBitset m_dirty = { };
|
||||
|
||||
/**
|
||||
* \brief Mip level
|
||||
|
@ -3868,7 +3868,7 @@ namespace dxvk {
|
||||
if (desc.Usage & D3DUSAGE_WRITEONLY)
|
||||
Flags &= ~D3DLOCK_READONLY;
|
||||
|
||||
pResource->SetLockFlags(Subresource, Flags);
|
||||
pResource->SetReadOnlyLocked(Subresource, Flags & D3DLOCK_READONLY);
|
||||
|
||||
bool renderable = desc.Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL);
|
||||
|
||||
@ -4034,7 +4034,7 @@ namespace dxvk {
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
// Do we have a pending copy?
|
||||
if (!(pResource->GetLockFlags(Subresource) & D3DLOCK_READONLY)) {
|
||||
if (!pResource->GetReadOnlyLocked(Subresource)) {
|
||||
// Only flush buffer -> image if we actually have an image
|
||||
if (pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED)
|
||||
this->FlushImage(pResource, Subresource);
|
||||
|
Loading…
Reference in New Issue
Block a user