Friday 15 May 2015

c++ - Need Help Understanding Invalid Argument Error When Creating Vertex Shader -


I am just starting in DirectX 11, and I have participated in a problem. I am loading an extremely simple Shader in an HSDL file:

  struct VOut {float4 status: SV_POSITION; Float4 color: color; }; VOut VS_Main (float4 pos: POSITION, float4 color: COLOR) {output output; Output.position = pos; Output.color = color; Return output; } Float 4 PS_Minias (Float 4 Pauses: SV_Position, Float4 Color: COLOR): SV_Tagate {Return color; }   

Using the following code (which does not trigger if (failed (result) statement):

  bool PathfindingDemoBase :: CompileD3DShader (char * FilePath, four * entry, four * shaderModel, ID3DBlob ** buffer) {DWORD shaderFlags = D3DCOMPILE_ENABLE_STRICTNESS; #define (DEBUG) || define (_DEBUG) shaderFlags | = D3DCOMPILE_DEBUG; #endif ID3DBlob * errorBuffer = 0; HRESULT result; Results = D3DX11CompileFromFile (filePath, 0, 0, entry, ShadderModel, 0, 0, 0, buffer, and error buffer, 0); if (failed (result)) {if (errorBuffer! = 0) {output debug string ((* four *) Error buffer -> GetBufferPointer ()); errorBuffer- & gt; ; Release ();} return false;} if (errorBuffer! = 0) {errorBuffer-> release ();} trueity back;}   

but what happens in the load content function The commented line (// Bool Asterado :: Load Content () {ID3D10Blob * vsBuffer = 0; Bool CompileResult = CompileD3DShader ("ReturnColor.hlsl", "VS_Main", "vs_5_0", and vs. buffer); If (compile == wrong) {message box (0, "Error loading vertex shader!", "Compile error", MB_OK); return false; } HRESULT d3dResult; D3dResult = d3dDevice-> CreateVertexShader (vsBuffer-> GetBufferPointer (), vsBuffer- & gt; GetBufferSize (), 0, and ReturnColorVS); // In fact the summit shader d3dContext-> VSSetShader (return ColorVS, 0, 0) set; If (FAILED (d3dResult) {if (buffer) {vsBuffer-> Release (); } return false; } D3D11_INPUT_ELEMENT_DESC solid collar layout [] = {{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA,}}; Unsigned int totalLayoutElements = ARRAYSIZE (solid collar layout); D3dResult = d3dDevice-> CreateInputLayout (Solid Collar Layout, Total Layout Elements, vsBuffer- & gt; GetBufferPointer (), vsBuffer- & gt; GetBufferSize (), and Input Layouts); VsBuffer- & gt; Release (); If (FAILED (d3dResult)) {return false; } ID3D10Blob * psBuffer = 0; CompileResult = CompileD3DShader ("ReturnColor.hlsl", "PS_Main", "ps_5_0", and psBuffer); // In fact pixel shader D3 decontax-> Set up PSSetShader (return collar, 0, 0); If (compile == incorrect) {message box (0, "error loading pixel shader!", "Compile error", MB_OK); return false; } D3dResult = d3dDevice-> CreatePixelShader (psBuffer-> GetBufferPointer (), psBuffer-> GetBufferSize (), 0, and ReturnColorPS); PsBuffer- & gt; Release (); If (FAILED (d3dResult)) {return false; } Vertical peak [4 * TOTAL_NUMBER_GRID_SQUARES]; GridSquares = New Gridware [TOTAL_NUMBER_GRID_SQUARES]; // For each grid class (int i = 0; i & lt; TOTAL_NUMBER_GRID_SQUARES; i ++) {XMFLOAT4 color = ((i% 2) == 0)? green red; // Create a grid class object; GridScare GS; Gs.TopLeft = Vertex (XMFLOAT3 (0.5 f * i, 0.5 f * i, z_LEVEL, colored); Gs.TopRight = Vertex (XMFOLAT3 (0.5 F * I, -0.5F * I, ZLLEELE, Color); Gs.BottomRight = Vertex (XMFLOAT3 (-0.5f * i, -0.5f * i, Z_LEVEL, colored); Gs.BottomLeft = Vertex (XMFLOAT3 (-0.5f * i, 0.5 f * i, z_LEVEL), color); Gs.type = ((i% 2) == 0)? Hunting: Hunters; GridSquares [I] = GS; Corners [4 * i] = GS Top left; Corners [(4 * i) + 1] = GS Oprah; Upper part [(4 * i +2] = g. Bottomlight; Upper part [(4 * i +3] = G. Bottom left; } D311_BUFFER_DESC Vertex Disk; Zoramori (and vertexdisk, shaped (VertxDSc)); Pinnacle Desc.Usage = D3D11_USAGE_DYNAMIC; Vertexdes .bindflags = D3d_bbibsfttexbufff; VertexDesc.ByteWidth = 4 * TOTAL_NUMBER_GRID_SQUARES * size (verttex); VertxdccUpuVVSflags = D3D11_CPU_ACCESS_WRITE; D3D11_SUBRESOURCE_DATA resource data; Zoramori (and resource data, size (resource data)); ResourceData.pSysMem = Meridian; D3dResult = d3dDevice-> CreateBuffer (& vertexDesc, and Resource Data, & amp; vertexBuffer); If (FAILED (d3dResult)) {return false; } Back true; }

Any advice would be greatly appreciated! :)

Answer after a little excavation - apparently something like using "ps_5_0" There are problems and "vs_5_0", even though my machine runs DirectX 11

No comments:

Post a Comment