Closed VladimirMakeew closed 7 months ago
Thanks Vladimir, however this "name" should not be used in any shader compilation-related process. If it does, we should fix it.
The name of all gfx
resources should only ever be used for debugging purposes (so it shows up in a Pix capture for instance) and as a matter of fact can be renamed by the user of the API to anything.
Under the hood, the full name and path should be stored as heap-allocated strings under the internal Program
structure:
https://github.com/gboisse/gfx/blob/7e89c1156aeb4dc8323cae5da343caa14fd980da/gfx.cpp#L645-L646
Let's make sure that these are used for all shader compilation functions and not that (re-namable) GfxProgram::name
, which is, again, purely intended for debugging purposes and should not be used for anything else.
Investigated this a bit further and I'd say this buffer is probably the culprit: https://github.com/gboisse/gfx/blob/7e89c1156aeb4dc8323cae5da343caa14fd980da/gfx.cpp#L8116
Please turn both shader_file
and wshader_file
into a std:string
and std::wstring
respectively and we can call it a day.
While you're at it, also apply a similar fix to the .pdb
files please:
https://github.com/gboisse/gfx/blob/7e89c1156aeb4dc8323cae5da343caa14fd980da/gfx.cpp#L8296
Thanks for quick answer and investigation.
I was thinking about this code: https://github.com/gboisse/gfx/blob/master/gfx.cpp#L2312
Instead of creating gfx_program.file_path
from argument we use program.name
. program.name as you mentioned is a small buffer for debug purposes, so I guess I should fix this place first.
ha, good finding, you've definitely found another issue 😉
Yes, that code is incorrect indeed and needs fixing.
Investigated this a bit further and I'd say this buffer is probably the culprit:
https://github.com/gboisse/gfx/blob/7e89c1156aeb4dc8323cae5da343caa14fd980da/gfx.cpp#L8116
Please turn both
shader_file
andwshader_file
into astd:string
andstd::wstring
respectively and we can call it a day.While you're at it, also apply a similar fix to the
.pdb
files please:https://github.com/gboisse/gfx/blob/7e89c1156aeb4dc8323cae5da343caa14fd980da/gfx.cpp#L8296
Investigated this a bit further and I'd say this buffer is probably the culprit:
https://github.com/gboisse/gfx/blob/7e89c1156aeb4dc8323cae5da343caa14fd980da/gfx.cpp#L8116
Please turn both
shader_file
andwshader_file
into astd:string
andstd::wstring
respectively and we can call it a day.While you're at it, also apply a similar fix to the
.pdb
files please:https://github.com/gboisse/gfx/blob/7e89c1156aeb4dc8323cae5da343caa14fd980da/gfx.cpp#L8296
This has already been done in #114
Increasing
kGfxConstant_MaxNameLength
up to 260 characters (MAX_PATH
fromwindows.h
header file) should fix the problem with long shader paths. The root of the problem isGfxProgram::name
buffer that is too small to store long paths and the full path to the shader file is truncated (for example inGfxInternal::createProgram
).