pouët.net

[c++,dx11], compiler shader from Memory

category: code [glöplog]
 
Heej,

i try to compile a vertex shader on runtime. But it is not working. How to fix it??

Code: char *VERTEXSHADER = R"( cbuffer PerApplication : register(b0) { matrix projectionMatrix; } cbuffer PerFrame : register(b1) { matrix viewMatrix; } cbuffer PerObject : register(b2) { matrix worldMatrix; } struct AppData { float3 position : POSITION; float3 color : COLOR; }; struct VertexShaderOutput { float4 color : COLOR; float4 position : SV_POSITION; }; VertexShaderOutput SimpleVertexShader(AppData IN) { VertexShaderOutput OUT; matrix mvp = mul(projectionMatrix, mul(viewMatrix, worldMatrix)); OUT.position = mul(mvp, float4(IN.position, 1.0f)); OUT.color = float4(IN.color, 1.0f); return OUT; } )"; // Load the compiled vertex shader. ID3DBlob* vertexShaderBlob=NULL; ID3DBlob* vertexShaderBlobError=NULL; hr= D3DCompile( &VERTEXSHADER, //in LPCVOID pSrcData, sizeof(VERTEXSHADER), //in SIZE_T SrcDataSize, NULL, //in_opt LPCSTR pSourceName, NULL, //in_opt const D3D_SHADER_MACRO pDefines, NULL, //in_opt ID3DInclude pInclude, "SimpleVertexShader", //in LPCSTR pEntrypoint, "vs_5_0", //in LPCSTR pTarget, D3DCOMPILE_OPTIMIZATION_LEVEL3 ,//in UINT Flags1, NULL, //in UINT Flags2, &vertexShaderBlob, //out ID3DBlob ppCode, &vertexShaderBlobError //out_opt ID3DBlob ppErrorMsgs ); if (FAILED(hr)) return false;


Thanks for helping :-)
added on the 2015-07-27 14:32:22 by nebulus nebulus
Very cursory look but if VERTEXSHADER is char*, shouldnt you pass that instead of &VERTEXSHADER as a first parameter?
added on the 2015-07-27 14:42:58 by Gargaj Gargaj
I tryed everything , VERTEXSHADER or &VERTEXSHADER , no difference
added on the 2015-07-27 15:14:15 by nebulus nebulus
Are there messages in vertexShaderBlobError?
added on the 2015-07-27 15:15:13 by Gargaj Gargaj
Yes,
- __vfptr D3DCompiler_47.dll!0x5a4d0a94 (Symbole für zusätzliche Informationen laden) {D3DCompiler_47.dll!0x5a74d811, ...} void * *

- __vfptr D3DCompiler_47.dll!0x5a4d0a94 (Symbole für zusätzliche Informationen laden) {D3DCompiler_47.dll!0x5a74d811, ...} void * *

- 0x006b5c38 <Keine Informationen verfügbar. Für D3DCompiler_47.dll wurden keine Symbole geladen> ID3D10Blob *
added on the 2015-07-27 15:25:07 by nebulus nebulus
I have no clue about D3D but I assume D3DCompile expects the length of the source and not sizeof(char*).
added on the 2015-07-27 15:28:59 by hfr hfr
YES, thats it.. :-) Now it is compiling without Errors... :-)
added on the 2015-07-27 15:37:09 by nebulus nebulus

login