Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/vsg/app/WindowTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ namespace vsg

// forward declare
class Window;
class CommandLine;

/// WindowTraits specifies the settings required when creating windows/vulkan instance/device.
class VSG_DECLSPEC WindowTraits : public Inherit<Object, WindowTraits>
{
public:
WindowTraits();
WindowTraits(CommandLine& arguments);
explicit WindowTraits(const WindowTraits& traits, const CopyOp& copyop = {});
explicit WindowTraits(const std::string& title);
WindowTraits(int32_t in_x, int32_t in_y, uint32_t in_width, uint32_t in_height, const std::string& title = "vsg window");
Expand Down
1 change: 1 addition & 0 deletions include/vsg/io/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace vsg
uint32_t _materialSetIndex = 1;
ref_ptr<Sampler> _sampler;
ref_ptr<DescriptorBuffer> _material;
ref_ptr<DescriptorBuffer> _texCoordIndices;

ref_ptr<DescriptorImage> _imageFallback;
ref_ptr<DescriptorImage> _detailFallback;
Expand Down
1 change: 1 addition & 0 deletions include/vsg/utils/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ namespace vsg
return false;
}

/// deprecated: provided for backwards compatibility, use vsg::Options::readOptions(arguments)
bool read(Options* options);

using Messages = std::vector<std::string>;
Expand Down
36 changes: 36 additions & 0 deletions src/vsg/app/WindowTraits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/app/WindowTraits.h>
#include <vsg/io/Logger.h>
#include <vsg/vk/vulkan.h>
#include <vsg/utils/CommandLine.h>

#include <iostream>

using namespace vsg;

Expand All @@ -21,6 +24,39 @@ WindowTraits::WindowTraits()
defaults();
}

WindowTraits::WindowTraits(CommandLine& arguments)
{
defaults();

if (arguments.read("--args")) std::cout<<arguments<<std::endl;

windowTitle = vsg::make_string(arguments);
debugLayer = arguments.read({"--debug", "-d"});
apiDumpLayer = arguments.read({"--api", "-a"});
synchronizationLayer = arguments.read("--sync");

if (arguments.read("--double-buffer")) swapchainPreferences.imageCount = 2;
if (arguments.read("--triple-buffer")) swapchainPreferences.imageCount = 3; // default
if (arguments.read("--IMMEDIATE")) { swapchainPreferences.presentMode = VK_PRESENT_MODE_IMMEDIATE_KHR; }
if (arguments.read("--FIFO")) swapchainPreferences.presentMode = VK_PRESENT_MODE_FIFO_KHR;
if (arguments.read("--FIFO_RELAXED")) swapchainPreferences.presentMode = VK_PRESENT_MODE_FIFO_RELAXED_KHR;
if (arguments.read("--MAILBOX")) swapchainPreferences.presentMode = VK_PRESENT_MODE_MAILBOX_KHR;

if (arguments.read({"--fullscreen", "--fs"})) fullscreen = true;
if (arguments.read({"--window", "-w"}, width, height)) { fullscreen = false; }
if (arguments.read({"--no-frame", "--nf"})) decoration = false;
if (arguments.read("--or")) overrideRedirect = true;

if (arguments.read("--d32")) depthFormat = VK_FORMAT_D32_SFLOAT;
if (arguments.read("--sRGB")) swapchainPreferences.surfaceFormat = {VK_FORMAT_B8G8R8A8_SRGB, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
if (arguments.read("--RGB")) swapchainPreferences.surfaceFormat = {VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};

arguments.read("--screen", screenNum);
arguments.read("--display", display);
arguments.read("--samples", samples);

}

WindowTraits::WindowTraits(const WindowTraits& traits, const CopyOp& copyop) :
Inherit(traits, copyop),
x(traits.x),
Expand Down
15 changes: 15 additions & 0 deletions src/vsg/io/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ void tile::init(vsg::ref_ptr<const vsg::Options> options)
_material = vsg::DescriptorBuffer::create(mat, 10, 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
}

if (auto& texCoordIndicesBinding = _shaderSet->getDescriptorBinding("texCoordIndices"))
{
// Assumed texCoordIndicesBinding.set is equal to _materialSetIndex used to assign the tile texture and texCoordIndices

ref_ptr<Data> indices = texCoordIndicesBinding.data;
if (!indices) indices = vsg::TexCoordIndicesValue::create();
_texCoordIndices = vsg::DescriptorBuffer::create(indices, texCoordIndicesBinding.binding, 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
}
else
{
auto indices = vsg::TexCoordIndicesValue::create();
_texCoordIndices = vsg::DescriptorBuffer::create(indices, 11, 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
}

_graphicsPipelineConfig->init();
}

Expand Down Expand Up @@ -570,6 +584,7 @@ ref_ptr<BindDescriptorSet> tile::createBindDescriptorSet(ref_ptr<Data> imageData
}

descriptors.push_back(_material);
descriptors.push_back(_texCoordIndices);

return vsg::BindDescriptorSet::create(VK_PIPELINE_BIND_POINT_GRAPHICS, _graphicsPipelineConfig->layout, _materialSetIndex, descriptors);
}
Expand Down
Loading
Loading