summaryrefslogtreecommitdiffstats
path: root/AssetLoader/src/GLTFLoader.cpp
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-05-05 18:02:35 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-05-05 18:02:35 +0000
commit02b5dd0c2169f78a7d951f787c68b428e7af4867 (patch)
treef31e7a50132acd33f64d998650f316fa83e9f608 /AssetLoader/src/GLTFLoader.cpp
parentFixed variable naming problem causing Linux build errors (diff)
downloadDiligentTools-02b5dd0c2169f78a7d951f787c68b428e7af4867.tar.gz
DiligentTools-02b5dd0c2169f78a7d951f787c68b428e7af4867.zip
GLTF Loader: fixed mipmap generation issue on Vulkan on Mac
Diffstat (limited to 'AssetLoader/src/GLTFLoader.cpp')
-rw-r--r--AssetLoader/src/GLTFLoader.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/AssetLoader/src/GLTFLoader.cpp b/AssetLoader/src/GLTFLoader.cpp
index dd0532f..5cb6a24 100644
--- a/AssetLoader/src/GLTFLoader.cpp
+++ b/AssetLoader/src/GLTFLoader.cpp
@@ -89,14 +89,13 @@ RefCntAutoPtr<ITexture> TextureFromGLTFImage(IRenderDevice* pDevice,
TexDesc.MipLevels = 0;
TexDesc.MiscFlags = MISC_TEXTURE_FLAG_GENERATE_MIPS;
RefCntAutoPtr<ITexture> pTexture;
-
+
pDevice->CreateTexture(TexDesc, nullptr, &pTexture);
Box UpdateBox;
UpdateBox.MaxX = TexDesc.Width;
UpdateBox.MaxY = TexDesc.Height;
TextureSubResData Level0Data(pTextureData, gltfimage.width*4);
pCtx->UpdateTexture(pTexture, 0, 0, UpdateBox, Level0Data, RESOURCE_STATE_TRANSITION_MODE_NONE, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- pCtx->GenerateMips(pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)->SetSampler(pSampler);
return pTexture;
@@ -447,7 +446,6 @@ void Model::LoadTextures(IRenderDevice* pDevice,
IDeviceContext* pCtx,
const tinygltf::Model& gltf_model)
{
- std::vector<StateTransitionDesc> Barriers;
for (const tinygltf::Texture& gltf_tex : gltf_model.textures)
{
const tinygltf::Image& gltf_image = gltf_model.images[gltf_tex.source];
@@ -462,10 +460,17 @@ void Model::LoadTextures(IRenderDevice* pDevice,
pSampler = TextureSamplers[gltf_tex.sampler];
}
auto pTexture = TextureFromGLTFImage(pDevice, pCtx, gltf_image, pSampler);
- StateTransitionDesc Barrier{pTexture, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_SHADER_RESOURCE};
+ Textures.push_back(std::move(pTexture));
+ }
+
+ std::vector<StateTransitionDesc> Barriers;
+ for (auto& Tex : Textures)
+ {
+ pCtx->GenerateMips(Tex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
+
+ StateTransitionDesc Barrier{Tex, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_SHADER_RESOURCE};
Barrier.UpdateResourceState = true;
Barriers.emplace_back(Barrier);
- Textures.push_back(std::move(pTexture));
}
pCtx->TransitionResourceStates(static_cast<Uint32>(Barriers.size()), Barriers.data());
}