Ex texture loaders updated with additional parameter validation (#142)
This commit is contained in:
parent
a161b96dec
commit
f55158d557
@ -1776,6 +1776,11 @@ HRESULT DirectX::CreateDDSTextureFromMemoryEx(
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE))
|
||||||
|
{
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
// Validate DDS file in memory
|
// Validate DDS file in memory
|
||||||
const DDS_HEADER* header = nullptr;
|
const DDS_HEADER* header = nullptr;
|
||||||
const uint8_t* bitData = nullptr;
|
const uint8_t* bitData = nullptr;
|
||||||
@ -1906,6 +1911,11 @@ HRESULT DirectX::CreateDDSTextureFromFileEx(
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE))
|
||||||
|
{
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
const DDS_HEADER* header = nullptr;
|
const DDS_HEADER* header = nullptr;
|
||||||
const uint8_t* bitData = nullptr;
|
const uint8_t* bitData = nullptr;
|
||||||
size_t bitSize = 0;
|
size_t bitSize = 0;
|
||||||
|
@ -638,6 +638,9 @@ HRESULT DirectX::CreateShaderResourceViewEx(
|
|||||||
|
|
||||||
*ppSRV = nullptr;
|
*ppSRV = nullptr;
|
||||||
|
|
||||||
|
if (!(bindFlags & D3D11_BIND_SHADER_RESOURCE))
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
ComPtr<ID3D11Resource> resource;
|
ComPtr<ID3D11Resource> resource;
|
||||||
HRESULT hr = CreateTextureEx(pDevice, srcImages, nimages, metadata,
|
HRESULT hr = CreateTextureEx(pDevice, srcImages, nimages, metadata,
|
||||||
usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB,
|
usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB,
|
||||||
|
@ -818,7 +818,14 @@ HRESULT DirectX::CreateWICTextureFromMemoryEx(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!d3dDevice || !wicData || (!texture && !textureView))
|
if (!d3dDevice || !wicData || (!texture && !textureView))
|
||||||
|
{
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE))
|
||||||
|
{
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
if (!wicDataSize)
|
if (!wicDataSize)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
@ -951,7 +958,14 @@ HRESULT DirectX::CreateWICTextureFromFileEx(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!d3dDevice || !fileName || (!texture && !textureView))
|
if (!d3dDevice || !fileName || (!texture && !textureView))
|
||||||
|
{
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE))
|
||||||
|
{
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
auto pWIC = _GetWIC();
|
auto pWIC = _GetWIC();
|
||||||
if (!pWIC)
|
if (!pWIC)
|
||||||
|
Loading…
Reference in New Issue
Block a user