I'm using DirectX 11. I pre-compiling the shader and then loading at a runtime. I'm loading the file into a buffer and then sending it in to CreateVertexShader. When I call CreateVertexShader with the debug layer turned on, I get the following error:
Encoded Vertex Shader size doesn't match specified size
I'm compiling the vertex shader at the command line as follows:
fxc /Fc /Od /Zi /T fx_5_0 /Fo "myfile.cso" "myfile.fx"
In the case of a simple shader, the resulting file is around 200 bytes. I can verify that Windows explorer and my code both report the same number of bytes.
I've tried variations of fx_5_0.
Here is how I am loading the file:
uint32_t length, rr;
char *buffer;
FILE *fp;
fp = fopen("<path to file>\\myfile.cso", "rb");
fseek(fp, 0, SEEK_END);
length = ftell(fp);
fseek(fp, 0, SEEK_SET);
buffer = (char*)calloc(1, length);
rr = fread(buffer, sizeof(char), length, fp);
fclose(fp);
assert(rr == length);
Then:
hr = device->lpVtbl->CreateVertexShader(device, buffer, length, NULL, NULL );
(Note: I'm passing NULL to the last param expecting to get S_FALSE as the return code)
I'm not sure what else to try to solve this.