I'm trying to create immutable texture in d3d11 so I want to use subresourceData, every tutorial on textures creates them with 2nd argument being null and after that updates subresource but I want to create it using 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 does not:
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 cannot be 0 [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA] D3D11 ERROR: ID3D11Device::CreateTexture2D: pInitialData[5].pSysMem cannot be NULL. [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA] Which I don't understand since it's not even an array and texture array size is set to 1
initDatainitialization. The source code for these should help. \$\endgroup\$