bool beUtils::GdtHwGenToNumericValue(GDT_HW_GENERATION hwGen, size_t& gfxIp) { const size_t BE_GFX_IP_6 = 6; const size_t BE_GFX_IP_7 = 7; const size_t BE_GFX_IP_8 = 8; bool ret = true; switch (hwGen) { case GDT_HW_GENERATION_SOUTHERNISLAND: gfxIp = BE_GFX_IP_6; break; case GDT_HW_GENERATION_SEAISLAND: gfxIp = BE_GFX_IP_7; break; case GDT_HW_GENERATION_VOLCANICISLAND: gfxIp = BE_GFX_IP_8; break; case GDT_HW_GENERATION_NONE: case GDT_HW_GENERATION_NVIDIA: case GDT_HW_GENERATION_LAST: default: // We should not get here. GT_ASSERT_EX(false, L"Unsupported HW Generation."); ret = false; break; } return ret; }
bool beUtils::GdtHwGenToString(GDT_HW_GENERATION hwGen, std::string& hwGenAsStr) { const char* BE_GFX_IP_6 = "SI"; const char* BE_GFX_IP_7 = "CI"; const char* BE_GFX_IP_8 = "VI"; bool ret = true; switch (hwGen) { case GDT_HW_GENERATION_SOUTHERNISLAND: hwGenAsStr = BE_GFX_IP_6; break; case GDT_HW_GENERATION_SEAISLAND: hwGenAsStr = BE_GFX_IP_7; break; case GDT_HW_GENERATION_VOLCANICISLAND: hwGenAsStr = BE_GFX_IP_8; break; case GDT_HW_GENERATION_NONE: case GDT_HW_GENERATION_NVIDIA: case GDT_HW_GENERATION_LAST: default: // We should not get here. GT_ASSERT_EX(false, L"Unsupported HW Generation."); ret = false; break; } return ret; }
// --------------------------------------------------------------------------- // Name: osSharedMemorySocket::read // Description: // Reads a block of data from the shared memory socket. // // Arguments: pDataBuffer - A pointer to a buffer that will receive the // read data. // dataSize - The amount of data to be read. // Return Val: bool - Success / failure. // Author: AMD Developer Tools Team // Date: 17/8/2005 // Implementation notes: // The data buffer is cyclic, therefore, we read the data in 2 chunks: // - All data that fits until we reach the end of the buffer. // - All the remaining data (if any) will be read from the buffer begin point. // --------------------------------------------------------------------------- bool osSharedMemorySocket::read(gtByte* pDataBuffer, unsigned long dataSize) { bool retVal = false; // Verify that the socket is open if (isOpen()) { // Wait for data to be available for reading: bool isEnoughDataAvailableForReading = waitForAvailableReadingData(dataSize, _readOperationTimeOut); // If after waiting the time interval, we still don't have data available: if (!isEnoughDataAvailableForReading) { // Trigger an assertion: GT_ASSERT_EX(false, OS_STR_ReadOperationTimeOut); } else { // Lock / wait for my incoming buffer resources: lockBufferResources(_pMyIncomingBuffLocked); // Calculate the first and second chunk sizes (see "implementation notes" above): int firstChunkSize = min(int(dataSize), (_communicationBufferSize - *_pMyReadPos)); int secondChunkSize = dataSize - firstChunkSize; // Read the first data chunk: void* pReadLocation = _pMyIncomingDataBuff + *_pMyReadPos; memcpy(pDataBuffer, pReadLocation, firstChunkSize); // If we need a second chunk: if (secondChunkSize > 0) { // Copy the second data chunk (from the beginning of our incoming buffer): memcpy((pDataBuffer + firstChunkSize), _pMyIncomingDataBuff, secondChunkSize); *_pMyReadPos = secondChunkSize; } else { *_pMyReadPos += dataSize; } // If my next read position passed the end of the buffer: if (_communicationBufferSize <= *_pMyReadPos) { *_pMyReadPos = 0; } // Update the incoming buffer free space: *_pMyIncomingDataBuffFreeSpace += dataSize; // Release my incoming buffer resources: unlockBufferResources(_pMyIncomingBuffLocked); retVal = true; } } return retVal; }
bool GraphicsServerCommunication::RequestData(const gtASCIIString& strRequest, unsigned char*& pReturnData, unsigned long& dataBufferSize) { bool retVal = false; TargetAppState appState = APP_ACTIVE; if (true == m_httpClient.connect()) { do { gtASCIIString httpReply; // Execute the HTTP submission: pReturnData = nullptr; dataBufferSize = 0; bool rc = m_httpClient.RequestPageWithBinaryData(strRequest, pReturnData, dataBufferSize, false, m_serverURL.asCharArray(), true); if (rc) { CheckServerStatus(pReturnData, dataBufferSize, appState); if (APP_ACTIVE == appState) { // The message was successfully handled by the server retVal = true; break; } else if (APP_NOT_RENDERING == appState) { // The message was rejected by the server if (false == m_isStopSignaled) { sleepBetweenResendAttempts(); } } else if (APP_NOT_RUNNING == appState) { // The target application is no longer running break; } } else { // communication failure dataBufferSize = 0; delete[] pReturnData; gtString errorCode; errorCode.fromASCIIString(m_httpClient.getLastErrorCode().asCharArray()); GT_ASSERT_EX(rc, errorCode.asCharArray()); break; } } while (false == m_isStopSignaled); } return retVal; }
// --------------------------------------------------------------------------- // Name: gsTextureUnitMonitor::applyForcedStubTextureObjects // Description: Applies the "Forces stub textures" mode. // Arguments: stub1DTexName, stub2DTexName, stub3DTexName, stubCubeMapTexName, // stubRectangleTexName - The stub texture names (or 0 if they does not exist). // Author: Yaki Tebeka // Date: 18/4/2005 // --------------------------------------------------------------------------- void gsTextureUnitMonitor::applyForcedStubTextureObjects(GLuint stub1DTexName, GLuint stub2DTexName, GLuint stub3DTexName, GLuint stubCubeMapTexName, GLuint stubRectangleTexName) { // Set the active texture unit to be the texture unit that this class monitors: GLuint curActiveTextureUnit = 0; setActiveTexureUnit(_textureUnitName, curActiveTextureUnit); SU_BEFORE_EXECUTING_REAL_FUNCTION(ap_glBindTexture); // Replace currently bind textures (if exists) with the stub textures: if (_bind1DTextureName != 0) { gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_1D, stub1DTexName); } if (_bind2DTextureName != 0) { gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_2D, stub2DTexName); } if ((_bind3DTextureName != 0) && (stub3DTexName != 0)) { gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_3D, stub3DTexName); } if ((_bindCubeMapTextureName != 0) && (stubCubeMapTexName != 0)) { gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_CUBE_MAP, stubCubeMapTexName); } if ((_bindTextureRectangleName != 0) && (stubRectangleTexName != 0)) { gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_RECTANGLE_ARB, stubRectangleTexName); } SU_AFTER_EXECUTING_REAL_FUNCTION(ap_glBindTexture); // Restore the active texture unit: GLuint ignored = 0; setActiveTexureUnit(curActiveTextureUnit, ignored); // Test for OpenGL error: SU_BEFORE_EXECUTING_REAL_FUNCTION(ap_glGetError); GLenum error = gs_stat_realFunctionPointers.glGetError(); SU_AFTER_EXECUTING_REAL_FUNCTION(ap_glGetError); if (error != GL_NO_ERROR) { GT_ASSERT_EX(false, L"Error"); } }
// --------------------------------------------------------------------------- // Name: GraphicsServerCommunication::RequestData // Description: Sends the HTTP request to the server, obtain returned page // Arguments: requestString - The URL request string. // returnedPage - The result page returned from the system. // Return Val: bool - Success / failure // --------------------------------------------------------------------------- bool GraphicsServerCommunication::RequestData(const gtASCIIString& requestString, gtASCIIString& returnedPage, bool isResendAllowed) { bool retVal = false; TargetAppState appState = APP_ACTIVE; if (true == m_httpClient.connect()) { do { gtASCIIString httpReply; bool rc = m_httpClient.requestPage(requestString, returnedPage, false, m_serverURL.asCharArray(), true); if (rc) { CheckServerStatus(returnedPage, appState); if (APP_ACTIVE == appState) { // The message was successfully handled by the server retVal = true; break; } else if (APP_NOT_RENDERING == appState) { // The message was rejected by the server if (false == m_isStopSignaled) { sleepBetweenResendAttempts(); } } else if (APP_NOT_RUNNING == appState) { // The target application is no longer running break; } } else { gtString errorCode; errorCode.fromASCIIString(m_httpClient.getLastErrorCode().asCharArray()); GT_ASSERT_EX(rc, errorCode.asCharArray()); break; } } while (isResendAllowed && false == m_isStopSignaled); } return retVal; }
// --------------------------------------------------------------------------- // Name: gsConnectDriverInternalFunctionPointers // Description: Connects the driver internal functions to the real implementations. // Arguments: hSystemOpenGLModule - A handle to the system's OpenGL module. // Author: Uri Shomroni // Date: 29/6/2016 // --------------------------------------------------------------------------- void gsConnectDriverInternalFunctionPointers(osModuleHandle hSystemOpenGLModule) { static bool callOnce = true; GT_ASSERT_EX(callOnce, L"gsConnectDriverInternalFunctionPointers called multiple times!"); callOnce = false; // These number and array must be updated every time gsDriverInternalFunctionPointers is changed: #define GS_NUMBER_OF_INTERNAL_FUNCTIONS 20 const char* driverInternalFunctionNames[GS_NUMBER_OF_INTERNAL_FUNCTIONS] = { // The order in this array must be exactly like the entry point order in gsDriverInternalFunctionPointers: "loader_get_dispatch_table_size", "_loader_get_proc_offset", "_loader_add_dispatch", "_loader_set_dispatch", "_glapi_noop_enable_warnings", "_glapi_set_warning_func", "_glapi_check_multithread", "_glapi_set_context", "_glapi_get_context", "_glapi_set_dispatch", "_glapi_get_dispatch", "_glapi_begin_dispatch_override", "_glapi_end_dispatch_override", "_glapi_get_override_dispatch", "_glapi_get_dispatch_table_size", "_glapi_check_table", "_glapi_add_dispatch", "_glapi_get_proc_offset", "_glapi_get_proc_address", "_glapi_get_proc_name", }; // Initialize the structure: ::memset(&gs_stat_realDriverInternalFunctionPointers, 0, sizeof(gsDriverInternalFunctionPointers)); for (int i = 0; GS_NUMBER_OF_INTERNAL_FUNCTIONS > i; ++i) { // Get the functions pointer: osProcedureAddress pRealFunction = nullptr; bool rcPtr = osGetProcedureAddress(hSystemOpenGLModule, driverInternalFunctionNames[i], pRealFunction, false); if (rcPtr && (nullptr != pRealFunction)) { // Place it in the structure: ((osProcedureAddress*)(&gs_stat_realDriverInternalFunctionPointers))[i] = pRealFunction; } } }
// --------------------------------------------------------------------------- // Name: GraphicsServerCommunication::ConnectProcess // Description: Connect to Graphics server's specific process // Arguments: strPid - Process ID to connect to and update current PID, (optional) can be "", function will then connect to known process // Return Val: bool - Success / failure // --------------------------------------------------------------------------- bool GraphicsServerCommunication::ConnectProcess(const gtASCIIString strPid, const gtASCIIString& apiType) { gtASCIIString strWebResponse; bool retVal = false; if ((0 < strPid.length()) && (true == strPid.isIntegerNumber())) { m_strPid = strPid; } if (apiType.isEmpty() == false) { if (apiType == GP_GRAPHICS_SERVER_DX12_API_TYPE || apiType == GP_GRAPHICS_SERVER_VULKAN_API_TYPE) { m_strApiHttpCommand = "/"; m_strApiHttpCommand.append(apiType); } else { gtString msg = L"Wrong API given : "; msg.append(gtString().fromASCIIString(apiType.asCharArray())); GT_ASSERT_EX(false, msg.asCharArray()); m_strApiHttpCommand = ""; } } if (m_strPid.isEmpty() == false && m_strApiHttpCommand.isEmpty() == false) { // Connect gtASCIIString showStack = m_strApiHttpCommand; retVal = SendCommandPid(showStack.append("/ShowStack"), strWebResponse, ""); if (retVal) { gtASCIIString timeControl = m_strApiHttpCommand; retVal = SendCommandPid(timeControl.append("/PushLayer=TimeControl") , strWebResponse, ""); } if (retVal) { gtASCIIString tcSettings = m_strApiHttpCommand; retVal = SendCommandPid(tcSettings.append("/TC/Settings.xml"), strWebResponse, ""); } } return retVal; }
// --------------------------------------------------------------------------- // Name: osTCPSocketServer::bind // // Description: Associates a local port with this socket. // I.E: Any socket client connection to this port address will be mapped // to this socket server. // // Arguments: portAddress - The address of the port to which the socket will be bound. // // Return Val: bool - Success / failure. // Author: AMD Developer Tools Team // Date: 3/1/2004 // --------------------------------------------------------------------------- bool osTCPSocketServer::bind(const osPortAddress& portAddress) { bool retVal = false; // Verify that the socket is open: if (isOpen()) { // Translate portAddress into a win32 local port address: SOCKADDR_IN win32PortAddress; bool rc = portAddress.asSockaddr(win32PortAddress, _blockOnDNS); if (rc) { // Bind this socket to the input local port address: osSocketDescriptor socketDescriptor = OSSocketDescriptor(); int rc1 = ::bind(socketDescriptor, (LPSOCKADDR)&win32PortAddress, sizeof(SOCKADDR_IN)); if (rc1 != SOCKET_ERROR) { retVal = true; _boundAddress = portAddress; } else { // An error occurred: gtString errMsg = OS_STR_bindError; errMsg += OS_STR_osReportedErrorIs; errMsg += OS_STR_host; errMsg += portAddress.hostName(); errMsg += OS_STR_port; unsigned short portNum = portAddress.portNumber(); errMsg.appendFormattedString(L"%u ", portNum); gtString systemError; osGetLastSystemErrorAsString(systemError); errMsg += systemError; GT_ASSERT_EX(false, errMsg.asCharArray()); } } } return retVal; }
// --------------------------------------------------------------------------- // Name: gsVertexArrayDrawer::migrateArrayDataToFloatData // Description: Migrates data array to GLfloat data array. // Arguments: dataToBeMigrated - The array of data to be migrated. // is0To255Data - true iff the input data is [0, 255] data. This kind of data // will be translated to float data of [0,1]. // first - The index of the first item to be migrated. // count - The amount of items to be migrated. // migratedData - Will get the migrated data. // Return Val: bool - Success / failure. // Author: Yaki Tebeka // Date: 19/6/2006 // --------------------------------------------------------------------------- bool gsVertexArrayDrawer::migrateArrayDataToFloatData(const gsArrayPointer& dataToBeMigrated, bool is0To255Data, GLint first, GLsizei count, gtVector<GLfloat>& migratedData) { bool retVal = false; // Work according to the data array type: switch (dataToBeMigrated._dataType) { case GL_BYTE: retVal = gsMigrateArrayToFloatData<GLbyte>(dataToBeMigrated, is0To255Data, first, count, migratedData); break; case GL_UNSIGNED_BYTE: retVal = gsMigrateArrayToFloatData<GLubyte>(dataToBeMigrated, is0To255Data, first, count, migratedData); break; case GL_SHORT: retVal = gsMigrateArrayToFloatData<GLshort>(dataToBeMigrated, is0To255Data, first, count, migratedData); break; case GL_FIXED: retVal = gsMigrateArrayToFloatData<apGLFixedWrapper>(dataToBeMigrated, is0To255Data, first, count, migratedData); break; case GL_FLOAT: retVal = gsMigrateArrayToFloatData<GLfloat>(dataToBeMigrated, is0To255Data, first, count, migratedData); break; default: // Unsupported data array type: GT_ASSERT_EX(false, L"Unsupported data array type"); break; } return retVal; }
// --------------------------------------------------------------------------- // Name: gsVertexArrayDrawer::migrateIndexedDataToNoneIndexedFloatData // Description: Converts indexed array data to GLfloat none indexed data. // // Arguments: dataToBeMigrated - The array of data to be migrated. // is0To255Data - true iff the input data is [0, 255] data. This kind of data // will be translated to float data of [0,1]. // count - count - Number of elements to be converted. // type - Type of the values in indices. (GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT). // indices - Pointer to the indices array. // migratedData - Will get the migrated data. // // Return Val: bool - Success / failure. // Author: Yaki Tebeka // Date: 1/3/2006 // --------------------------------------------------------------------------- bool gsVertexArrayDrawer::migrateIndexedDataToNoneIndexedFloatData(const gsArrayPointer& dataToBeMigrated, bool is0To255Data, GLsizei count, GLenum type, const GLvoid* indices, gtVector<GLfloat>& migratedData) { bool retVal = false; // Work according to the index array type: // (OpenGL ES 1.1 supports only GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT indices) if (type == GL_UNSIGNED_BYTE) { // Work according to the data array type: switch (dataToBeMigrated._dataType) { case GL_BYTE: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLubyte, GLbyte>(dataToBeMigrated, is0To255Data, count, (const GLubyte*)indices, migratedData); break; case GL_UNSIGNED_BYTE: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLubyte, GLubyte>(dataToBeMigrated, is0To255Data, count, (const GLubyte*)indices, migratedData); break; case GL_SHORT: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLubyte, GLshort>(dataToBeMigrated, is0To255Data, count, (const GLubyte*)indices, migratedData); break; case GL_FIXED: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLubyte, apGLFixedWrapper>(dataToBeMigrated, is0To255Data, count, (const GLubyte*)indices, migratedData); break; case GL_FLOAT: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLubyte, GLfloat>(dataToBeMigrated, is0To255Data, count, (const GLubyte*)indices, migratedData); break; default: // Unsupported data array type: GT_ASSERT_EX(false, L"Unsupported data array type"); break; } } else if (type == GL_UNSIGNED_SHORT) { // Work according to the data array type: switch (dataToBeMigrated._dataType) { case GL_BYTE: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLushort, GLbyte>(dataToBeMigrated, is0To255Data, count, (const GLushort*)indices, migratedData); break; case GL_UNSIGNED_BYTE: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLushort, GLubyte>(dataToBeMigrated, is0To255Data, count, (const GLushort*)indices, migratedData); break; case GL_SHORT: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLushort, GLshort>(dataToBeMigrated, is0To255Data, count, (const GLushort*)indices, migratedData); break; case GL_FIXED: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLushort, apGLFixedWrapper>(dataToBeMigrated, is0To255Data, count, (const GLushort*)indices, migratedData); break; case GL_FLOAT: retVal = gsMigrateIndexedDataToNoneIndexedFloatData<GLushort, GLfloat>(dataToBeMigrated, is0To255Data, count, (const GLushort*)indices, migratedData); break; default: // Unsupported data array type: GT_ASSERT_EX(false, L"Unsupported data array type"); break; } } else { // Unsupported index array type: GT_ASSERT_EX(false, L"Unsupported index array type"); } return retVal; }
bool OpenCLTraceOptions::setProjectSettingsXML(const gtString& projectAsXMLString) { QString qtStr = acGTStringToQString(projectAsXMLString); QDomDocument doc; doc.setContent(qtStr.toUtf8()); QDomElement rootElement = doc.documentElement(); QDomNode rootNode = rootElement.firstChild(); QDomNode childNode = rootNode.firstChild(); QString nodeVal; bool val; while (!childNode.isNull()) { val = false; nodeVal = childNode.firstChild().nodeValue(); if (nodeVal == "T") { val = true; } if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsGenerateOccupancy)) { m_currentSettings.m_generateKernelOccupancy = val; } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsShowErrorCode)) { m_currentSettings.m_alwaysShowAPIErrorCode = val; } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsCollapseClGetEventInfo)) { m_currentSettings.m_collapseClGetEventInfo = val; } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsEnableNavigation)) { m_currentSettings.m_generateSymInfo = val; } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsGenerateSummaryPage)) { m_currentSettings.m_generateSummaryPage = val; } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsAPIsToFilter)) { m_currentSettings.m_filterAPIsToTrace = val; } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsMaxAPIs)) { m_currentSettings.m_maxAPICalls = nodeVal.toInt(); } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsWriteDataTimeOut)) { m_currentSettings.m_writeDataTimeOut = val; } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsTimeOutInterval)) { m_currentSettings.m_timeoutInterval = nodeVal.toInt(); } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsAPIType)) { if (nodeVal == acGTStringToQString(GPU_STR_ProjectSettingsAPITypeOpenCL)) { m_currentSettings.m_apiToTrace = APIToTrace_OPENCL; } else if (nodeVal == acGTStringToQString(GPU_STR_ProjectSettingsAPITypeHSA)) { m_currentSettings.m_apiToTrace = APIToTrace_HSA; } else { m_currentSettings.m_apiToTrace = APIToTrace_OPENCL; GT_ASSERT_EX(false, L"Invalid project settings option"); } } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsRulesTree)) { if (childNode.hasChildNodes()) { UpdateTreeWidgetFromXML(childNode, m_pAPIRulesTW, false); } else { if (m_pAPIRulesTW != nullptr) { Util::SetCheckState(m_pAPIRulesTW, true); } } UpdateRuleList(); } else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsAPIsFilterTree)) { if (childNode.hasChildNodes()) { UpdateTreeWidgetFromXML(childNode, m_pAPIsToTraceTW, true); } else { if (m_pAPIsToTraceTW != nullptr) { Util::SetCheckState(m_pAPIsToTraceTW, true); } } UpdateAPIFilterList(); } childNode = childNode.nextSibling(); } return true; }
/// List the asics as got from device void kcCLICommanderDX::ListAsics(Config& config, LoggingCallBackFuncP callback) { if (!Init(config, callback)) return; std::stringstream s_Log; if (! config.m_bVerbose) { s_Log << "Devices:" << endl; string calName; for (vector<GDT_GfxCardInfo>::const_iterator it = m_dxDefaultAsicsList.begin(); it != m_dxDefaultAsicsList.end(); ++it) { calName = string(it->m_szCALName); s_Log << " " << calName << endl; } } else { // Some headings: s_Log << "Devices:" << endl; s_Log << "-------------------------------------" << endl; s_Log << "Hardware Generation:" << endl; s_Log << " ASIC name" << endl; s_Log << " DeviceID Marketing Name" << endl; s_Log << "-------------------------------------" << endl; std::vector<GDT_GfxCardInfo> dxDeviceTable; beStatus bRet = be->theOpenDXBuilder()->GetDeviceTable(dxDeviceTable); if (bRet == beStatus_SUCCESS) { GDT_HW_GENERATION gen = GDT_HW_GENERATION_NONE; std::string calName; for (const GDT_GfxCardInfo& gfxDevice : dxDeviceTable) { if (gen != gfxDevice.m_generation) { gen = gfxDevice.m_generation; std::string sHwGenDisplayName; AMDTDeviceInfoUtils::Instance()->GetHardwareGenerationDisplayName(gen, sHwGenDisplayName); switch (gfxDevice.m_generation) { case GDT_HW_GENERATION_SOUTHERNISLAND: s_Log << sHwGenDisplayName << KA_STR_familyNameSICards ":" << endl; break; case GDT_HW_GENERATION_SEAISLAND: s_Log << sHwGenDisplayName << KA_STR_familyNameCICards ":" << endl; break; case GDT_HW_GENERATION_VOLCANICISLAND: s_Log << sHwGenDisplayName << KA_STR_familyNameVICards ":" << endl; break; default: GT_ASSERT_EX(false, L"Unknown hardware generation."); break; } } if (calName.compare(gfxDevice.m_szCALName) != 0) { calName = std::string(gfxDevice.m_szCALName); s_Log << " " << calName << endl; } std::stringstream ss; ss << hex << gfxDevice.m_deviceID; s_Log << " " << ss.str() << " " << string(gfxDevice.m_szMarketingName) << endl; } } else { s_Log << "Could not generate device table."; } } LogCallBack(s_Log.str()); }
STDMETHODIMP D3DIncludeManager::Open(THIS_ D3D_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes) { GT_UNREFERENCED_PARAMETER(pParentData); bool isDone = false; if (pFileName != nullptr) { std::string includeFileFullPath; switch (IncludeType) { case D3D_INCLUDE_LOCAL: { // First, try the shader's directory. includeFileFullPath = m_shaderDir; // Is it a relative path to the shader's directory. bool isRelative = IsBeginsWith(pFileName, "\\"); if (!isRelative) { AdjustIncludePath(includeFileFullPath); } includeFileFullPath += pFileName; isDone = OpenIncludeFile(includeFileFullPath, (char*&) * ppData, *pBytes); if (!isDone) { // Search in the user-defined directories. for (const std::string& includeDir : m_includeSearchDirs) { includeFileFullPath = includeDir; if (!isRelative) { AdjustIncludePath(includeFileFullPath); } includeFileFullPath += pFileName; isDone = OpenIncludeFile(includeFileFullPath, (char*&) * ppData, *pBytes); if (isDone) { break; } } } break; } case D3D_INCLUDE_SYSTEM: { // First, try the shader's directory. includeFileFullPath = m_shaderDir; AdjustIncludePath(includeFileFullPath); includeFileFullPath += pFileName; isDone = OpenIncludeFile(includeFileFullPath, (char*&) * ppData, *pBytes); if (!isDone) { // Go through the directories which the user specified. for (const std::string& includeDir : m_includeSearchDirs) { includeFileFullPath = includeDir; AdjustIncludePath(includeFileFullPath); includeFileFullPath += pFileName; isDone = OpenIncludeFile(includeFileFullPath, (char*&) * ppData, *pBytes); if (isDone) { break; } } } break; } default: GT_ASSERT_EX(false, L"Unknown D3D include type."); break; } } // Must return S_OK according to the documentation. return (isDone ? S_OK : E_FAIL); }
// --------------------------------------------------------------------------- // Name: gsConnectOpenGLWrappers // Description: Connects the wrapper functions to the real OpenGL functions // implementations. // Arguments: hSystemOpenGLModule - A handle to the system's OpenGL module. // Return Val: bool - Success / failure. // Author: Yaki Tebeka // Date: 5/7/2003 // --------------------------------------------------------------------------- bool gsConnectOpenGLWrappers(osModuleHandle hSystemOpenGLModule) { bool retVal = true; // Output debug log printout: OS_OUTPUT_DEBUG_LOG(GS_STR_DebugLog_wrappingSystemOGLFunctions, OS_DEBUG_LOG_DEBUG); // Get the "base" OGL functions types mask: unsigned int baseOGLFunctionsTypes = gsGetBaseOpenGLFunctionTypes(); // Get the Monitored functions manager instance: apMonitoredFunctionsManager& theMonitoredFunctionsManager = apMonitoredFunctionsManager::instance(); // For each monitored function: int amountOfMonitoredFuncs = theMonitoredFunctionsManager.amountOfMonitoredFunctions(); for (int i = 0; i < amountOfMonitoredFuncs; i++) { // Get the function type: unsigned int functionAPIType = theMonitoredFunctionsManager.monitoredFunctionAPIType((apMonitoredFunctionId)i); // If this is a "base" OGL function: if (functionAPIType & baseOGLFunctionsTypes) { bool functionOkay = true; // Get a the function name: gtString currFunctionName = theMonitoredFunctionsManager.monitoredFunctionName((apMonitoredFunctionId)i); // Get a pointer to the function implementation in the system's OGL module: osProcedureAddress pRealFunctionImplementation = NULL; bool rc = osGetProcedureAddress(hSystemOpenGLModule, currFunctionName.asASCIICharArray(), pRealFunctionImplementation, false); if (!rc) { bool shouldReportError = true; #if ((AMDT_BUILD_TARGET == AMDT_LINUX_OS) && (AMDT_LINUX_VARIANT == AMDT_GENERIC_LINUX_VARIANT)) { // On Linux, not all functions are supported by all variants, so it's alright if some // are missing. } #elif ((AMDT_BUILD_TARGET == AMDT_LINUX_OS) && (AMDT_LINUX_VARIANT == AMDT_MAC_OS_X_LINUX_VARIANT)) { // On Mac, we only consider failure if a non-extension function is not found: #ifndef _GR_IPHONE_BUILD functionOkay = ((functionAPIType & AP_OPENGL_EXTENSION_FUNC) != 0); #else // The iPhone OS 3.0 OpenGLES library exports both OpenGL ES 1.1 and OpenGL ES 2.0 functions, but the older ones // only export the 1.1 ones. So, to support both cases, we do not fail here if an OpenGL ES 2.0-only function is missing. functionOkay = ((functionAPIType & (AP_OPENGL_ES_MAC_EXTENSION_FUNC | AP_OPENGL_ES_2_MAC_GENERIC_FUNC)) != 0); #endif if (functionOkay) { shouldReportError = false; } } #else { // On Windows, failure to get a function pointers is considered a failure: functionOkay = false; } #endif if (shouldReportError) { // Output an error message: gtString errorMessage = GS_STR_DebugLog_cannotGetOGLFuncPtr; errorMessage += currFunctionName; GT_ASSERT_EX(false, errorMessage.asCharArray()); } } // Connects gs_stat_realFunctionPointers[i] to point the real functions implementation: ((osProcedureAddress*)(&gs_stat_realFunctionPointers))[i] = pRealFunctionImplementation; retVal = retVal && functionOkay; } } // Output debug log printout: OS_OUTPUT_DEBUG_LOG(GS_STR_DebugLog_wrappingSystemOGLFunctionsEnded, OS_DEBUG_LOG_DEBUG); return retVal; }
// --------------------------------------------------------------------------- // Name: gsLoadSystemsOpenGLModule // Description: Loads the system's OpenGL module into the calling process address space. // Return Val: osModuleHandle - Will get a handle to the systems OpenGL module. // Author: Yaki Tebeka // Date: 5/7/2003 // --------------------------------------------------------------------------- osModuleHandle gsLoadSystemsOpenGLModule() { osModuleHandle retVal = OS_NO_MODULE_HANDLE; // Will get the system's OpenGL module path: gtVector<osFilePath> systemOGLModulePath; osGetSystemOpenGLModulePath(systemOGLModulePath); gtString moduleLoadError = L"System OpenGL module not found."; bool rc = false; int numberOfGLPaths = (int)systemOGLModulePath.size(); GT_ASSERT(numberOfGLPaths > 0); for (int i = 0; (i < numberOfGLPaths) && (!rc); i++) { // Output debug log printout: const osFilePath& currentModulePath = systemOGLModulePath[i]; const gtString& currentModulePathStr = currentModulePath.asString(); gtString dbgLogMsg = GS_STR_DebugLog_loadingSystemOGLServer; dbgLogMsg.append(currentModulePathStr); OS_OUTPUT_DEBUG_LOG(dbgLogMsg.asCharArray(), OS_DEBUG_LOG_DEBUG); // Load the system OpenGL module: if (currentModulePath.exists()) { // Some of the paths may fail: gtString currentModuleError; rc = osLoadModule(currentModulePath, retVal, ¤tModuleError, false); if (!rc) { // Log the error for each attempted path: moduleLoadError.append('\n').append(currentModulePathStr).append(L":\n ").append(currentModuleError); } else { // Output debug log printout of the module that was successfully loaded: dbgLogMsg = GS_STR_DebugLog_systemOGLServerLoadedOk; dbgLogMsg.append(currentModulePathStr); OS_OUTPUT_DEBUG_LOG(dbgLogMsg.asCharArray(), OS_DEBUG_LOG_INFO); } } } // If we failed to load the system OpenGL module: if (!rc) { // Trigger an assertion failure: GT_ASSERT_EX(false, GS_STR_DebugLog_systemOGLServerLoadFailed); GT_ASSERT_EX(false, moduleLoadError.asCharArray()); suTechnologyMonitorsManager::reportFailedSystemModuleLoad(moduleLoadError); } else { // Log the system's OpenGL module handle: gsSetSystemsOpenGLModuleHandle(retVal); } return retVal; }
// --------------------------------------------------------------------------- // Name: gsTextureUnitMonitor::cancelForcedStubTextureObjects // Description: Cancels the "Forces stub textures" mode. // Author: Yaki Tebeka // Date: 18/4/2005 // --------------------------------------------------------------------------- void gsTextureUnitMonitor::cancelForcedStubTextureObjects() { // Set the active texture unit to be the texture unit that this class monitors: GLuint curActiveTextureUnit = 0; setActiveTexureUnit(_textureUnitName, curActiveTextureUnit); // Calculate the names of the "original" program textures: // ------------------------------------------------------ GLuint resumedTex1D = _bind1DTextureName; GLuint resumedTex2D = _bind2DTextureName; GLuint resumedTex3D = _bind3DTextureName; GLuint resumedTexCubeMap = _bindCubeMapTextureName; GLuint resumedTexRectangle = _bindTextureRectangleName; GLuint resumedTexBuffer = _bindTextureBufferName; if (_bind1DTextureName != 0) { // If the "original" bind texture is a default textures: if (apIsDefaultTextureName(resumedTex1D)) { resumedTex1D = 0; } } if (_bind2DTextureName != 0) { // If the "original" bind texture is a default textures: if (apIsDefaultTextureName(resumedTex2D)) { resumedTex2D = 0; } } if (_bind3DTextureName != 0) { // If the "original" bind texture is a default textures: if (apIsDefaultTextureName(resumedTex3D)) { resumedTex3D = 0; } } if (_bindCubeMapTextureName != 0) { // If the "original" bind texture is a default textures: if (apIsDefaultTextureName(resumedTexCubeMap)) { resumedTexCubeMap = 0; } } if (_bindTextureRectangleName != 0) { // If the "original" bind texture is a default textures: if (apIsDefaultTextureName(resumedTexRectangle)) { resumedTexRectangle = 0; } } if (_bindTextureBufferName != 0) { // If the "original" bind texture is a default textures: if (apIsDefaultTextureName(resumedTexBuffer)) { resumedTexBuffer = 0; } } // Resume the "original" bind textures: SU_BEFORE_EXECUTING_REAL_FUNCTION(ap_glBindTexture); #if ((defined OS_OGL_ES_IMPLEMENTATION_DLL_BUILD) || (defined _GR_IPHONE_BUILD)) gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_2D, resumedTex2D); #else gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_1D, resumedTex1D); gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_2D, resumedTex2D); gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_3D, resumedTex3D); gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_CUBE_MAP, resumedTexCubeMap); gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_RECTANGLE_ARB, resumedTexRectangle); gs_stat_realFunctionPointers.glBindTexture(GL_TEXTURE_BUFFER, resumedTexBuffer); #endif SU_AFTER_EXECUTING_REAL_FUNCTION(ap_glBindTexture); // Test for OpenGL error: SU_BEFORE_EXECUTING_REAL_FUNCTION(ap_glGetError); GLenum error = gs_stat_realFunctionPointers.glGetError(); SU_AFTER_EXECUTING_REAL_FUNCTION(ap_glGetError); if (error != GL_NO_ERROR) { GT_ASSERT_EX(false, L"Error"); } // Restore the active texture unit: GLuint ignored = 0; setActiveTexureUnit(curActiveTextureUnit, ignored); }