aboutsummaryrefslogtreecommitdiff
path: root/demos/cube.cpp
diff options
context:
space:
mode:
authorRobert Morell <rmorell@nvidia.com>2017-02-01 14:51:00 -0800
committerTony-LunarG <tony@lunarg.com>2017-02-02 15:18:41 -0700
commit4ccc652a0656a09b5baf8b0723dd256ca8293a4d (patch)
treea83b40864605583712e02a30ccf5428418198dd6 /demos/cube.cpp
parent4784a34467a3e077fc506769c1bc618095aaf84f (diff)
downloadusermoji-4ccc652a0656a09b5baf8b0723dd256ca8293a4d.tar.xz
cube: Error handling improvements
- Add a newline to the end of the error message when printing to stdout for ERR_EXIT. - Handle demo_read_spv failures by calling ERR_EXIT rather than just continuing on and calling the Vulkan library with a NULL pointer.
Diffstat (limited to 'demos/cube.cpp')
-rw-r--r--demos/cube.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/demos/cube.cpp b/demos/cube.cpp
index e5fa6ae2..096bf0b0 100644
--- a/demos/cube.cpp
+++ b/demos/cube.cpp
@@ -64,7 +64,7 @@
#else
#define ERR_EXIT(err_msg, err_class) \
do { \
- printf(err_msg); \
+ printf("%s\n", err_msg); \
fflush(stdout); \
exit(1); \
} while (0)
@@ -1555,6 +1555,9 @@ struct Demo {
vk::ShaderModule prepare_fs() {
size_t size = 0;
void *fragShaderCode = read_spv("cube-frag.spv", &size);
+ if (!fragShaderCode) {
+ ERR_EXIT("Failed to load cube-frag.spv", "Load Shader Failure");
+ }
frag_shader_module = prepare_shader_module(fragShaderCode, size);
@@ -1861,6 +1864,9 @@ struct Demo {
vk::ShaderModule prepare_vs() {
size_t size = 0;
void *vertShaderCode = read_spv("cube-vert.spv", &size);
+ if (!vertShaderCode) {
+ ERR_EXIT("Failed to load cube-vert.spv", "Load Shader Failure");
+ }
vert_shader_module = prepare_shader_module(vertShaderCode, size);