Fix Shader:sendImage;

This commit is contained in:
bjorn 2018-09-04 06:58:54 -07:00
parent 1b3e8c9766
commit 7e1687ce6b
2 changed files with 4 additions and 2 deletions

View File

@ -68,7 +68,7 @@ int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* des
case UNIFORM_IMAGE: {
Image* image = (Image*) dest + i;
image->texture = luax_checktype(L, j, Texture);
image->slice = 0;
image->slice = -1;
image->mipmap = 0;
image->access = ACCESS_READ_WRITE;
TextureType type = lovrTextureGetType(image->texture);

View File

@ -539,10 +539,12 @@ static void lovrGpuBindImage(Image* image, int slot) {
lovrAssert(image->slice < texture->depth, "Invalid texture slice '%d' for image uniform", image->slice);
GLenum glAccess = convertAccess(image->access);
GLenum glFormat = convertTextureFormatInternal(texture->format, false);
bool layered = image->slice == -1;
int slice = layered ? 0 : image->slice;
lovrRetain(texture);
lovrRelease(state.images[slot].texture);
glBindImageTexture(slot, texture->id, image->mipmap, image->slice == -1, image->slice, glAccess, glFormat);
glBindImageTexture(slot, texture->id, image->mipmap, layered, slice, glAccess, glFormat);
memcpy(state.images + slot, image, sizeof(Image));
}
}