aboutsummaryrefslogtreecommitdiff
path: root/demos/cube.c
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.c
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.c')
-rw-r--r--demos/cube.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/demos/cube.c b/demos/cube.c
index 0abffae6..4b84ae64 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -91,7 +91,7 @@ bool in_callback = false;
#else
#define ERR_EXIT(err_msg, err_class) \
do { \
- printf(err_msg); \
+ printf("%s\n", err_msg); \
fflush(stdout); \
exit(1); \
} while (0)
@@ -1661,6 +1661,9 @@ static VkShaderModule demo_prepare_vs(struct demo *demo) {
size_t size;
vertShaderCode = demo_read_spv("cube-vert.spv", &size);
+ if (!vertShaderCode) {
+ ERR_EXIT("Failed to load cube-vert.spv", "Load Shader Failure");
+ }
demo->vert_shader_module =
demo_prepare_shader_module(demo, vertShaderCode, size);
@@ -1686,6 +1689,9 @@ static VkShaderModule demo_prepare_fs(struct demo *demo) {
size_t size;
fragShaderCode = demo_read_spv("cube-frag.spv", &size);
+ if (!fragShaderCode) {
+ ERR_EXIT("Failed to load cube-frag.spv", "Load Shader Failure");
+ }
demo->frag_shader_module =
demo_prepare_shader_module(demo, fragShaderCode, size);