clean up etc

This commit is contained in:
Samuel Gateau 2019-07-05 13:23:19 +02:00
parent 4cc3800384
commit 0c26d3ef66
4 changed files with 87 additions and 75 deletions

View file

@ -44,15 +44,13 @@ namespace platform { namespace keys{
extern const char* boundsTop; extern const char* boundsTop;
extern const char* boundsBottom; extern const char* boundsBottom;
extern const char* gpu; extern const char* gpu;
extern const char* ppiHorizontal;
extern const char* ppiVertical;
extern const char* ppi; extern const char* ppi;
extern const char* ppiDesktop;
extern const char* physicalWidth; extern const char* physicalWidth;
extern const char* physicalHeight; extern const char* physicalHeight;
extern const char* modeRefreshrate; extern const char* modeRefreshrate;
extern const char* modeWidth; extern const char* modeWidth;
extern const char* modeHeight; extern const char* modeHeight;
extern const char* desktopPpi;
extern const char* isMaster; extern const char* isMaster;
} }
namespace memory { namespace memory {

View file

@ -100,8 +100,6 @@ void MACOSInstance::enumerateGpusAndDisplays() {
display[keys::display::boundsBottom] = displayBounds.origin.y + displayBounds.size.height; display[keys::display::boundsBottom] = displayBounds.origin.y + displayBounds.size.height;
// PPI & resolution // PPI & resolution
display[keys::display::ppiHorizontal] = ppiH;
display[keys::display::ppiVertical] = ppiV;
display[keys::display::physicalWidth] = displaySizeWidthInches; display[keys::display::physicalWidth] = displaySizeWidthInches;
display[keys::display::physicalHeight] = displaySizeHeightInches; display[keys::display::physicalHeight] = displaySizeHeightInches;
display[keys::display::modeWidth] = displayModeWidth; display[keys::display::modeWidth] = displayModeWidth;
@ -109,7 +107,7 @@ void MACOSInstance::enumerateGpusAndDisplays() {
//Average the ppiH and V for the simple ppi //Average the ppiH and V for the simple ppi
display[keys::display::ppi] = std::round(0.5f * (ppiH + ppiV)); display[keys::display::ppi] = std::round(0.5f * (ppiH + ppiV));
display[keys::display::desktopPpi] = std::round(0.5f * (ppiHScaled + ppiVScaled)); display[keys::display::ppiDesktop] = std::round(0.5f * (ppiHScaled + ppiVScaled));
// refreshrate // refreshrate
display[keys::display::modeRefreshrate] = displayRefreshrate; display[keys::display::modeRefreshrate] = displayRefreshrate;

View file

@ -45,15 +45,13 @@ namespace platform { namespace keys {
const char* boundsTop = "boundsTop"; const char* boundsTop = "boundsTop";
const char* boundsBottom = "boundsBottom"; const char* boundsBottom = "boundsBottom";
const char* gpu = "gpu"; const char* gpu = "gpu";
const char* ppiHorizontal = "ppiHorizontal";
const char* ppiVertical = "ppiHorizontal";
const char* ppi = "ppi"; const char* ppi = "ppi";
const char* ppiDesktop = "ppiDesktop";
const char* physicalWidth = "physicalWidth"; const char* physicalWidth = "physicalWidth";
const char* physicalHeight = "physicalHeight"; const char* physicalHeight = "physicalHeight";
const char* modeRefreshrate = "modeRefreshrate"; const char* modeRefreshrate = "modeRefreshrate";
const char* modeWidth = "modeWidth"; const char* modeWidth = "modeWidth";
const char* modeHeight = "modeHeight"; const char* modeHeight = "modeHeight";
const char* desktopPpi = "desktopPpi";
const char* isMaster = "isMaster"; const char* isMaster = "isMaster";
} }
namespace memory { namespace memory {

View file

@ -82,6 +82,9 @@ void WINInstance::enumerateGpusAndDisplays() {
DXGI_ADAPTER_DESC1 adapterDesc; DXGI_ADAPTER_DESC1 adapterDesc;
pAdapter->GetDesc1(&adapterDesc); pAdapter->GetDesc1(&adapterDesc);
// Only describe gpu if it is a hardware adapter
if (!(adapterDesc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)) {
LARGE_INTEGER version; LARGE_INTEGER version;
hr = pAdapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &version); hr = pAdapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &version);
@ -104,6 +107,13 @@ void WINInstance::enumerateGpusAndDisplays() {
// FOund an output attached to the adapter, get descriptor // FOund an output attached to the adapter, get descriptor
DXGI_OUTPUT_DESC outputDesc; DXGI_OUTPUT_DESC outputDesc;
pOutput->GetDesc(&outputDesc); pOutput->GetDesc(&outputDesc);
pOutput->Release();
outputNum++;
// Grab the monitor info
MONITORINFO monitorInfo;
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(outputDesc.Monitor, &monitorInfo);
// Grab the dpi info for the monitor // Grab the dpi info for the monitor
UINT dpiX{ 0 }; UINT dpiX{ 0 };
@ -134,8 +144,6 @@ void WINInstance::enumerateGpusAndDisplays() {
display[keys::display::boundsTop] = outputDesc.DesktopCoordinates.top; display[keys::display::boundsTop] = outputDesc.DesktopCoordinates.top;
// PPI & resolution // PPI & resolution
display[keys::display::ppiHorizontal] = dpiX;
display[keys::display::ppiVertical] = dpiY;
display[keys::display::physicalWidth] = devMode.dmPelsWidth / (float) dpiX; display[keys::display::physicalWidth] = devMode.dmPelsWidth / (float) dpiX;
display[keys::display::physicalHeight] = devMode.dmPelsHeight / (float) dpiY; display[keys::display::physicalHeight] = devMode.dmPelsHeight / (float) dpiY;
display[keys::display::modeWidth] = devMode.dmPelsWidth; display[keys::display::modeWidth] = devMode.dmPelsWidth;
@ -143,28 +151,38 @@ void WINInstance::enumerateGpusAndDisplays() {
//Average the ppiH and V for the simple ppi //Average the ppiH and V for the simple ppi
display[keys::display::ppi] = std::round(0.5f * (dpiX + dpiY)); display[keys::display::ppi] = std::round(0.5f * (dpiX + dpiY));
display[keys::display::desktopPpi] = std::round(0.5f * (dpiXScaled + dpiYScaled)); display[keys::display::ppiDesktop] = std::round(0.5f * (dpiXScaled + dpiYScaled));
// refreshrate // refreshrate
display[keys::display::modeRefreshrate] = devMode.dmDisplayFrequency;; display[keys::display::modeRefreshrate] = devMode.dmDisplayFrequency;;
// Master display ? // Master display ?
display[keys::display::isMaster] = true; display[keys::display::isMaster] = (bool) (monitorInfo.dwFlags & MONITORINFOF_PRIMARY);
// Add the display index to the list of displays of the gpu // Add the display index to the list of displays of the gpu
displayIndices.push_back(_displays.size()); displayIndices.push_back((int) _displays.size());
// And set the gpu index to the display description // And set the gpu index to the display description
display[keys::display::gpu] = _gpus.size(); display[keys::display::gpu] = (int) _gpus.size();
// WIN specific
display["win_workLeft"] = monitorInfo.rcWork.left;
display["win_workRight"] = monitorInfo.rcWork.right;
display["win_workTop"] = monitorInfo.rcWork.top;
display["win_workBottom"] = monitorInfo.rcWork.bottom;
display["win_monLeft"] = monitorInfo.rcMonitor.left;
display["win_monRight"] = monitorInfo.rcMonitor.right;
display["win_monTop"] = monitorInfo.rcMonitor.top;
display["win_monBottom"] = monitorInfo.rcMonitor.bottom;
// One more display desc // One more display desc
_displays.push_back(display); _displays.push_back(display);
pOutput->Release();
outputNum++;
} }
gpu[keys::gpu::displays] = displayIndices; gpu[keys::gpu::displays] = displayIndices;
_gpus.push_back(gpu); _gpus.push_back(gpu);
}
pAdapter->Release(); pAdapter->Release();
adapterNum++; adapterNum++;
} }