Skip to content

Commit

Permalink
Merge pull request #18201 from hrydgard/asserts-and-checks
Browse files Browse the repository at this point in the history
Asserts and checks
  • Loading branch information
hrydgard authored Sep 23, 2023
2 parents c1529b2 + e64d1e9 commit 7dc18a9
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ VulkanPushPool::Block VulkanPushPool::CreateBlock(size_t size) {
_assert_(result == VK_SUCCESS);

result = vmaMapMemory(vulkan_->Allocator(), block.allocation, (void **)(&block.writePtr));
_assert_msg_(result == VK_SUCCESS, "VulkanPushPool: Failed to map memory (result = %08x)", result);
_assert_msg_(result == VK_SUCCESS, "VulkanPushPool: Failed to map memory (result = %s)", VulkanResultToString(result));

_assert_msg_(block.writePtr != nullptr, "VulkanPushPool: Failed to map memory on block of size %d", (int)block.size);
return block;
Expand Down
1 change: 1 addition & 0 deletions Common/Thread/Promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PromiseTask : public Task {
template<class T>
class Promise {
public:
// Never fails.
static Promise<T> *Spawn(ThreadManager *threadman, std::function<T()> fun, TaskType taskType, TaskPriority taskPriority = TaskPriority::NORMAL) {
Mailbox<T> *mailbox = new Mailbox<T>();

Expand Down
5 changes: 4 additions & 1 deletion Core/HLE/ReplaceTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,10 @@ std::vector<int> GetReplacementFuncIndexes(u64 hash, int funcSize) {
return emptyResult;
}

const ReplacementTableEntry *GetReplacementFunc(int i) {
const ReplacementTableEntry *GetReplacementFunc(size_t i) {
if (i >= ARRAY_SIZE(entries)) {
return nullptr;
}
return &entries[i];
}

Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/ReplaceTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void Replacement_Shutdown();

int GetNumReplacementFuncs();
std::vector<int> GetReplacementFuncIndexes(u64 hash, int funcSize);
const ReplacementTableEntry *GetReplacementFunc(int index);
const ReplacementTableEntry *GetReplacementFunc(size_t index);

void WriteReplaceInstructions(u32 address, u64 hash, int size);
void RestoreReplacedInstruction(u32 address);
Expand Down
2 changes: 1 addition & 1 deletion Core/MIPS/ARM/ArmJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ void ArmJit::Comp_ReplacementFunc(MIPSOpcode op)

const ReplacementTableEntry *entry = GetReplacementFunc(index);
if (!entry) {
ERROR_LOG(HLE, "Invalid replacement op %08x", op.encoding);
ERROR_LOG_REPORT_ONCE(replFunc, HLE, "Invalid replacement op %08x at %08x", op.encoding, js.compilerPC);
return;
}

Expand Down
3 changes: 2 additions & 1 deletion Core/MIPS/ARM64/Arm64Jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ void Arm64Jit::Comp_ReplacementFunc(MIPSOpcode op)

const ReplacementTableEntry *entry = GetReplacementFunc(index);
if (!entry) {
ERROR_LOG(HLE, "Invalid replacement op %08x", op.encoding);
ERROR_LOG_REPORT_ONCE(replFunc, HLE, "Invalid replacement op %08x at %08x", op.encoding, js.compilerPC);
// TODO: What should we do here? We're way off in the weeds probably.
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/MIPS/x86/Jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ void Jit::Comp_ReplacementFunc(MIPSOpcode op) {

const ReplacementTableEntry *entry = GetReplacementFunc(index);
if (!entry) {
ERROR_LOG(HLE, "Invalid replacement op %08x", op.encoding);
ERROR_LOG_REPORT_ONCE(replFunc, HLE, "Invalid replacement op %08x at %08x", op.encoding, js.compilerPC);
return;
}

Expand Down
22 changes: 7 additions & 15 deletions GPU/Vulkan/ShaderManagerVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
// Most drivers treat vkCreateShaderModule as pretty much a memcpy. What actually
// takes time here, and makes this worthy of parallelization, is GLSLtoSPV.
// Takes ownership over tag.
// This always returns something, checking the return value for null is not meaningful.
static Promise<VkShaderModule> *CompileShaderModuleAsync(VulkanContext *vulkan, VkShaderStageFlagBits stage, const char *code, std::string *tag) {
auto compile = [=] {
PROFILE_THIS_SCOPE("shadercomp");
Expand Down Expand Up @@ -112,13 +113,10 @@ static Promise<VkShaderModule> *CompileShaderModuleAsync(VulkanContext *vulkan,

VulkanFragmentShader::VulkanFragmentShader(VulkanContext *vulkan, FShaderID id, FragmentShaderFlags flags, const char *code)
: vulkan_(vulkan), id_(id), flags_(flags) {
_assert_(!id.is_invalid());
source_ = code;
module_ = CompileShaderModuleAsync(vulkan, VK_SHADER_STAGE_FRAGMENT_BIT, source_.c_str(), new std::string(FragmentShaderDesc(id)));
if (!module_) {
failed_ = true;
} else {
VERBOSE_LOG(G3D, "Compiled fragment shader:\n%s\n", (const char *)code);
}
VERBOSE_LOG(G3D, "Compiled fragment shader:\n%s\n", (const char *)code);
}

VulkanFragmentShader::~VulkanFragmentShader() {
Expand Down Expand Up @@ -147,13 +145,10 @@ std::string VulkanFragmentShader::GetShaderString(DebugShaderStringType type) co

VulkanVertexShader::VulkanVertexShader(VulkanContext *vulkan, VShaderID id, VertexShaderFlags flags, const char *code, bool useHWTransform)
: vulkan_(vulkan), useHWTransform_(useHWTransform), flags_(flags), id_(id) {
_assert_(!id.is_invalid());
source_ = code;
module_ = CompileShaderModuleAsync(vulkan, VK_SHADER_STAGE_VERTEX_BIT, source_.c_str(), new std::string(VertexShaderDesc(id)));
if (!module_) {
failed_ = true;
} else {
VERBOSE_LOG(G3D, "Compiled vertex shader:\n%s\n", (const char *)code);
}
VERBOSE_LOG(G3D, "Compiled vertex shader:\n%s\n", (const char *)code);
}

VulkanVertexShader::~VulkanVertexShader() {
Expand Down Expand Up @@ -182,13 +177,10 @@ std::string VulkanVertexShader::GetShaderString(DebugShaderStringType type) cons

VulkanGeometryShader::VulkanGeometryShader(VulkanContext *vulkan, GShaderID id, const char *code)
: vulkan_(vulkan), id_(id) {
_assert_(!id.is_invalid());
source_ = code;
module_ = CompileShaderModuleAsync(vulkan, VK_SHADER_STAGE_GEOMETRY_BIT, source_.c_str(), new std::string(GeometryShaderDesc(id).c_str()));
if (!module_) {
failed_ = true;
} else {
VERBOSE_LOG(G3D, "Compiled geometry shader:\n%s\n", (const char *)code);
}
VERBOSE_LOG(G3D, "Compiled geometry shader:\n%s\n", (const char *)code);
}

VulkanGeometryShader::~VulkanGeometryShader() {
Expand Down
8 changes: 1 addition & 7 deletions GPU/Vulkan/ShaderManagerVulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class VulkanFragmentShader {

const std::string &source() const { return source_; }

bool Failed() const { return failed_; }

std::string GetShaderString(DebugShaderStringType type) const;
Promise<VkShaderModule> *GetModule() { return module_; }
const FShaderID &GetID() const { return id_; }
Expand All @@ -68,7 +66,6 @@ class VulkanVertexShader {

const std::string &source() const { return source_; }

bool Failed() const { return failed_; }
bool UseHWTransform() const { return useHWTransform_; } // TODO: Roll into flags
VertexShaderFlags Flags() const { return flags_; }

Expand All @@ -81,7 +78,6 @@ class VulkanVertexShader {

VulkanContext *vulkan_;
std::string source_;
bool failed_ = false;
bool useHWTransform_;
VShaderID id_;
VertexShaderFlags flags_;
Expand All @@ -94,9 +90,8 @@ class VulkanGeometryShader {

const std::string &source() const { return source_; }

bool Failed() const { return failed_; }

std::string GetShaderString(DebugShaderStringType type) const;

Promise<VkShaderModule> *GetModule() const { return module_; }
const GShaderID &GetID() { return id_; }

Expand All @@ -105,7 +100,6 @@ class VulkanGeometryShader {

VulkanContext *vulkan_;
std::string source_;
bool failed_ = false;
GShaderID id_;
};

Expand Down

0 comments on commit 7dc18a9

Please sign in to comment.