diff --git a/DDSTextureLoader/DDSTextureLoader.cpp b/DDSTextureLoader/DDSTextureLoader.cpp index af7009f..66bcce3 100644 --- a/DDSTextureLoader/DDSTextureLoader.cpp +++ b/DDSTextureLoader/DDSTextureLoader.cpp @@ -1776,6 +1776,11 @@ HRESULT DirectX::CreateDDSTextureFromMemoryEx( return E_INVALIDARG; } + if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) + { + return E_INVALIDARG; + } + // Validate DDS file in memory const DDS_HEADER* header = nullptr; const uint8_t* bitData = nullptr; @@ -1906,6 +1911,11 @@ HRESULT DirectX::CreateDDSTextureFromFileEx( return E_INVALIDARG; } + if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) + { + return E_INVALIDARG; + } + const DDS_HEADER* header = nullptr; const uint8_t* bitData = nullptr; size_t bitSize = 0; diff --git a/DirectXTex/DirectXTexD3D11.cpp b/DirectXTex/DirectXTexD3D11.cpp index 2a18503..f129fba 100644 --- a/DirectXTex/DirectXTexD3D11.cpp +++ b/DirectXTex/DirectXTexD3D11.cpp @@ -638,6 +638,9 @@ HRESULT DirectX::CreateShaderResourceViewEx( *ppSRV = nullptr; + if (!(bindFlags & D3D11_BIND_SHADER_RESOURCE)) + return E_INVALIDARG; + ComPtr resource; HRESULT hr = CreateTextureEx(pDevice, srcImages, nimages, metadata, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, diff --git a/WICTextureLoader/WICTextureLoader.cpp b/WICTextureLoader/WICTextureLoader.cpp index 1e0ec5e..1bd4c50 100644 --- a/WICTextureLoader/WICTextureLoader.cpp +++ b/WICTextureLoader/WICTextureLoader.cpp @@ -818,7 +818,14 @@ HRESULT DirectX::CreateWICTextureFromMemoryEx( } if (!d3dDevice || !wicData || (!texture && !textureView)) + { return E_INVALIDARG; + } + + if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) + { + return E_INVALIDARG; + } if (!wicDataSize) return E_FAIL; @@ -951,7 +958,14 @@ HRESULT DirectX::CreateWICTextureFromFileEx( } if (!d3dDevice || !fileName || (!texture && !textureView)) + { return E_INVALIDARG; + } + + if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) + { + return E_INVALIDARG; + } auto pWIC = _GetWIC(); if (!pWIC)