| 3067 | #include "lunarg.ppm.h" |
| 3068 | #endif |
| 3069 | bool Demo::loadTexture(const char *filename, uint8_t *rgba_data, vk::SubresourceLayout &layout, uint32_t &width, uint32_t &height) { |
| 3070 | (void)filename; |
| 3071 | char *cPtr; |
| 3072 | cPtr = (char *)lunarg_ppm; |
| 3073 | if ((unsigned char *)cPtr >= (lunarg_ppm + lunarg_ppm_len) || strncmp(cPtr, "P6\n", 3)) { |
| 3074 | return false; |
| 3075 | } |
| 3076 | while (strncmp(cPtr++, "\n", 1)); |
| 3077 | sscanf(cPtr, "%u %u", &width, &height); |
| 3078 | if (rgba_data == nullptr) { |
| 3079 | return true; |
| 3080 | } |
| 3081 | while (strncmp(cPtr++, "\n", 1)); |
| 3082 | if ((unsigned char *)cPtr >= (lunarg_ppm + lunarg_ppm_len) || strncmp(cPtr, "255\n", 4)) { |
| 3083 | return false; |
| 3084 | } |
| 3085 | while (strncmp(cPtr++, "\n", 1)); |
| 3086 | for (uint32_t y = 0; y < height; y++) { |
| 3087 | uint8_t *rowPtr = rgba_data; |
| 3088 | for (uint32_t x = 0; x < width; x++) { |
| 3089 | memcpy(rowPtr, cPtr, 3); |
| 3090 | rowPtr[3] = 255; /* Alpha of 1 */ |
| 3091 | rowPtr += 4; |
| 3092 | cPtr += 3; |
| 3093 | } |
| 3094 | rgba_data += layout.rowPitch; |
| 3095 | } |
| 3096 | return true; |
| 3097 | } |
| 3098 | |
| 3099 | bool Demo::memory_type_from_properties(uint32_t typeBits, vk::MemoryPropertyFlags requirements_mask, uint32_t &typeIndex) { |
| 3100 | // Search memtypes to find first index with those properties |
nothing calls this directly
no outgoing calls
no test coverage detected