mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Work around annoying assert in debug memory allocator on 32-bit Windows
This commit is contained in:
parent
691cdf8d76
commit
dfca3dd87a
@ -27,6 +27,7 @@
|
||||
#include "Common/GPU/thin3d.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/MemoryUtil.h"
|
||||
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/GPU/Vulkan/VulkanContext.h"
|
||||
@ -213,16 +214,16 @@ ShaderManagerVulkan::ShaderManagerVulkan(Draw::DrawContext *draw)
|
||||
codeBuffer_ = new char[CODE_BUFFER_SIZE];
|
||||
VulkanContext *vulkan = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT);
|
||||
uboAlignment_ = vulkan->GetPhysicalDeviceProperties().properties.limits.minUniformBufferOffsetAlignment;
|
||||
memset(&ub_base, 0, sizeof(ub_base));
|
||||
memset(&ub_lights, 0, sizeof(ub_lights));
|
||||
memset(&ub_bones, 0, sizeof(ub_bones));
|
||||
|
||||
static_assert(sizeof(ub_base) <= 512, "ub_base grew too big");
|
||||
static_assert(sizeof(ub_lights) <= 512, "ub_lights grew too big");
|
||||
static_assert(sizeof(ub_bones) <= 384, "ub_bones grew too big");
|
||||
uniforms_ = (Uniforms *)AllocateAlignedMemory(sizeof(Uniforms), 16);
|
||||
|
||||
static_assert(sizeof(uniforms_->ub_base) <= 512, "ub_base grew too big");
|
||||
static_assert(sizeof(uniforms_->ub_lights) <= 512, "ub_lights grew too big");
|
||||
static_assert(sizeof(uniforms_->ub_bones) <= 384, "ub_bones grew too big");
|
||||
}
|
||||
|
||||
ShaderManagerVulkan::~ShaderManagerVulkan() {
|
||||
FreeAlignedMemory(uniforms_);
|
||||
Clear();
|
||||
delete[] codeBuffer_;
|
||||
}
|
||||
@ -278,11 +279,11 @@ uint64_t ShaderManagerVulkan::UpdateUniforms(bool useBufferedRendering) {
|
||||
uint64_t dirty = gstate_c.GetDirtyUniforms();
|
||||
if (dirty != 0) {
|
||||
if (dirty & DIRTY_BASE_UNIFORMS)
|
||||
BaseUpdateUniforms(&ub_base, dirty, false, useBufferedRendering);
|
||||
BaseUpdateUniforms(&uniforms_->ub_base, dirty, false, useBufferedRendering);
|
||||
if (dirty & DIRTY_LIGHT_UNIFORMS)
|
||||
LightUpdateUniforms(&ub_lights, dirty);
|
||||
LightUpdateUniforms(&uniforms_->ub_lights, dirty);
|
||||
if (dirty & DIRTY_BONE_UNIFORMS)
|
||||
BoneUpdateUniforms(&ub_bones, dirty);
|
||||
BoneUpdateUniforms(&uniforms_->ub_bones, dirty);
|
||||
}
|
||||
gstate_c.CleanUniforms();
|
||||
return dirty;
|
||||
|
@ -103,6 +103,13 @@ protected:
|
||||
GShaderID id_;
|
||||
};
|
||||
|
||||
struct Uniforms {
|
||||
// Uniform block scratchpad. These (the relevant ones) are copied to the current pushbuffer at draw time.
|
||||
UB_VS_FS_Base ub_base{};
|
||||
UB_VS_Lights ub_lights{};
|
||||
UB_VS_Bones ub_bones{};
|
||||
};
|
||||
|
||||
class ShaderManagerVulkan : public ShaderManagerCommon {
|
||||
public:
|
||||
ShaderManagerVulkan(Draw::DrawContext *draw);
|
||||
@ -139,15 +146,15 @@ public:
|
||||
bool IsLightDirty() { return true; }
|
||||
bool IsBoneDirty() { return true; }
|
||||
|
||||
uint32_t PushBaseBuffer(VulkanPushPool *dest, VkBuffer *buf) {
|
||||
return dest->Push(&ub_base, sizeof(ub_base), uboAlignment_, buf);
|
||||
uint32_t PushBaseBuffer(VulkanPushPool *dest, VkBuffer *buf) const {
|
||||
return dest->Push(&uniforms_->ub_base, sizeof(uniforms_->ub_base), uboAlignment_, buf);
|
||||
}
|
||||
uint32_t PushLightBuffer(VulkanPushPool *dest, VkBuffer *buf) {
|
||||
return dest->Push(&ub_lights, sizeof(ub_lights), uboAlignment_, buf);
|
||||
uint32_t PushLightBuffer(VulkanPushPool *dest, VkBuffer *buf) const {
|
||||
return dest->Push(&uniforms_->ub_lights, sizeof(uniforms_->ub_lights), uboAlignment_, buf);
|
||||
}
|
||||
// TODO: Only push half the bone buffer if we only have four bones.
|
||||
uint32_t PushBoneBuffer(VulkanPushPool *dest, VkBuffer *buf) {
|
||||
return dest->Push(&ub_bones, sizeof(ub_bones), uboAlignment_, buf);
|
||||
uint32_t PushBoneBuffer(VulkanPushPool *dest, VkBuffer *buf) const {
|
||||
return dest->Push(&uniforms_->ub_bones, sizeof(uniforms_->ub_bones), uboAlignment_, buf);
|
||||
}
|
||||
|
||||
static bool LoadCacheFlags(FILE *f, DrawEngineVulkan *drawEngine);
|
||||
@ -171,10 +178,8 @@ private:
|
||||
char *codeBuffer_;
|
||||
|
||||
uint64_t uboAlignment_;
|
||||
// Uniform block scratchpad. These (the relevant ones) are copied to the current pushbuffer at draw time.
|
||||
UB_VS_FS_Base ub_base;
|
||||
UB_VS_Lights ub_lights;
|
||||
UB_VS_Bones ub_bones;
|
||||
|
||||
Uniforms *uniforms_;
|
||||
|
||||
VulkanFragmentShader *lastFShader_ = nullptr;
|
||||
VulkanVertexShader *lastVShader_ = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user