Status randomData(DataChunk &result, size_t size) { DataChunk out; out.resize(size); if (!RAND_bytes(out.data(), out.size())) return ABC_ERROR(ABC_CC_Error, "Random data generation failed"); result = std::move(out); return Status(); }
void DirectXShader::compileShader(const std::shared_ptr<class DirectXRenderer>& renderer, DataChunk data, ID3DInclude* includes, const std::string& entryPoint, ShaderType type) { ComPtr<ID3D10Blob> errors; HRESULT hr = D3DCompile(data.data(), data.size(), "", NULL, includes, entryPoint.c_str(), getTarget(type), D3DCOMPILE_DEBUG | D3DCOMPILE_PREFER_FLOW_CONTROL | D3DCOMPILE_SKIP_OPTIMIZATION, 0, mBlob.getInitRef(), errors.getInitRef()); if (hr != S_OK) { log("%s", errors->GetBufferPointer()); runtimeCheck(false); } switch (type) { case ShaderType::Vertex: hr = renderer->getDevice()->CreateVertexShader(mBlob->GetBufferPointer(), mBlob->GetBufferSize(), nullptr, mVertexShader.getInitRef()); TB::runtimeCheck(hr == S_OK); break; case ShaderType::Pixel: hr = renderer->getDevice()->CreatePixelShader(mBlob->GetBufferPointer(), mBlob->GetBufferSize(), nullptr, mPixelShader.getInitRef()); TB::runtimeCheck(hr == S_OK); break; } }