Skip to content

Commit

Permalink
[build] Initial build options support
Browse files Browse the repository at this point in the history
 * -Denv=false required for native WINE build
  • Loading branch information
pchome committed Feb 16, 2018
1 parent e7102cc commit e5027ce
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Inside the dxvk directory, run:
```
meson -Dwine-build=true --cross-file build-win64-wine.txt build.x86_64
cd build.x86_64
meson configure -Dprefix=/your/dxvk/directory/ -Dbuildtype=release
meson configure -Denv=false -Dutils=false -Dprefix=/your/dxvk/directory/ -Dbuildtype=release
ninja
ninja install
```
Expand Down
33 changes: 27 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,32 @@ lib_d3d11 = dxvk_compiler.find_library('d3d11')
lib_dxgi = dxvk_compiler.find_library('dxgi')
lib_d3dcompiler_47 = dxvk_compiler.find_library('d3dcompiler_47')

glsl_compiler = find_program('glslangValidator')
glsl_generator = generator(glsl_compiler,
output : [ '@BASENAME@.h' ],
arguments : [ '-V', '--vn', '@BASENAME@', '@INPUT@', '-o', '@OUTPUT@' ])
if (get_option('hud'))
add_global_arguments('-DWANT_HUD', language : ['c', 'cpp'])

glsl_compiler = find_program('glslangValidator')
glsl_generator = generator(glsl_compiler,
output : [ '@BASENAME@.h' ],
arguments : [ '-V', '--vn', '@BASENAME@', '@INPUT@', '-o', '@OUTPUT@' ])
endif



if (get_option('env'))
add_global_arguments('-DWANT_ENV', language : ['c', 'cpp'])
endif

if (get_option('logger'))
add_global_arguments('-DWANT_LOGGER', language : ['c', 'cpp'])
endif


subdir('src')
subdir('tests')
subdir('wine_utils')

if (get_option('tests'))
subdir('tests')
endif

if (get_option('utils'))
subdir('wine_utils')
endif
7 changes: 5 additions & 2 deletions src/d3d11/d3d11_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2356,9 +2356,12 @@ namespace dxvk {
{ "9_2", D3D_FEATURE_LEVEL_9_2 },
{ "9_1", D3D_FEATURE_LEVEL_9_1 },
}};


#ifdef WANT_ENV
const std::string maxLevel = env::getEnvVar(L"DXVK_FEATURE_LEVEL");

#else
const std::string maxLevel = "";
#endif
auto entry = std::find_if(s_featureLevels.begin(), s_featureLevels.end(),
[&] (const std::pair<std::string, D3D_FEATURE_LEVEL>& pair) {
return pair.first == maxLevel;
Expand Down
6 changes: 5 additions & 1 deletion src/d3d11/d3d11_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ namespace dxvk {

// If requested by the user, dump both the raw DXBC
// shader and the compiled SPIR-V module to a file.
#ifdef WANT_ENV
const std::string dumpPath = env::getEnvVar(L"DXVK_SHADER_DUMP_PATH");
const std::string readPath = env::getEnvVar(L"DXVK_SHADER_READ_PATH");

#else
const std::string dumpPath = "dxvk_shader_dump";
const std::string readPath = "dxvk_shader_read";
#endif
if (dumpPath.size() != 0) {
reader.store(std::ofstream(str::format(dumpPath, "/", m_name, ".dxbc"),
std::ios_base::binary | std::ios_base::trunc));
Expand Down
4 changes: 2 additions & 2 deletions src/d3d11/d3d11_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <dxvk_device.h>

#include "../util/sha1/sha1_util.h"

#ifdef WANT_ENV
#include "../util/util_env.h"

#endif
#include "d3d11_device_child.h"
#include "d3d11_interfaces.h"

Expand Down
4 changes: 4 additions & 0 deletions src/dxvk/dxvk_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ namespace dxvk {
m_pipelineManager (new DxvkPipelineManager(this)),
m_unboundResources(this),
m_submissionQueue (this) {
#ifdef WANT_ENV
m_options.adjustAppOptions(env::getExeName());
#else
m_options.adjustAppOptions("");
#endif
m_options.adjustDeviceOptions(m_adapter);
m_options.logOptions();

Expand Down
3 changes: 2 additions & 1 deletion src/dxvk/dxvk_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

#include "../util/log/log.h"
#include "../util/log/log_debug.h"

#ifdef WANT_ENV
#include "../util/util_env.h"
#endif
#include "../util/util_error.h"
#include "../util/util_flags.h"
#include "../util/util_math.h"
Expand Down
4 changes: 2 additions & 2 deletions src/dxvk/dxvk_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ namespace dxvk {

vk::NameList DxvkInstance::getLayers() {
std::vector<const char*> layers = { };
#ifdef WANT_ENV
if (env::getEnvVar(L"DXVK_DEBUG_LAYERS") == "1")
layers.push_back("VK_LAYER_LUNARG_standard_validation");

#endif
const vk::NameSet layersAvailable
= vk::NameSet::enumerateInstanceLayers(*m_vkl);

Expand Down
5 changes: 4 additions & 1 deletion src/dxvk/hud/dxvk_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ namespace dxvk::hud {


Rc<Hud> Hud::createHud(const Rc<DxvkDevice>& device) {
#ifdef WANT_ENV
const std::string hudConfig = env::getEnvVar(L"DXVK_HUD");

#else
const std::string hudConfig = "";
#endif
if (hudConfig.size() == 0)
return nullptr;

Expand Down
4 changes: 2 additions & 2 deletions src/dxvk/hud/dxvk_hud.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "../dxvk_device.h"

#ifdef WANT_ENV
#include "../util/util_env.h"

#endif
#include "dxvk_hud_devinfo.h"
#include "dxvk_hud_fps.h"
#include "dxvk_hud_text.h"
Expand Down
14 changes: 11 additions & 3 deletions src/util/log/log.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "log.h"

#ifdef WANT_ENV
#include "../util_env.h"

#endif
namespace dxvk {

Logger::Logger(const std::string& file_name)
Expand Down Expand Up @@ -62,8 +62,11 @@ namespace dxvk {
{ "error", LogLevel::Error },
{ "none", LogLevel::None },
}};
#ifdef WANT_ENV
const std::string logLevelStr = env::getEnvVar(L"DXVK_LOG_LEVEL");
#else
const std::string logLevelStr = "";
#endif

for (const auto& pair : logLevels) {
if (logLevelStr == pair.first)
Expand All @@ -75,6 +78,7 @@ namespace dxvk {


std::string Logger::getFileName(const std::string& base) {
#ifdef WANT_ENV
std::string path = env::getEnvVar(L"DXVK_LOG_PATH");

if (!path.empty() && *path.rbegin() != '/')
Expand All @@ -87,7 +91,11 @@ namespace dxvk {
exeName.erase(extp);

path += exeName + "_" + base;

return path;
#else
return "dxvk_" + base;
#endif
}

}
11 changes: 11 additions & 0 deletions src/util/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
if (get_option('env') == false)
util_src = files([
'com/com_guid.cpp',
'com/com_private_data.cpp',
'log/log.cpp',
'log/log_debug.cpp',
'sha1/sha1.c',
'sha1/sha1_util.cpp',
])
else
util_src = files([
'util_env.cpp',

Expand All @@ -10,6 +20,7 @@ util_src = files([
'sha1/sha1.c',
'sha1/sha1_util.cpp',
])
endif

util_lib = static_library('util', util_src,
include_directories : [ dxvk_include_path ])
Expand Down

0 comments on commit e5027ce

Please sign in to comment.