本文整理汇总了C++中D3DX11CompileFromFile函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DX11CompileFromFile函数的具体用法?C++ D3DX11CompileFromFile怎么用?C++ D3DX11CompileFromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D3DX11CompileFromFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: D3DX11CompileFromFile
void Heightfield::SetupPipeline()
{
// load and compile the two shaders
ID3D10Blob *VS, *PS;
D3DX11CompileFromFile("shaders.hlsl", 0, 0, "VShader", "vs_5_0", 0, 0, 0, &VS, 0, 0);
D3DX11CompileFromFile("shaders.hlsl", 0, 0, "PShader", "ps_5_0", 0, 0, 0, &PS, 0, 0);
// encapsulate both shaders into shader objects
mDev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &mVS);
mDev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &mPS);
// create the input layout object
D3D11_INPUT_ELEMENT_DESC ied[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 36, D3D11_INPUT_PER_VERTEX_DATA, 0}
};
mDev->CreateInputLayout(ied, 4, VS->GetBufferPointer(), VS->GetBufferSize(), &mLayout);
}
示例2: D3DX11CompileFromFile
// this function loads and prepares the shaders
void FRenderD3D11::InitPipeline()
{
// load and compile the two shaders
ID3D10Blob *VertexShader, *PixelShader;
D3DX11CompileFromFile(TEXT("..\\..\\Resource\\Shader\\shader.shader"), 0, 0, "VShader", "vs_4_0", 0, 0, 0, &VertexShader, 0, 0);
D3DX11CompileFromFile(TEXT("..\\..\\Resource\\Shader\\shader.shader"), 0, 0, "PShader", "ps_4_0", 0, 0, 0, &PixelShader, 0, 0);
// encapsulate both shaders into shader objects
m_pDevice->CreateVertexShader(VertexShader->GetBufferPointer(), VertexShader->GetBufferSize(), NULL, &m_pVertexShader);
m_pDevice->CreatePixelShader(PixelShader->GetBufferPointer(), PixelShader->GetBufferSize(), NULL, &m_pPixelShader);
// set the shader objects
m_pDeviceContext->VSSetShader(m_pVertexShader, 0, 0);
m_pDeviceContext->PSSetShader(m_pPixelShader, 0, 0);
// create the input layout object
D3D11_INPUT_ELEMENT_DESC ied[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
m_pDevice->CreateInputLayout(ied, _countof(ied), VertexShader->GetBufferPointer(), VertexShader->GetBufferSize(), &m_pLayout);
m_pDeviceContext->IASetInputLayout(m_pLayout);
}
示例3: HR
void BlendApp::BuildShaders()
{
HR(D3DX11CompileFromFile(L"Blend.hlsl", 0, 0, "VS", "vs_4_0", 0, 0, 0, &mVsBlob, 0, 0));
HR(md3dDevice->CreateVertexShader(mVsBlob->GetBufferPointer(), mVsBlob->GetBufferSize(), 0, &mVertexShader));
HR(D3DX11CompileFromFile(L"Blend.hlsl", 0, 0, "PS", "ps_4_0", 0, 0, 0, &mPsBlob, 0, 0));
HR(md3dDevice->CreatePixelShader(mPsBlob->GetBufferPointer(), mPsBlob->GetBufferSize(), 0, &mPixelShader));
}
示例4: ARRAYSIZE
HRESULT CAniShader::Init()
{
D3D11_INPUT_ELEMENT_DESC tInputLayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "BONES", 0, DXGI_FORMAT_R32G32B32A32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "BONES", 1, DXGI_FORMAT_R32G32B32A32_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "WEIGHTS", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "WEIGHTS", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
UINT iElementNum = ARRAYSIZE(tInputLayout);
DWORD swFlag = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
swFlag |= D3D10_SHADER_DEBUG;
#endif
ID3DBlob* pBlob = NULL, *pErrorBlob = NULL;
ID3D11Device* pDevice = m_pDevice->GetDevice();
if (SUCCEEDED(D3DX11CompileFromFile(L"../bin/Data/Fx/VertexAni.fx", NULL, NULL,
"VS", "vs_4_0", swFlag, 0, NULL, &pBlob, &pErrorBlob, NULL)))
{
pDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &m_pVertexShader);
pDevice->CreateInputLayout(
tInputLayout, iElementNum, pBlob->GetBufferPointer(), pBlob->GetBufferSize(), &m_pVertexLayout);
}
else
{
if (pErrorBlob) { FAILED_CHECK_MSG(E_FAIL, L"셰이더 컴파일 실패"); }
else { FAILED_CHECK_MSG(E_FAIL, L"셰이더 파일이 존재하지 않습니다."); }
return E_FAIL;
}
pBlob = pErrorBlob = NULL;
if (SUCCEEDED(D3DX11CompileFromFile(L"../bin/Data/Fx/VertexAni.fx", NULL, NULL,
"PS", "ps_4_0", swFlag, 0, NULL, &pBlob, &pErrorBlob, NULL)))
{
pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &m_pPixelShader);
}
else
{
if (pErrorBlob) { FAILED_CHECK_MSG(E_FAIL, L"셰이더 컴파일 실패"); }
else { FAILED_CHECK_MSG(E_FAIL, L"셰이더 파일이 존재하지 않습니다."); }
return E_FAIL;
}
::Safe_Release(pBlob);
::Safe_Release(pErrorBlob);
return S_OK;
}
示例5: CompileShaderFromFile
HRESULT CompileShaderFromFile(const WCHAR* szFileName,
LPCSTR szEntryPoint,
LPCSTR szShaderModel,
ID3DBlob** ppBlobOut)
{
HRESULT hr = S_OK;
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
dwShaderFlags |= D3DCOMPILE_DEBUG;
#endif
ID3DBlob* pErrorBlob;
hr = D3DX11CompileFromFile(szFileName, NULL, NULL, szEntryPoint, szShaderModel,
dwShaderFlags, 0, NULL, ppBlobOut, &pErrorBlob, NULL);
if (FAILED(hr))
{
if (pErrorBlob != NULL)
OutputDebugStringA((char*)pErrorBlob->GetBufferPointer());
if (pErrorBlob) pErrorBlob->Release();
return hr;
}
if (pErrorBlob) pErrorBlob->Release();
return S_OK;
}
示例6: defined
HRESULT CGraphics::CompileShaderFromFile( WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut )
{
HRESULT hr = S_OK;
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Sirve para que el shader proveea de información
//para debugueo, pero sin afectar el rendimiento.
dwShaderFlags |= D3DCOMPILE_DEBUG;
#endif
//Variable que se usa para obtener informacion
//de errores y poder saber en dónde ocurrió
//el error al compilar el shader
ID3DBlob* pErrorBlob;
//Compila el shader
hr = D3DX11CompileFromFile( szFileName, NULL, NULL, szEntryPoint, szShaderModel,
dwShaderFlags, 0, NULL, ppBlobOut, &pErrorBlob, NULL );
if( FAILED(hr) )
{
if( pErrorBlob != NULL )
OutputDebugStringA( (char*)pErrorBlob->GetBufferPointer() );
if( pErrorBlob ) pErrorBlob->Release();
return hr;
}
if( pErrorBlob ) pErrorBlob->Release();
return S_OK;
}
示例7: defined
bool Dx11DemoBase::CompileD3DShader( char * filePath , char * entry , char * shaderModle , ID3DBlob ** buffer )
{
DWORD shaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG )||defined( _DEBUG )
shaderFlags |= D3DCOMPILE_DEBUG;
#endif
ID3DBlob * errorBuffer = 0;
HRESULT result;
result = D3DX11CompileFromFile( filePath , 0 , 0 , entry , shaderModle , shaderFlags , 0 , 0 , buffer , &errorBuffer , 0 );
if( FAILED( result ))
{
if( errorBuffer != 0 )
{
OutputDebugStringA( ( char * )errorBuffer ->GetBufferPointer() );
errorBuffer ->Release();
}
return false;
}
if( errorBuffer !=0 )
{
errorBuffer ->Release();
}
return true;
}
示例8: defined
bool DirectX11ComputeShader::Load()
{
auto file = mResourceData->mFileSystem.getFilePath(mResourceData->mFileName);
if(!file.second)
{
mResourceData->mConsole.threadSafePrintError(StringUtility::format("Failed to locate file %", mResourceData->mFileName));
return true;
}
UINT shaderFlags = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR;
#if defined(SCGE_DEBUG)
shaderFlags |= D3D10_SHADER_DEBUG;
#endif
std::wstring fileName;
fileName.assign(file.first.begin(), file.first.end());
ComPtr<ID3D10Blob> errorMessage;
if(FAILED(D3DX11CompileFromFile(fileName.c_str(), mResourceData->mShaderDefines, nullptr, mResourceData->mFunctionName.c_str(), "cs_5_0", shaderFlags, 0, nullptr, mShaderBuffer.getModifiablePointer(), errorMessage.getModifiablePointer(), nullptr)))
{
mResourceData->mConsole.threadSafePrintError(StringUtility::format("Failed to compile Compute Shader : %, function : %", mResourceData->mFileName, mResourceData->mFunctionName));
if(errorMessage)
mResourceData->mConsole.threadSafePrintError(static_cast<const char *>(errorMessage->GetBufferPointer()));
return true;
}
return mResourceData->mMultiThreadLoad && finaliseLoad();
}
示例9: defined
//--------------------------------------------------------------------------------------
// Helper for compiling shaders with D3DX11
//--------------------------------------------------------------------------------------
HRESULT DxAssist::CompileShaderFromFile( const char* fileName, const char* entryPoint, const char* shaderModel, ID3DBlob** blobOut )
{
HRESULT hr = S_OK;
DWORD shaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
shaderFlags |= D3DCOMPILE_DEBUG;
#endif
ID3DBlob* errorBlob = 0;
hr = D3DX11CompileFromFile( fileName, NULL, NULL, entryPoint, shaderModel,
shaderFlags, 0, NULL, blobOut, &errorBlob, NULL );
if( FAILED(hr) )
{
if( errorBlob != NULL )
OutputDebugStringA( (char*)errorBlob->GetBufferPointer() );
if( errorBlob ) errorBlob->Release();
return hr;
}
if( errorBlob ) errorBlob->Release();
return S_OK;
}
示例10: defined
HRESULT PixelShaderClass::CompileShaderFromFile
(WCHAR* szFileName,
LPCSTR szEntryPoint,
LPCSTR szShaderModel,
ID3DBlob** ppBlobOut)
{
HRESULT hr = S_OK;
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DCOMPILE_DEBUG;
#endif
ID3DBlob* pErrorBlob;
hr = D3DX11CompileFromFile(szFileName, NULL, NULL, szEntryPoint, szShaderModel,
dwShaderFlags, 0, NULL, ppBlobOut, &pErrorBlob, NULL);
if (FAILED(hr))
{
if (pErrorBlob != NULL)
OutError(pErrorBlob);
if (pErrorBlob) pErrorBlob->Release();
return hr;
}
if (pErrorBlob) pErrorBlob->Release();
return S_OK;
}
示例11: PrepareShaderMacro
void GSDevice11::CompileShader(const char* fn, const char* entry, D3D11_SHADER_MACRO* macro, ID3D11ComputeShader** cs)
{
HRESULT hr;
vector<D3D11_SHADER_MACRO> m;
PrepareShaderMacro(m, macro);
CComPtr<ID3D11Blob> shader, error;
hr = D3DX11CompileFromFile(fn, &m[0], NULL, entry, m_shader.cs.c_str(), 0, 0, NULL, &shader, &error, NULL);
if(error)
{
printf("%s\n", (const char*)error->GetBufferPointer());
}
if(FAILED(hr))
{
throw GSDXRecoverableError();
}
hr = m_dev->CreateComputeShader((void*)shader->GetBufferPointer(), shader->GetBufferSize(),NULL, cs);
if(FAILED(hr))
{
throw GSDXRecoverableError();
}
}
示例12: loadShader
void loadShader(char* fileName, char* entryPoint, char* shaderModel, ID3DBlob** ppBlobOut)
{
DWORD shaderFlags = D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_DEBUG;
ID3DBlob* pErrorBlob;
g_hResult = D3DX11CompileFromFile(fileName, NULL, NULL, entryPoint, shaderModel, shaderFlags, 0, NULL, ppBlobOut, &pErrorBlob, NULL);
if (FAILED(g_hResult)) {
OutputDebugString("!!!!!!!! Failed to compile shader\n");
OutputDebugString(fileName);
OutputDebugString("\n");
OutputDebugString(entryPoint);
OutputDebugString("\n");
OutputDebugString(shaderModel);
OutputDebugString("\n");
if (pErrorBlob != NULL) {
OutputDebugString((char*) pErrorBlob->GetBufferPointer());
pErrorBlob->Release();
}
ExitProcess(0);
}
if (pErrorBlob) {
pErrorBlob->Release();
}
}
示例13: CreateShader
/*-------------------------------------------
シェーダの作成
--------------------------------------------*/
HRESULT CreateShader(void)
{
HRESULT hr;
// コンピュート・シェーダのコードをコンパイル
ID3DBlob* pBlobVS = NULL;
hr = D3DX11CompileFromFile(
L"..\\misc\\D3D11Sample19.sh", // ファイル名
NULL, // マクロ定義(なし)
NULL, // インクルード・ファイル定義(なし)
"CS", // 「CS関数」がシェーダから実行される
"cs_4_0", // コンピュート・シェーダ
g_flagCompile, // コンパイル・オプション
0, // エフェクトのコンパイル・オプション(なし)
NULL, // 直ぐにコンパイルしてから関数を抜ける。
&pBlobVS, // コンパイルされたバイト・コード
NULL, // エラーメッセージは不要
NULL); // 戻り値
if (FAILED(hr))
return DXTRACE_ERR(L"D3DX11CompileShaderFromFile", hr);
// コンピュート・シェーダの作成
hr = g_pD3DDevice->CreateComputeShader(
pBlobVS->GetBufferPointer(),// バイト・コードへのポインタ
pBlobVS->GetBufferSize(), // バイト・コードの長さ
NULL,
&g_pComputeShader); //
SAFE_RELEASE(pBlobVS); // バイト・コードを解放
if (FAILED(hr))
return DXTRACE_ERR(L"g_pD3DDevice->CreateComputeShader", hr);
return hr;
}
示例14: defined
bool ParticleManager::CompileShader(ID3DBlob** shader, string filename, string entry, string shaderModel)
{
DWORD shaderFlags = 0;
ID3DBlob* errorBuffer = 0;
HRESULT hResult;
//If debugging then compile shader in debug mode for error messages
#if defined(DEBUG) || defined(_DEBUG)
shaderFlags |= D3DCOMPILE_DEBUG;
#endif
//Compile the shader using the determined filename, entry point, shader model
hResult = D3DX11CompileFromFile(filename.c_str(), 0, 0, entry.c_str(), shaderModel.c_str(),
shaderFlags, 0, 0, shader, &errorBuffer, 0);
//If the returned shader has errored then see what line in the .fx file
if (errorBuffer != 0)
{
MessageBoxA(NULL, (char*)errorBuffer->GetBufferPointer(), 0, 0);
errorBuffer->Release();
errorBuffer = 0;
}
//If the compile failed completely then return a DXTRACE msg to link back to this function call
if (FAILED(hResult))
{
DXTRACE_MSG(__FILE__, (DWORD)__LINE__, hResult, "D3DX11CompileFromFile", true);
return false;
}
return true;
}
示例15: LoadShader
void Shader::LoadShader(ID3D11Device * d3ddev)
{
sShaderReady = false;
BOOL b = true;
if (FAILED(D3DX11CompileFromFile(ShaderFileAddr, 0, 0, "CONEVS", "vs_5_0", 0, 0, 0, &VertexShaderBlob, 0, 0))) b = false;
if (FAILED(D3DX11CompileFromFile(ShaderFileAddr, 0, 0, "CONEPS", "ps_5_0", 0, 0, 0, &PixelShaderBlob, 0, 0))) b = false;
if (!b)
{
Log("Failed to load shader");
}
else {
sShaderReady = true;
d3ddev->CreatePixelShader(PixelShaderBlob->GetBufferPointer(), PixelShaderBlob->GetBufferSize(), NULL, &PS);
d3ddev->CreateVertexShader(VertexShaderBlob->GetBufferPointer(), VertexShaderBlob->GetBufferSize(), NULL, &VS);
}
}