- fix shaders only being loaded from the engine pk3

This commit is contained in:
Magnus Norddahl 2019-03-12 15:02:21 +01:00
parent 6be5769746
commit aa84f7b3e6
3 changed files with 18 additions and 9 deletions

View file

@ -363,7 +363,7 @@ void VkPostprocess::CompileEffectShaders()
FString VkPostprocess::LoadShaderCode(const FString &lumpName, const FString &defines, int version) FString VkPostprocess::LoadShaderCode(const FString &lumpName, const FString &defines, int version)
{ {
int lump = Wads.CheckNumForFullName(lumpName, 0); int lump = Wads.CheckNumForFullName(lumpName);
if (lump == -1) I_FatalError("Unable to load '%s'", lumpName.GetChars()); if (lump == -1) I_FatalError("Unable to load '%s'", lumpName.GetChars());
FString code = Wads.ReadLump(lump).GetString().GetChars(); FString code = Wads.ReadLump(lump).GetString().GetChars();

View file

@ -217,7 +217,7 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadVertShader(FString shadername
FString code = GetTargetGlslVersion(); FString code = GetTargetGlslVersion();
code << defines << shaderBindings; code << defines << shaderBindings;
code << "#line 1\n"; code << "#line 1\n";
code << LoadShaderLump(vert_lump).GetChars() << "\n"; code << LoadPrivateShaderLump(vert_lump).GetChars() << "\n";
ShaderBuilder builder; ShaderBuilder builder;
builder.setVertexShader(code); builder.setVertexShader(code);
@ -233,19 +233,19 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
if (gbufferpass) code << "#define GBUFFER_PASS\n"; if (gbufferpass) code << "#define GBUFFER_PASS\n";
code << "\n#line 1\n"; code << "\n#line 1\n";
code << LoadShaderLump(frag_lump).GetChars() << "\n"; code << LoadPrivateShaderLump(frag_lump).GetChars() << "\n";
if (material_lump) if (material_lump)
{ {
if (material_lump[0] != '#') if (material_lump[0] != '#')
{ {
FString pp_code = LoadShaderLump(material_lump); FString pp_code = LoadPublicShaderLump(material_lump);
if (pp_code.IndexOf("ProcessMaterial") < 0) if (pp_code.IndexOf("ProcessMaterial") < 0)
{ {
// this looks like an old custom hardware shader. // this looks like an old custom hardware shader.
// add ProcessMaterial function that calls the older ProcessTexel function // add ProcessMaterial function that calls the older ProcessTexel function
code << "\n" << LoadShaderLump("shaders/glsl/func_defaultmat.fp").GetChars() << "\n"; code << "\n" << LoadPrivateShaderLump("shaders/glsl/func_defaultmat.fp").GetChars() << "\n";
if (pp_code.IndexOf("ProcessTexel") < 0) if (pp_code.IndexOf("ProcessTexel") < 0)
{ {
@ -269,7 +269,7 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
if (pp_code.IndexOf("ProcessLight") < 0) if (pp_code.IndexOf("ProcessLight") < 0)
{ {
code << "\n" << LoadShaderLump("shaders/glsl/func_defaultlight.fp").GetChars() << "\n"; code << "\n" << LoadPrivateShaderLump("shaders/glsl/func_defaultlight.fp").GetChars() << "\n";
} }
} }
else else
@ -282,7 +282,7 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
if (light_lump) if (light_lump)
{ {
code << "\n#line 1\n"; code << "\n#line 1\n";
code << LoadShaderLump(light_lump).GetChars(); code << LoadPrivateShaderLump(light_lump).GetChars();
} }
ShaderBuilder builder; ShaderBuilder builder;
@ -295,7 +295,15 @@ FString VkShaderManager::GetTargetGlslVersion()
return "#version 450 core\n"; return "#version 450 core\n";
} }
FString VkShaderManager::LoadShaderLump(const char *lumpname) FString VkShaderManager::LoadPublicShaderLump(const char *lumpname)
{
int lump = Wads.CheckNumForFullName(lumpname);
if (lump == -1) I_Error("Unable to load '%s'", lumpname);
FMemLump data = Wads.ReadLump(lump);
return data.GetString();
}
FString VkShaderManager::LoadPrivateShaderLump(const char *lumpname)
{ {
int lump = Wads.CheckNumForFullName(lumpname, 0); int lump = Wads.CheckNumForFullName(lumpname, 0);
if (lump == -1) I_Error("Unable to load '%s'", lumpname); if (lump == -1) I_Error("Unable to load '%s'", lumpname);

View file

@ -95,7 +95,8 @@ private:
std::unique_ptr<VulkanShader> LoadFragShader(FString shadername, const char *frag_lump, const char *material_lump, const char *light_lump, const char *defines, bool alphatest, bool gbufferpass); std::unique_ptr<VulkanShader> LoadFragShader(FString shadername, const char *frag_lump, const char *material_lump, const char *light_lump, const char *defines, bool alphatest, bool gbufferpass);
FString GetTargetGlslVersion(); FString GetTargetGlslVersion();
FString LoadShaderLump(const char *lumpname); FString LoadPublicShaderLump(const char *lumpname);
FString LoadPrivateShaderLump(const char *lumpname);
VulkanDevice *device; VulkanDevice *device;