nxtSwapChainNextTexture: make texture a union of ptr, u32, u64
Making all textures represented by pointers is a problem for Vulkan where VkImage is a 64bit type and wouldn't fit in a pointer on 32bit builds. Make texture contain on of each useful type so that each backend can choose which one it wants to receive.
This commit is contained in:
parent
c0f5ca1f5a
commit
0887236c81
|
@ -40,7 +40,7 @@ namespace backend { namespace d3d12 {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Resource* nativeTexture = reinterpret_cast<ID3D12Resource*>(next.texture);
|
ID3D12Resource* nativeTexture = reinterpret_cast<ID3D12Resource*>(next.texture.ptr);
|
||||||
return new Texture(builder, nativeTexture);
|
return new Texture(builder, nativeTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace backend { namespace metal {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
id<MTLTexture> nativeTexture = reinterpret_cast<id<MTLTexture>>(next.texture);
|
id<MTLTexture> nativeTexture = reinterpret_cast<id<MTLTexture>>(next.texture.ptr);
|
||||||
return new Texture(builder, nativeTexture);
|
return new Texture(builder, nativeTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace backend { namespace opengl {
|
||||||
GetDevice()->HandleError(error);
|
GetDevice()->HandleError(error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
GLuint nativeTexture = static_cast<GLuint>(reinterpret_cast<uintptr_t>(next.texture));
|
GLuint nativeTexture = next.texture.u32;
|
||||||
return new Texture(builder, nativeTexture);
|
return new Texture(builder, nativeTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,11 @@ constexpr nxtSwapChainError NXT_SWAP_CHAIN_NO_ERROR = nullptr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/// Backend-specific texture id/name/pointer
|
/// Backend-specific texture id/name/pointer
|
||||||
void* texture = nullptr;
|
union {
|
||||||
|
void* ptr;
|
||||||
|
uint64_t u64;
|
||||||
|
uint32_t u32;
|
||||||
|
} texture;
|
||||||
} nxtSwapChainNextTexture;
|
} nxtSwapChainNextTexture;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -177,7 +177,7 @@ namespace utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
||||||
nextTexture->texture = mRenderTargetResources[mRenderTargetIndex].Get();
|
nextTexture->texture.ptr = mRenderTargetResources[mRenderTargetIndex].Get();
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace utils {
|
||||||
mCurrentTexture = mCurrentDrawable.texture;
|
mCurrentTexture = mCurrentDrawable.texture;
|
||||||
[mCurrentTexture retain];
|
[mCurrentTexture retain];
|
||||||
|
|
||||||
nextTexture->texture = reinterpret_cast<void*>(mCurrentTexture);
|
nextTexture->texture.ptr = reinterpret_cast<void*>(mCurrentTexture);
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
||||||
nextTexture->texture = reinterpret_cast<void*>(static_cast<size_t>(mBackTexture));
|
nextTexture->texture.u32 = mBackTexture;
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue