/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #ifndef CRYINCLUDE_CRYENGINE_RENDERDLL_COMMON_SHADERS_REMOTECOMPILER_H #define CRYINCLUDE_CRYENGINE_RENDERDLL_COMMON_SHADERS_REMOTECOMPILER_H #pragma once #include namespace NRemoteCompiler { typedef std::vector tdEntryVec; enum EServerError { ESOK, ESFailed, ESInvalidState, ESCompileError, ESNetworkError, ESSendFailed, ESRecvFailed, }; #if defined(AZ_PLATFORM_PROVO) || defined(TOOLS_SUPPORT_PROVO) #include "Provo/RemoteCompiler_h_provo.inl" #endif #if defined(AZ_PLATFORM_XENIA) || defined(TOOLS_SUPPORT_XENIA) #include "Xenia/RemoteCompiler_h_xenia.inl" #endif enum EShaderCompiler { eSC_Unknown, eSC_Orbis_DXC, eSC_Durango_FXC, eSC_D3D11_FXC, eSC_GLSL_HLSLcc, eSC_METAL_HLSLcc, eSC_GLSL_LLVM_DXC, eSC_METAL_LLVM_DXC, eSC_MAX }; class RemoteProxyState; class CShaderSrv { public: // the main entry into this system // on return, rVec contains the response vector, or an error string, if failed EServerError Compile(std::vector& rVec, const char* pProfile, const char* pProgram, const char* pEntry, const char* pCompileFlags, const char* pIdent) const; EServerError GetShaderList(std::vector& rVec) const; bool CommitPLCombinations(std::vector& rVec); // RequestLine causes the remote compiler to compile without expecting a response. bool RequestLine(const string& rList, const string& rString) const; EShaderCompiler GetShaderCompiler() const; const char *GetShaderCompilerName() const; AZStd::string GetShaderCompilerFlags(EHWShaderClass eClass, UPipelineState pipelineState, uint32 MDVMask) const; static CShaderSrv& Instance(); #if defined(AZ_TESTS_ENABLED) // UNIT TEST things can go here. friend class ShaderSrvUnitTestAccessor; bool m_unitTestMode; void EnableUnitTestingMode(bool mode); // used during cry unit test launcher #endif private: EServerError SendRequestViaEngineConnection(std::vector& rCompileData) const; // socket implementation here EServerError SendRequestViaSocket(std::vector& rCompileData) const; bool Send(AZSOCKET Socket, const char* pBuffer, uint32 Size) const; bool Send(AZSOCKET Socket, std::vector& rCompileData) const; EServerError Recv(AZSOCKET Socket, std::vector& rCompileData) const; // internal utilities bool CreateRequest(std::vector& rVec, std::vector >& rNodes) const; bool EncapsulateRequestInEngineConnectionProtocol(std::vector& rCompileData) const; const char* GetPlatformName() const; RemoteProxyState* m_remoteState; // root path added to each request line to store the data per game (eg. MyGame\) string m_RequestLineRootFolder; CShaderSrv(); EServerError Send(std::vector& rCompileData) const; void Tokenize(tdEntryVec& rRet, const string& Tokens, const string& Separator) const; string TransformToXML(const string& rIn) const; string CreateXMLNode(const string& rTag, const string& rValue) const; bool RequestLine(const SCacheCombination& cmb, const string& rLine) const; void Init(); void Terminate(); // given a payload of response data from the actual shader server // decompress and parse it. EServerError ProcessResponse(std::vector& rCompileData) const; }; } #endif // CRYINCLUDE_CRYENGINE_RENDERDLL_COMMON_SHADERS_REMOTECOMPILER_H