mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 07:24:15 +01:00
[d3d9] Implement PreLoad for buffers + textures
This commit is contained in:
parent
86c53bb9e6
commit
b1bd3597a4
@ -33,6 +33,10 @@ namespace dxvk {
|
|||||||
return m_buffer.Unlock();
|
return m_buffer.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE PreLoad() final {
|
||||||
|
m_buffer.PreLoad();
|
||||||
|
}
|
||||||
|
|
||||||
D3D9CommonBuffer* GetCommonBuffer() {
|
D3D9CommonBuffer* GetCommonBuffer() {
|
||||||
return &m_buffer;
|
return &m_buffer;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,16 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D9CommonBuffer::PreLoad() {
|
||||||
|
if (IsPoolManaged(m_desc.Pool)) {
|
||||||
|
auto lock = m_parent->LockDevice();
|
||||||
|
|
||||||
|
if (NeedsUpload())
|
||||||
|
m_parent->FlushBuffer(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Rc<DxvkBuffer> D3D9CommonBuffer::CreateBuffer() const {
|
Rc<DxvkBuffer> D3D9CommonBuffer::CreateBuffer() const {
|
||||||
DxvkBufferCreateInfo info;
|
DxvkBufferCreateInfo info;
|
||||||
info.size = m_desc.Size;
|
info.size = m_desc.Size;
|
||||||
|
@ -163,6 +163,8 @@ namespace dxvk {
|
|||||||
return locked;
|
return locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreLoad();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Rc<DxvkBuffer> CreateBuffer() const;
|
Rc<DxvkBuffer> CreateBuffer() const;
|
||||||
|
@ -465,6 +465,27 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D9CommonTexture::PreLoadAll() {
|
||||||
|
if (IsManaged()) {
|
||||||
|
auto lock = m_device->LockDevice();
|
||||||
|
|
||||||
|
m_device->UploadManagedTexture(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D9CommonTexture::PreLoadSubresource(UINT Subresource) {
|
||||||
|
if (IsManaged()) {
|
||||||
|
auto lock = m_device->LockDevice();
|
||||||
|
|
||||||
|
if (GetNeedsUpload(Subresource)) {
|
||||||
|
m_device->FlushImage(this, Subresource);
|
||||||
|
SetNeedsUpload(Subresource, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D9CommonTexture::CreateSampleView(UINT Lod) {
|
void D3D9CommonTexture::CreateSampleView(UINT Lod) {
|
||||||
// This will be a no-op for SYSTEMMEM types given we
|
// This will be a no-op for SYSTEMMEM types given we
|
||||||
// don't expose the cap to allow texturing with them.
|
// don't expose the cap to allow texturing with them.
|
||||||
|
@ -355,6 +355,7 @@ namespace dxvk {
|
|||||||
bool GetUploading(UINT Subresource) const { return m_uploading.get(Subresource); }
|
bool GetUploading(UINT Subresource) const { return m_uploading.get(Subresource); }
|
||||||
|
|
||||||
void SetNeedsUpload(UINT Subresource, bool upload) { m_needsUpload.set(Subresource, upload); }
|
void SetNeedsUpload(UINT Subresource, bool upload) { m_needsUpload.set(Subresource, upload); }
|
||||||
|
bool GetNeedsUpload(UINT Subresource) const { return m_needsUpload.get(Subresource); }
|
||||||
bool NeedsAnyUpload() { return m_needsUpload.any(); }
|
bool NeedsAnyUpload() { return m_needsUpload.any(); }
|
||||||
void ClearNeedsUpload() { return m_needsUpload.clearAll(); }
|
void ClearNeedsUpload() { return m_needsUpload.clearAll(); }
|
||||||
|
|
||||||
@ -366,6 +367,9 @@ namespace dxvk {
|
|||||||
void SetMipFilter(D3DTEXTUREFILTERTYPE filter) { m_mipFilter = filter; }
|
void SetMipFilter(D3DTEXTUREFILTERTYPE filter) { m_mipFilter = filter; }
|
||||||
D3DTEXTUREFILTERTYPE GetMipFilter() const { return m_mipFilter; }
|
D3DTEXTUREFILTERTYPE GetMipFilter() const { return m_mipFilter; }
|
||||||
|
|
||||||
|
void PreLoadAll();
|
||||||
|
void PreLoadSubresource(UINT Subresource);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
D3D9DeviceEx* m_device;
|
D3D9DeviceEx* m_device;
|
||||||
|
@ -4120,6 +4120,7 @@ namespace dxvk {
|
|||||||
(!atiHack) ? formatInfo : nullptr,
|
(!atiHack) ? formatInfo : nullptr,
|
||||||
pBox);
|
pBox);
|
||||||
|
|
||||||
|
|
||||||
uint8_t* data = reinterpret_cast<uint8_t*>(physSlice.mapPtr);
|
uint8_t* data = reinterpret_cast<uint8_t*>(physSlice.mapPtr);
|
||||||
data += offset;
|
data += offset;
|
||||||
pLockedBox->pBits = data;
|
pLockedBox->pBits = data;
|
||||||
@ -4886,22 +4887,24 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D9DeviceEx::UploadManagedTextures(uint32_t mask) {
|
void D3D9DeviceEx::UploadManagedTexture(D3D9CommonTexture* pResource) {
|
||||||
for (uint32_t tex = mask; tex; tex &= tex - 1) {
|
for (uint32_t i = 0; i < pResource->GetUploadBitmask().dwordCount(); i++) {
|
||||||
// Guaranteed to not be nullptr...
|
for (uint32_t subresources = pResource->GetUploadBitmask().dword(i); subresources; subresources &= subresources - 1) {
|
||||||
auto texInfo = GetCommonTexture(m_state.textures[bit::tzcnt(tex)]);
|
uint32_t subresource = i * 32 + bit::tzcnt(subresources);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < texInfo->GetUploadBitmask().dwordCount(); i++) {
|
this->FlushImage(pResource, subresource);
|
||||||
for (uint32_t subresources = texInfo->GetUploadBitmask().dword(i); subresources; subresources &= subresources - 1) {
|
|
||||||
uint32_t subresource = i * 32 + bit::tzcnt(subresources);
|
|
||||||
|
|
||||||
this->FlushImage(texInfo, subresource);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
texInfo->ClearNeedsUpload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pResource->ClearNeedsUpload();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D9DeviceEx::UploadManagedTextures(uint32_t mask) {
|
||||||
|
// Guaranteed to not be nullptr...
|
||||||
|
for (uint32_t tex = mask; tex; tex &= tex - 1)
|
||||||
|
UploadManagedTexture(GetCommonTexture(m_state.textures[bit::tzcnt(tex)]));
|
||||||
|
|
||||||
m_activeTexturesToUpload &= ~mask;
|
m_activeTexturesToUpload &= ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,6 +748,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
void MarkRenderHazards();
|
void MarkRenderHazards();
|
||||||
|
|
||||||
|
void UploadManagedTexture(D3D9CommonTexture* pResource);
|
||||||
|
|
||||||
void UploadManagedTextures(uint32_t mask);
|
void UploadManagedTextures(uint32_t mask);
|
||||||
|
|
||||||
void GenerateTextureMips(uint32_t mask);
|
void GenerateTextureMips(uint32_t mask);
|
||||||
|
@ -70,9 +70,6 @@ namespace dxvk {
|
|||||||
return m_priority;
|
return m_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STDMETHODCALLTYPE PreLoad() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -52,6 +52,10 @@ namespace dxvk {
|
|||||||
return this->GetDevice()->QueryInterface(riid, ppContainer);
|
return this->GetDevice()->QueryInterface(riid, ppContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE PreLoad() {
|
||||||
|
m_texture->PreLoadSubresource(GetSubresource());
|
||||||
|
}
|
||||||
|
|
||||||
D3D9CommonTexture* GetCommonTexture() {
|
D3D9CommonTexture* GetCommonTexture() {
|
||||||
return m_texture;
|
return m_texture;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,10 @@ namespace dxvk {
|
|||||||
this->m_parent->EmitGenerateMips(&m_texture);
|
this->m_parent->EmitGenerateMips(&m_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE PreLoad() final {
|
||||||
|
m_texture.PreLoadAll();
|
||||||
|
}
|
||||||
|
|
||||||
D3D9CommonTexture* GetCommonTexture() {
|
D3D9CommonTexture* GetCommonTexture() {
|
||||||
return &m_texture;
|
return &m_texture;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user