我尝试使用 DirectX 11 创建计算着色器,但它会导致访问冲突。
ID3DBlob* csBlob = nullptr;
ID3DBlob* errorBlob = nullptr;
if (FAILED(D3DCompileFromFile(csFilename, NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, "main", "cs_5_0",
D3DCOMPILE_ENABLE_STRICTNESS, 0, &csBlob, &errorBlob)))
{
if (errorBlob)
OutputShaderErrorMessage(errorBlob, hwnd, csFilename);
else
MessageBox(hwnd, csFilename, L"Compute shader non trouvé", MB_OK);
return false;
}
if (FAILED(device->CreateComputeShader(csBlob->GetBufferPointer(), csBlob->GetBufferSize(),
nullptr, &m_computeShader)))
{
MessageBox(hwnd, csFilename, L"Erreur de création du compute shader", MB_OK);
return false;
}
return true;
感谢您的帮助! :d