aboutsummaryrefslogtreecommitdiffstats
path: root/meta-v1000/recipes-graphics/lunarg-sdk/vulkan-loader-layers/0005-demos-cube-use-absolute-location-for-data-files.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-v1000/recipes-graphics/lunarg-sdk/vulkan-loader-layers/0005-demos-cube-use-absolute-location-for-data-files.patch')
-rw-r--r--meta-v1000/recipes-graphics/lunarg-sdk/vulkan-loader-layers/0005-demos-cube-use-absolute-location-for-data-files.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/meta-v1000/recipes-graphics/lunarg-sdk/vulkan-loader-layers/0005-demos-cube-use-absolute-location-for-data-files.patch b/meta-v1000/recipes-graphics/lunarg-sdk/vulkan-loader-layers/0005-demos-cube-use-absolute-location-for-data-files.patch
new file mode 100644
index 00000000..85c15b89
--- /dev/null
+++ b/meta-v1000/recipes-graphics/lunarg-sdk/vulkan-loader-layers/0005-demos-cube-use-absolute-location-for-data-files.patch
@@ -0,0 +1,70 @@
+From f6c2eeaad968b1ad0ebef7fad79eb5f01305a6e3 Mon Sep 17 00:00:00 2001
+From: Awais Belal <awais_belal@mentor.com>
+Date: Wed, 5 Sep 2018 11:43:07 +0500
+Subject: [PATCH 5/5] demos/cube*: use absolute location for data files
+
+If absolute locations are not used here the demo
+looks for texture files in a haphazard way and
+can only be launched from the same directory.
+This allows running the demo from anywhere and
+consolidate any data files that are needed.
+
+Signed-off-by: Awais Belal <awais_belal@mentor.com>
+---
+ demos/cube.c | 7 ++++++-
+ demos/cube.cpp | 7 ++++++-
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/demos/cube.c b/demos/cube.c
+index 29a484260..6b5f0b7af 100644
+--- a/demos/cube.c
++++ b/demos/cube.c
+@@ -67,6 +67,8 @@
+ #define APP_SHORT_NAME "cube"
+ #define APP_LONG_NAME "The Vulkan Cube Demo Program"
+
++#define VULKAN_DATA_LOC "/usr/share/vulkan-data/"
++
+ // Allow a maximum of two outstanding presentation operations.
+ #define FRAME_LAG 2
+
+@@ -1484,7 +1486,10 @@ bool loadTexture(const char *filename, uint8_t *rgba_data, VkSubresourceLayout *
+
+ return true;
+ #else
+- FILE *fPtr = fopen(filename, "rb");
++ char abs_filename[256];
++ strcpy(abs_filename, VULKAN_DATA_LOC);
++ strcat(abs_filename, filename);
++ FILE *fPtr = fopen(abs_filename, "rb");
+ char header[256], *cPtr, *tmp;
+
+ if (!fPtr) return false;
+diff --git a/demos/cube.cpp b/demos/cube.cpp
+index fe8cb7c90..3eee7d9c8 100644
+--- a/demos/cube.cpp
++++ b/demos/cube.cpp
+@@ -57,6 +57,8 @@
+ // Allow a maximum of two outstanding presentation operations.
+ #define FRAME_LAG 2
+
++#define VULKAN_DATA_LOC "/usr/share/vulkan-data/"
++
+ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+ #ifdef _WIN32
+@@ -2261,7 +2263,10 @@ void Demo::update_data_buffer() {
+ }
+
+ bool Demo::loadTexture(const char *filename, uint8_t *rgba_data, vk::SubresourceLayout *layout, int32_t *width, int32_t *height) {
+- FILE *fPtr = fopen(filename, "rb");
++ char abs_filename[256];
++ strcpy(abs_filename, VULKAN_DATA_LOC);
++ strcat(abs_filename, filename);
++ FILE *fPtr = fopen(abs_filename, "rb");
+ if (!fPtr) {
+ return false;
+ }
+--
+2.11.1
+