
[ad_1]
I’m attempting to create immutable texture in d3d11 so I wish to use subresourceData, each tutorial on textures creates them with 2nd argument being null and after that updates subresource however I wish to create it utilizing the 2nd argument.
This code works:
hResult = m_device->CreateTexture2D(&textureDesc, NULL, &m_cubeTexture);
if (FAILED(hResult)) {
return false;
}
int rowPitch = textureWidth * 4;
m_deviceContext->UpdateSubresource(m_cubeTexture, 0, NULL, &(decodedTexture[0]), rowPitch, rowPitch * textureHeight);
And this doesn’t:
int rowPitch = textureWidth * 4;
D3D11_SUBRESOURCE_DATA tSData;
tSData.pSysMem = &(decodedTexture[0]);
tSData.SysMemPitch = rowPitch;
tSData.SysMemSlicePitch = rowPitch * textureHeight;
hResult = m_device->CreateTexture2D(&textureDesc, &tSData, &m_cubeTexture);
if (FAILED(hResult)) {
return false;
}
DirectX11 debug layer outputs this:
D3D11 ERROR: ID3D11Device::CreateTexture2D: pInitialData[3].SysMemPitch can't be 0 [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA]
D3D11 ERROR: ID3D11Device::CreateTexture2D: pInitialData[5].pSysMem can't be NULL. [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA]
Which I do not perceive since it isn’t even an array and texture array dimension is ready to 1
[ad_2]