mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
Vulkan/Texture: Allow uploading non-zero layers/levels
This commit is contained in:
parent
aff9f1c25f
commit
8d32547ec9
|
@ -422,7 +422,7 @@ bool Vulkan::Texture::BeginUpdate(u32 width, u32 height, void** out_buffer, u32*
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vulkan::Texture::EndUpdate(u32 x, u32 y, u32 width, u32 height)
|
void Vulkan::Texture::EndUpdate(u32 x, u32 y, u32 width, u32 height, u32 level, u32 layer)
|
||||||
{
|
{
|
||||||
const u32 pitch = CalcUpdatePitch(width);
|
const u32 pitch = CalcUpdatePitch(width);
|
||||||
const u32 required_size = pitch * height;
|
const u32 required_size = pitch * height;
|
||||||
|
@ -431,11 +431,12 @@ void Vulkan::Texture::EndUpdate(u32 x, u32 y, u32 width, u32 height)
|
||||||
const u32 buffer_offset = buffer.GetCurrentOffset();
|
const u32 buffer_offset = buffer.GetCurrentOffset();
|
||||||
buffer.CommitMemory(required_size);
|
buffer.CommitMemory(required_size);
|
||||||
|
|
||||||
UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), 0, 0, x, y, width, height, buffer.GetBuffer(),
|
UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), level, layer, x, y, width, height, buffer.GetBuffer(),
|
||||||
buffer_offset, CalcUpdateRowLength(pitch));
|
buffer_offset, CalcUpdateRowLength(pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vulkan::Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* data, u32 data_pitch)
|
bool Vulkan::Texture::Update(u32 x, u32 y, u32 width, u32 height, u32 level, u32 layer, const void* data,
|
||||||
|
u32 data_pitch)
|
||||||
{
|
{
|
||||||
const u32 pitch = CalcUpdatePitch(width);
|
const u32 pitch = CalcUpdatePitch(width);
|
||||||
const u32 row_length = CalcUpdateRowLength(pitch);
|
const u32 row_length = CalcUpdateRowLength(pitch);
|
||||||
|
@ -479,7 +480,8 @@ bool Vulkan::Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* da
|
||||||
StringUtil::StrideMemCpy(ai.pMappedData, pitch, data, data_pitch, std::min(data_pitch, pitch), height);
|
StringUtil::StrideMemCpy(ai.pMappedData, pitch, data, data_pitch, std::min(data_pitch, pitch), height);
|
||||||
vmaFlushAllocation(g_vulkan_context->GetAllocator(), allocation, 0, size);
|
vmaFlushAllocation(g_vulkan_context->GetAllocator(), allocation, 0, size);
|
||||||
|
|
||||||
UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), 0, 0, x, y, width, height, buffer, 0, row_length);
|
UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), level, layer, x, y, width, height, buffer, 0,
|
||||||
|
row_length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -499,8 +501,8 @@ bool Vulkan::Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* da
|
||||||
height);
|
height);
|
||||||
sbuffer.CommitMemory(required_size);
|
sbuffer.CommitMemory(required_size);
|
||||||
|
|
||||||
UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), 0, 0, x, y, width, height, sbuffer.GetBuffer(),
|
UpdateFromBuffer(g_vulkan_context->GetCurrentCommandBuffer(), level, layer, x, y, width, height,
|
||||||
buffer_offset, row_length);
|
sbuffer.GetBuffer(), buffer_offset, row_length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ public:
|
||||||
u32 CalcUpdatePitch(u32 width) const;
|
u32 CalcUpdatePitch(u32 width) const;
|
||||||
u32 CalcUpdateRowLength(u32 pitch) const;
|
u32 CalcUpdateRowLength(u32 pitch) const;
|
||||||
bool BeginUpdate(u32 width, u32 height, void** out_buffer, u32* out_pitch);
|
bool BeginUpdate(u32 width, u32 height, void** out_buffer, u32* out_pitch);
|
||||||
void EndUpdate(u32 x, u32 y, u32 width, u32 height);
|
void EndUpdate(u32 x, u32 y, u32 width, u32 height, u32 level, u32 layer);
|
||||||
bool Update(u32 x, u32 y, u32 width, u32 height, const void* data, u32 data_pitch);
|
bool Update(u32 x, u32 y, u32 width, u32 height, u32 level, u32 layer, const void* data, u32 data_pitch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u32 m_width = 0;
|
u32 m_width = 0;
|
||||||
|
|
|
@ -412,7 +412,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
bd->FontTexture.Update(0, 0, width, height, pixels, sizeof(u32) * width);
|
bd->FontTexture.Update(0, 0, width, height, 0, 0, pixels, sizeof(u32) * width);
|
||||||
io.Fonts->SetTexID((ImTextureID)&bd->FontTexture);
|
io.Fonts->SetTexID((ImTextureID)&bd->FontTexture);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,11 +40,11 @@ public:
|
||||||
return m_texture.BeginUpdate(width, height, out_buffer, out_pitch);
|
return m_texture.BeginUpdate(width, height, out_buffer, out_pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndUpdate(u32 x, u32 y, u32 width, u32 height) override { m_texture.EndUpdate(x, y, width, height); }
|
void EndUpdate(u32 x, u32 y, u32 width, u32 height) override { m_texture.EndUpdate(x, y, width, height, 0, 0); }
|
||||||
|
|
||||||
bool Update(u32 x, u32 y, u32 width, u32 height, const void* data, u32 pitch) override
|
bool Update(u32 x, u32 y, u32 width, u32 height, const void* data, u32 pitch) override
|
||||||
{
|
{
|
||||||
return m_texture.Update(x, y, width, height, data, pitch);
|
return m_texture.Update(x, y, width, height, 0, 0, data, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vulkan::Texture& GetTexture() const { return m_texture; }
|
const Vulkan::Texture& GetTexture() const { return m_texture; }
|
||||||
|
@ -203,7 +203,7 @@ std::unique_ptr<HostDisplayTexture> VulkanHostDisplay::CreateTexture(u32 width,
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
texture.Update(0, 0, width, height, data, data_stride);
|
texture.Update(0, 0, width, height, 0, 0, data, data_stride);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue