mojoshader_d3d11.c
changeset 1305 1fc6f843168f
parent 1296 9b3b01f2a9b7
child 1312 f6fbe7e72735
equal deleted inserted replaced
1304:d68910d81b6e 1305:1fc6f843168f
   502     result = ctx->D3DCompileFunc(source, strlen(source),
   502     result = ctx->D3DCompileFunc(source, strlen(source),
   503                                  pshader->parseData->mainfn, NULL, NULL,
   503                                  pshader->parseData->mainfn, NULL, NULL,
   504                                  pshader->parseData->mainfn, "ps_4_0",
   504                                  pshader->parseData->mainfn, "ps_4_0",
   505                                  D3D_SKIP_OPT, 0, &blob, &blob);
   505                                  D3D_SKIP_OPT, 0, &blob, &blob);
   506 
   506 
       
   507     if (needs_free)
       
   508         ctx->free_fn((void *) source, ctx->malloc_data);
       
   509 
   507     if (result < 0)
   510     if (result < 0)
   508     {
   511     {
   509         set_error((const char *) ID3D10Blob_GetBufferPointer(blob));
   512         set_error((const char *) ID3D10Blob_GetBufferPointer(blob));
   510         ctx->free_fn((void *) source, ctx->malloc_data);
       
   511         return NULL;
   513         return NULL;
   512     } // if
   514     } // if
   513 
   515 
   514     ID3D11Device_CreatePixelShader(ctx->device,
   516     ID3D11Device_CreatePixelShader(ctx->device,
   515                                    ID3D10Blob_GetBufferPointer(blob),
   517                                    ID3D10Blob_GetBufferPointer(blob),
   516                                    ID3D10Blob_GetBufferSize(blob),
   518                                    ID3D10Blob_GetBufferSize(blob),
   517                                    NULL, &retval);
   519                                    NULL, &retval);
   518 
   520 
   519     ID3D10Blob_Release(blob);
   521     ID3D10Blob_Release(blob);
   520     if (needs_free)
       
   521         ctx->free_fn((void *) source, ctx->malloc_data);
       
   522     return retval;
   522     return retval;
   523 } // compilePixelShader
   523 } // compilePixelShader
   524 
   524 
   525 /* Public API */
   525 /* Public API */
   526 
   526 
   834 
   834 
   835     // Add the new mapping
   835     // Add the new mapping
   836     vshader->shaderMaps[vshader->numMaps].vertex.layoutHash = inputLayoutHash;
   836     vshader->shaderMaps[vshader->numMaps].vertex.layoutHash = inputLayoutHash;
   837     ID3D11VertexShader *vs = compileVertexShader(vshader, newSource,
   837     ID3D11VertexShader *vs = compileVertexShader(vshader, newSource,
   838                                                  srcLength, &blob);
   838                                                  srcLength, &blob);
       
   839     if (newSource != origSource)
       
   840         ctx->free_fn((void *) newSource, ctx->malloc_data);
   839     vshader->shaderMaps[ctx->vertexShader->numMaps].val = vs;
   841     vshader->shaderMaps[ctx->vertexShader->numMaps].val = vs;
   840     vshader->shaderMaps[ctx->vertexShader->numMaps].vertex.blob = blob;
   842     vshader->shaderMaps[ctx->vertexShader->numMaps].vertex.blob = blob;
   841     ctx->vertexShader->numMaps++;
   843     ctx->vertexShader->numMaps++;
   842     assert(vs != NULL);
   844     assert(vs != NULL);
   843 
   845