summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-03-27 19:59:00 +0100
committerFernandoS27 <fsahmkow27@gmail.com>2019-04-07 13:52:01 +0200
commit021cd56bc98aec220b85c2049e1edb5c02714294 (patch)
tree815d65ee43f554d4dd44f65b81f3428c7bbf492d
parentMerge pull request #2285 from lioncash/unused-struct (diff)
downloadyuzu-021cd56bc98aec220b85c2049e1edb5c02714294.tar
yuzu-021cd56bc98aec220b85c2049e1edb5c02714294.tar.gz
yuzu-021cd56bc98aec220b85c2049e1edb5c02714294.tar.bz2
yuzu-021cd56bc98aec220b85c2049e1edb5c02714294.tar.lz
yuzu-021cd56bc98aec220b85c2049e1edb5c02714294.tar.xz
yuzu-021cd56bc98aec220b85c2049e1edb5c02714294.tar.zst
yuzu-021cd56bc98aec220b85c2049e1edb5c02714294.zip
-rw-r--r--src/common/assert.h18
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp4
2 files changed, 22 insertions, 0 deletions
diff --git a/src/common/assert.h b/src/common/assert.h
index 6002f7ab1..4b0e3f64e 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -57,3 +57,21 @@ __declspec(noinline, noreturn)
#define UNIMPLEMENTED_IF(cond) ASSERT_MSG(!(cond), "Unimplemented code!")
#define UNIMPLEMENTED_IF_MSG(cond, ...) ASSERT_MSG(!(cond), __VA_ARGS__)
+
+// If the assert is ignored, execute _b_
+#define ASSERT_OR_EXECUTE(_a_, _b_) \
+ do { \
+ ASSERT(_a_); \
+ if (!(_a_)) { \
+ _b_ \
+ } \
+ } while (0)
+
+// If the assert is ignored, execute _b_
+#define ASSERT_OR_EXECUTE_MSG(_a_, _b_, ...) \
+ do { \
+ ASSERT_MSG(_a_, __VA_ARGS__); \
+ if (!(_a_)) { \
+ _b_ \
+ } \
+ } while (0)
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 1f8eca6f0..a9d88000e 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -41,6 +41,10 @@ GPUVAddr GetShaderAddress(Maxwell::ShaderProgram program) {
/// Gets the shader program code from memory for the specified address
ProgramCode GetShaderCode(const u8* host_ptr) {
ProgramCode program_code(VideoCommon::Shader::MAX_PROGRAM_LENGTH);
+ ASSERT_OR_EXECUTE(host_ptr != nullptr, {
+ std::fill(program_code.begin(), program_code.end(), 0);
+ return program_code;
+ });
std::memcpy(program_code.data(), host_ptr, program_code.size() * sizeof(u64));
return program_code;
}