Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Loading Precompiled Shader?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 NotTakenSN   Members   

149
Like
0Likes
Like

Posted 08 December 2012 - 11:26 AM

I'm trying to remove the effects pipeline from my program and have realized that I have no idea how to load a precompiled shader without the effects functions. I've found example code that uses D3DReadFileToBlob, but that is only available in the Windows 8 SDK (I'm using the June 2010 SDK). I've even tried linking to the d3dcompiler.lib in the Windows 8 SDK, but still can't use the function. Right now, I'm attempting to read in the file through std::ifstream into a std::vector<char>, then use CreateVertexShader(). Is this the right way to go? Also, how do I set up the input layout afterwards? Most of the examples I see store the byte code in a ID3DBlob, so they are able to use ID3DBlob::GetBufferPointer() to retrieve the void *pShaderBytecodeWithInputSignature required in the CreateInputLayout() function. My byte code is stored in a vector<char>, so how do I do this? Can I create a ID3DBlob from a vector<char>?

#2 kunos   Members   

2254
Like
0Likes
Like

Posted 08 December 2012 - 11:37 AM

I save on the file the size of the blob then the blob itself. Then read like this straight into the blob:
in.read((char*)vs_blob->GetBufferPointer() , vs_size);

After that, once you have the blob, you go on creating your shader as usual.

#3 ~Helgon   Members   

361
Like
0Likes
Like

Posted 08 December 2012 - 01:01 PM

Hi, im doing it this way:

filename is for example: L"Shadows.cso" (or what ever format you have, maybe .fxo)
mFX is : ID3DX11Effect* mFX;

std::ifstream fin(filename, std::ios::binary);
fin.seekg(0, std::ios_base::end);
int size = (int)fin.tellg();
fin.seekg(0, std::ios_base::beg);
std::vector<char> compiledShader(size);
fin.read(&amp;amp;amp;compiledShader[0], size);
fin.close();

D3DX11CreateEffectFromMemory(&compiledShader[0], size, 0, device, &mFX);

Regards

Edited by ~Helgon, 08 December 2012 - 01:03 PM.

from time to time i find time





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.