Native texture depth must be explicitly specified;

To fix validation errors when attaching them to Canvases.
This commit is contained in:
bjorn 2019-06-25 18:56:59 -07:00
parent 5745ffa226
commit 749774e2fc
4 changed files with 5 additions and 4 deletions

View File

@ -1312,7 +1312,7 @@ Texture* lovrTextureInit(Texture* texture, TextureType type, TextureData** slice
return texture;
}
Texture* lovrTextureInitFromHandle(Texture* texture, uint32_t handle, TextureType type) {
Texture* lovrTextureInitFromHandle(Texture* texture, uint32_t handle, TextureType type, uint32_t depth) {
texture->type = type;
texture->id = handle;
texture->target = convertTextureTarget(type);
@ -1323,6 +1323,7 @@ Texture* lovrTextureInitFromHandle(Texture* texture, uint32_t handle, TextureTyp
glGetTexLevelParameteriv(texture->target, 0, GL_TEXTURE_HEIGHT, &height);
texture->width = (uint32_t) width;
texture->height = (uint32_t) height;
texture->depth = depth; // There isn't an easy way to get depth/layer count, so it's passed in...
return texture;
}

View File

@ -31,7 +31,7 @@ typedef struct Texture {
} Texture;
Texture* lovrTextureInit(Texture* texture, TextureType type, struct TextureData** slices, uint32_t sliceCount, bool srgb, bool mipmaps, uint32_t msaa);
Texture* lovrTextureInitFromHandle(Texture* texture, uint32_t handle, TextureType type);
Texture* lovrTextureInitFromHandle(Texture* texture, uint32_t handle, TextureType type, uint32_t depth);
#define lovrTextureCreate(...) lovrTextureInit(lovrAlloc(Texture), __VA_ARGS__)
#define lovrTextureCreateFromHandle(...) lovrTextureInitFromHandle(lovrAlloc(Texture), __VA_ARGS__)
void lovrTextureDestroy(void* ref);

View File

@ -31,7 +31,7 @@ static Texture* lookupTexture(uint32_t handle) {
sprintf(key, "%d", handle);
Texture** texture = map_get(&state.textureLookup, key);
if (!texture) {
map_set(&state.textureLookup, key, lovrTextureCreateFromHandle(handle, TEXTURE_2D));
map_set(&state.textureLookup, key, lovrTextureCreateFromHandle(handle, TEXTURE_2D, 1));
texture = map_get(&state.textureLookup, key);
}
return *texture;

View File

@ -267,7 +267,7 @@ static bool openxr_init(float offset, uint32_t msaa) {
XR_INIT(xrEnumerateSwapchainImages(state.swapchain, MAX_IMAGES, &state.imageCount, (XrSwapchainImageBaseHeader*) images));
for (uint32_t i = 0; i < state.imageCount; i++) {
lovrTextureInitFromHandle(&state.textures[i], images[i].image, TEXTURE_2D);
lovrTextureInitFromHandle(&state.textures[i], images[i].image, TEXTURE_2D, 1);
}
// Pre-init composition layer