Permalink
Browse files

Make VulkanTexture "immutable".

  • Loading branch information...
hrydgard committed Nov 1, 2017
1 parent d0f3282 commit 96cd36887825ee225f51c4c2c5edb598c3828e86
@@ -358,14 +358,6 @@ void VulkanTexture::EndCreate(VkCommandBuffer cmd) {
VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT);
}
void VulkanTexture::TransitionForUpload(VkCommandBuffer cmd) {
TransitionImageLayout2(cmd, image,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_SHADER_READ_BIT, VK_ACCESS_TRANSFER_WRITE_BIT);
}
void VulkanTexture::Destroy() {
if (view != VK_NULL_HANDLE) {
vulkan_->Delete().QueueDeleteImageView(view);
@@ -35,9 +35,6 @@ class VulkanTexture {
void UploadMip(VkCommandBuffer cmd, int mip, int mipWidth, int mipHeight, VkBuffer buffer, uint32_t offset, size_t rowLength); // rowLength is in pixels
void EndCreate(VkCommandBuffer cmd);
// Dangerous.
void TransitionForUpload(VkCommandBuffer cmd);
int GetNumMips() const { return numMips_; }
void Destroy();
@@ -214,7 +214,13 @@ void FramebufferManagerVulkan::MakePixelTexture(const u8 *srcPixels, GEBufferFor
VkCommandBuffer initCmd = (VkCommandBuffer)draw_->GetNativeObject(Draw::NativeObject::INIT_COMMANDBUFFER);
drawPixelsTex_ = new VulkanTexture(vulkan_);
drawPixelsTex_->CreateDirect(initCmd, width, height, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
if (!drawPixelsTex_->CreateDirect(initCmd, width, height, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)) {
// out of memory?
delete drawPixelsTex_;
drawPixelsTex_ = nullptr;
overrideImageView_ = VK_NULL_HANDLE;
return;
}
// Initialize backbuffer texture for DrawPixels
drawPixelsTexFormat_ = srcPixelFormat;
@@ -592,7 +592,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry, bool replaceIm
actualFmt = ToVulkanFormat(replaced.Format(0));
}
if (!entry->vkTex) { // Change to "if (true) {" to always recreate.
{
delete entry->vkTex;
entry->vkTex = new CachedTextureVulkan();
entry->vkTex->texture_ = new VulkanTexture(vulkan_, allocator_);
@@ -643,8 +643,6 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry, bool replaceIm
delete entry->vkTex;
entry->vkTex = nullptr;
}
} else {
entry->vkTex->texture_->TransitionForUpload(cmdInit);
}
lastBoundTexture = entry->vkTex;

0 comments on commit 96cd368

Please sign in to comment.