Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/doitsujin/dxvk.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ashton <joshua@froggi.es>2020-03-02 19:43:59 +0300
committerJoshua Ashton <joshua@froggi.es>2020-03-02 19:43:59 +0300
commitd0c5a7a9e0241334e48eea0502e7fe1bedf877ce (patch)
tree3fc3cf660062816b09d57b2f8e54837df0cf409e
parentc80d609b69b706b29764c83adccc023cad80218a (diff)
[d3d9] Use deferred vector helper for subresourcesd3d9-deferred-fixed-vector
These subresources classes are non-copyable and we want to allocate a large amount of them, so we use the deferred fixed size vector here to avoid potentially doing 90 individual allocations
-rw-r--r--src/d3d9/d3d9_texture.h36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/d3d9/d3d9_texture.h b/src/d3d9/d3d9_texture.h
index abad69f3..60082ba6 100644
--- a/src/d3d9/d3d9_texture.h
+++ b/src/d3d9/d3d9_texture.h
@@ -5,11 +5,12 @@
#include "d3d9_volume.h"
#include "d3d9_util.h"
+#include "../util/util_deferred_fixed_vector.h"
+
#include <vector>
#include <list>
#include <mutex>
#include <new>
-#include <type_traits>
namespace dxvk {
@@ -18,8 +19,6 @@ namespace dxvk {
public:
- using SubresourceData = std::aligned_storage_t<sizeof(SubresourceType), alignof(SubresourceType)>;
-
D3D9BaseTexture(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc,
@@ -27,19 +26,17 @@ namespace dxvk {
: D3D9Resource<Base...> ( pDevice )
, m_texture ( pDevice, pDesc, ResourceType )
, m_lod ( 0 )
- , m_autogenFilter ( D3DTEXF_LINEAR ) {
- const uint32_t arraySlices = m_texture.Desc()->ArraySize;
- const uint32_t mipLevels = m_texture.Desc()->MipLevels;
-
- m_subresources.resize(arraySlices * mipLevels);
-
- for (uint32_t i = 0; i < arraySlices; i++) {
- for (uint32_t j = 0; j < mipLevels; j++) {
+ , m_autogenFilter ( D3DTEXF_LINEAR )
+ , m_subresources ( m_texture.Desc()->ArraySize * m_texture.Desc()->MipLevels) {
+ // These subresources classes are non-copyable and we want to allocate
+ // a large amount of them, so we use the deferred fixed size vector
+ // here to avoid potentially doing 90 individual allocations
+ for (uint32_t i = 0; i < m_texture.Desc()->ArraySize; i++) {
+ for (uint32_t j = 0; j < m_texture.Desc()->MipLevels; j++) {
const uint32_t subresource = m_texture.CalcSubresource(i, j);
- SubresourceType* subObj = this->GetSubresource(subresource);
-
- new (subObj) SubresourceType(
+ m_subresources.construct(
+ subresource,
pDevice,
&m_texture,
i, j,
@@ -48,13 +45,6 @@ namespace dxvk {
}
}
- ~D3D9BaseTexture() {
- for (uint32_t i = 0; i < m_subresources.size(); i++) {
- SubresourceType* subObj = this->GetSubresource(i);
- subObj->~SubresourceType();
- }
- }
-
DWORD STDMETHODCALLTYPE SetLOD(DWORD LODNew) final {
DWORD oldLod = m_lod;
m_lod = LODNew;
@@ -96,7 +86,7 @@ namespace dxvk {
if (unlikely(Subresource >= m_subresources.size()))
return nullptr;
- return reinterpret_cast<SubresourceType*>(&m_subresources[Subresource]);
+ return &m_subresources[Subresource];
}
protected:
@@ -106,7 +96,7 @@ namespace dxvk {
DWORD m_lod;
D3DTEXTUREFILTERTYPE m_autogenFilter;
- std::vector<SubresourceData> m_subresources;
+ deferred_fixed_vector<SubresourceType> m_subresources;
};