Permalink
Browse files

More minor vulkan fixes and cleanups. Don't actually call "Resized" i…

…f the size stays the same.
  • Loading branch information...
hrydgard committed Nov 10, 2017
1 parent f3eeafc commit 3cc5d8f40a9753767273a0858faa1c005f5d94c3
@@ -93,8 +93,6 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan, Draw::DrawContext *dra
indexGen.Setup(decIndex);
InitDeviceObjects();
tessDataTransfer = new TessellationDataTransferVulkan(vulkan, draw);
}
void DrawEngineVulkan::InitDeviceObjects() {
@@ -206,6 +204,8 @@ void DrawEngineVulkan::InitDeviceObjects() {
assert(VK_SUCCESS == res);
vertexCache_ = new VulkanPushBuffer(vulkan_, VERTEX_CACHE_SIZE);
tessDataTransfer = new TessellationDataTransferVulkan(vulkan_, draw_);
}
DrawEngineVulkan::~DrawEngineVulkan() {
@@ -214,8 +214,6 @@ DrawEngineVulkan::~DrawEngineVulkan() {
FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE);
DestroyDeviceObjects();
delete tessDataTransfer;
}
void DrawEngineVulkan::FrameData::Destroy(VulkanContext *vulkan) {
@@ -241,6 +239,9 @@ void DrawEngineVulkan::FrameData::Destroy(VulkanContext *vulkan) {
}
void DrawEngineVulkan::DestroyDeviceObjects() {
delete tessDataTransfer;
tessDataTransfer = nullptr;
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
frame_[i].Destroy(vulkan_);
}
@@ -126,36 +126,14 @@ void SamplerCache::DeviceRestore(VulkanContext *vulkan) {
TextureCacheVulkan::TextureCacheVulkan(Draw::DrawContext *draw, VulkanContext *vulkan)
: TextureCacheCommon(draw),
vulkan_(vulkan),
samplerCache_(vulkan),
texelsScaledThisFrame_(0) {
samplerCache_(vulkan) {
timesInvalidatedAllThisFrame_ = 0;
lastBoundTexture = nullptr;
allocator_ = new VulkanDeviceAllocator(vulkan_, TEXCACHE_MIN_SLAB_SIZE, TEXCACHE_MAX_SLAB_SIZE);
VkSamplerCreateInfo samp{ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
samp.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samp.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samp.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samp.magFilter = VK_FILTER_NEAREST;
samp.minFilter = VK_FILTER_NEAREST;
samp.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
vkCreateSampler(vulkan_->GetDevice(), &samp, nullptr, &samplerNearest_);
DeviceRestore(vulkan, draw);
SetupTextureDecoder();
}
TextureCacheVulkan::~TextureCacheVulkan() {
vulkan_->Delete().QueueDeleteSampler(samplerNearest_);
Clear(true);
if (allocator_) {
allocator_->Destroy();
// We have to delete on queue, so this can free its queued deletions.
vulkan_->Delete().QueueCallback([](void *ptr) {
auto allocator = static_cast<VulkanDeviceAllocator *>(ptr);
delete allocator;
}, allocator_);
}
DeviceLost();
}
void TextureCacheVulkan::SetFramebufferManager(FramebufferManagerVulkan *fbManager) {
@@ -183,6 +161,7 @@ void TextureCacheVulkan::DeviceLost() {
}
samplerCache_.DeviceLost();
vulkan_->Delete().QueueDeleteSampler(samplerNearest_);
nextTexture_ = nullptr;
}
@@ -195,6 +174,15 @@ void TextureCacheVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext
allocator_ = new VulkanDeviceAllocator(vulkan_, TEXCACHE_MIN_SLAB_SIZE, TEXCACHE_MAX_SLAB_SIZE);
samplerCache_.DeviceRestore(vulkan);
VkSamplerCreateInfo samp{ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
samp.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samp.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samp.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samp.magFilter = VK_FILTER_NEAREST;
samp.minFilter = VK_FILTER_NEAREST;
samp.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
vkCreateSampler(vulkan_->GetDevice(), &samp, nullptr, &samplerNearest_);
}
void TextureCacheVulkan::ReleaseTexture(TexCacheEntry *entry, bool delete_them) {
@@ -122,19 +122,19 @@ class TextureCacheVulkan : public TextureCacheCommon {
void ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer) override;
void BuildTexture(TexCacheEntry *const entry, bool replaceImages) override;
VulkanContext *vulkan_;
VulkanDeviceAllocator *allocator_;
VulkanPushBuffer *push_;
VulkanContext *vulkan_ = nullptr;
VulkanDeviceAllocator *allocator_ = nullptr;
VulkanPushBuffer *push_ = nullptr;
SamplerCache samplerCache_;
TextureScalerVulkan scaler;
CachedTextureVulkan *lastBoundTexture;
CachedTextureVulkan *lastBoundTexture = nullptr;
int decimationCounter_;
int texelsScaledThisFrame_;
int timesInvalidatedAllThisFrame_;
int decimationCounter_ = 0;
int texelsScaledThisFrame_ = 0;
int timesInvalidatedAllThisFrame_ = 0;
FramebufferManagerVulkan *framebufferManagerVulkan_;
DepalShaderCacheVulkan *depalShaderCache_;
@@ -741,6 +741,8 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env,
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv *, jclass, jint bufw, jint bufh, jint format) {
ILOG("NativeApp.backbufferResize(%d x %d)", bufw, bufh);
bool new_size = pixel_xres != bufw || pixel_yres != bufh;
// pixel_*res is the backbuffer resolution.
pixel_xres = bufw;
pixel_yres = bufh;
@@ -767,7 +769,10 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv
ILOG("dp_xres=%d dp_yres=%d", dp_xres, dp_yres);
ILOG("pixel_xres=%d pixel_yres=%d", pixel_xres, pixel_yres);
NativeResized();
if (new_size) {
ILOG("Size change detected - calling NativeResized()");
NativeResized();
}
}
@@ -269,7 +269,8 @@ void TextDrawerAndroid::OncePerFrame() {
// If DPI changed (small-mode, future proper monitor DPI support), drop everything.
float newDpiScale = CalculateDPIScale();
if (newDpiScale != dpiScale_) {
ILOG("DPI Scale changed (%f to %f) - wiping font cache", dpiScale_, newDpiScale);
// TODO: Don't bother if it's a no-op (cache already empty)
ILOG("DPI Scale changed (%f to %f) - wiping font cache (%d items, %d fonts)", dpiScale_, newDpiScale, (int)cache_.size(), (int)fontMap_.size());
dpiScale_ = newDpiScale;
ClearCache();
fontMap_.clear(); // size is precomputed using dpiScale_.

0 comments on commit 3cc5d8f

Please sign in to comment.