Skip to main content
GameDev.net gamedev.net
🔒 Locked

does the hlsl compiler optimize for specific gpus

Started by ucfchuck Jul 5, 2017 at 6:47 PM 2 replies 1.3k views
Original Post
ucfchuck
ucfchuck

I have a set of shaders that i want to compile to run on different machines, and I want to precompile them. does the compiler optimize the code for the current graphics driver of the machine it is being compiled on?


say i have an nvidia 750m and precompile my shaders with D3DXSHADER_OPTIMIZATION_LEVEL3 set. and then i move those shaders to run on an intel integrated gpu. Are they as efficient on the intel gpu when precompiled on the nvidia vs compiled directly on the intel at runtime?

WFP
WFP

On mobile right now, but briefly - the HLSL compiler will spit out the same intermediate bytecode regardless of what your system specs are. When your application calls a D3D function to load the shader from the pre-compiled bytecode, it will be compiled again in a vendor-specific way before actually being used. So to answer your question - you can compile a shader on one machine with a dedicated GPU and run it on another machine with an integrated GPU just fine.

ucfchuck
ucfchuck

Thank you, I couldnt find where i read it before, but i kept thinking that the compile used the gpu driver to optimize to that hardware. I had set it up to compile on the target machine on the first execution, and output the compiled shader byte code to an fxo file and just load that every time the application started thereafter. but it left me nervous about shipping the uncompiled, unobfuscated, and fully commented shaders.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.