void Animation::Iterator::dispatch_events(AnimationEventObserver &observer)
{
for(; (event_iter!=animation->events.end() && event_iter->time<=elapsed); ++event_iter)
- observer.animation_event(0, event_iter->name, event_iter->value);
+ observer.animation_event(nullptr, event_iter->name, event_iter->value);
}
Matrix Animation::Iterator::get_matrix() const
/* These shortcut constructors must be defined here to avoid an undefined
reference to vftable. */
Animation::Loader::Loader(Animation &a):
- Loader(a, 0)
+ Loader(a, nullptr)
{ }
Animation::Loader::Loader(Animation &a, Collection &c):
};
private:
- const Armature *armature = 0;
+ const Armature *armature = nullptr;
std::vector<TimedKeyFrame> keyframes;
std::vector<Event> events;
bool looping = false;
AnimationPlayer::Target::Target(Placeable &p):
placeable(p),
- object(0),
- armature(0),
+ object(nullptr),
+ armature(nullptr),
stacked(false)
{ }
Armature::Link::Link(const string &n, unsigned i):
name(n),
index(i),
- parent(0)
+ parent(nullptr)
{ }
void Armature::Link::set_parent(const Link *p)
std::string inline_base_name;
public:
- Loader(KeyFrame &k): Loader(k, 0) { }
+ Loader(KeyFrame &k): Loader(k, nullptr) { }
Loader(KeyFrame &k, Collection &c): Loader(k, &c) { }
private:
Loader(KeyFrame &, Collection *);
private:
Transform transform;
UniformMap uniforms;
- const Pose *pose = 0;
+ const Pose *pose = nullptr;
public:
void set_transform(const Transform &);
void rotation(float, float, float, float);
};
- const Armature *armature = 0;
+ const Armature *armature = nullptr;
std::vector<Link> links;
public:
{
static const int flags = GL_MAP_READ_BIT|GL_MAP_WRITE_BIT|GL_DYNAMIC_STORAGE_BIT;
if(ARB_direct_state_access)
- glNamedBufferStorage(id, size, 0, flags);
+ glNamedBufferStorage(id, size, nullptr, flags);
else
{
bind_scratch();
- glBufferStorage(GL_ARRAY_BUFFER, size, 0, flags);
+ glBufferStorage(GL_ARRAY_BUFFER, size, nullptr, flags);
}
}
else if(ARB_direct_state_access)
- glNamedBufferData(id, size, 0, GL_STATIC_DRAW);
+ glNamedBufferData(id, size, nullptr, GL_STATIC_DRAW);
else
{
bind_scratch();
- glBufferData(GL_ARRAY_BUFFER, size, 0, GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_STATIC_DRAW);
}
}
if(scratch_binding)
{
glBindBuffer(GL_ARRAY_BUFFER, 0);
- scratch_binding = 0;
+ scratch_binding = nullptr;
}
}
void OpenGLCommands::clear(const ClearValue *values)
{
- const Framebuffer *target = (pipeline_state ? pipeline_state->get_framebuffer() : 0);
+ const Framebuffer *target = (pipeline_state ? pipeline_state->get_framebuffer() : nullptr);
if(!target)
throw invalid_operation("OpenGLCommands::clear");
void OpenGLCommands::resolve_multisample()
{
- const Framebuffer *framebuffer = (pipeline_state ? pipeline_state->get_framebuffer() : 0);
+ const Framebuffer *framebuffer = (pipeline_state ? pipeline_state->get_framebuffer() : nullptr);
if(!framebuffer)
throw invalid_operation("OpenGLCommands::resolve_multisample");
class MSPGL_API OpenGLCommands
{
protected:
- const PipelineState *pipeline_state = 0;
+ const PipelineState *pipeline_state = nullptr;
OpenGLCommands() = default;
struct OpenGLDeviceState
{
- const OpenGLPipelineState *last_pipeline = 0;
+ const OpenGLPipelineState *last_pipeline = nullptr;
std::vector<int> bound_tex_targets;
std::vector<char> bound_storage_textures;
std::vector<char> bound_uniform_blocks;
std::vector<char> bound_storage_buffers;
unsigned restart_index = 0;
unsigned n_clip_distances = 0;
- const OpenGLBuffer *scratch_buffer = 0;
- const OpenGLTexture *scratch_texture = 0;
+ const OpenGLBuffer *scratch_buffer = nullptr;
+ const OpenGLTexture *scratch_texture = nullptr;
};
class MSPGL_API OpenGLDevice: public NonCopyable
OpenGLPipelineState::~OpenGLPipelineState()
{
if(applied_to)
- applied_to->get_state().last_pipeline = 0;
+ applied_to->get_state().last_pipeline = nullptr;
}
void OpenGLPipelineState::apply() const
if(applied_to && applied_to!=&device)
{
- applied_to->get_state().last_pipeline = 0;
+ applied_to->get_state().last_pipeline = nullptr;
changes = ~0U;
}
if(this!=dev_state.last_pipeline)
{
if(dev_state.last_pipeline)
- dev_state.last_pipeline->applied_to = 0;
+ dev_state.last_pipeline->applied_to = nullptr;
changes = ~0U;
}
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
- dev_state.last_pipeline->applied_to = 0;
- dev_state.last_pipeline = 0;
+ dev_state.last_pipeline->applied_to = nullptr;
+ dev_state.last_pipeline = nullptr;
}
}
friend class OpenGLCommands;
protected:
- mutable Device *applied_to = 0;
+ mutable Device *applied_to = nullptr;
mutable unsigned changes = 0;
OpenGLPipelineState() = default;
GLenum prop = GL_BUFFER_BINDING;
int value;
- glGetProgramResourceiv(id, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 1, 0, &value);
+ glGetProgramResourceiv(id, GL_SHADER_STORAGE_BLOCK, i, 1, &prop, 1, nullptr, &value);
info.bind_point = value;
}
}
for(const ReflectData::UniformInfo *u: i->uniforms)
if(u->location>=0)
{
- UniformCall::FuncPtr func = 0;
+ UniformCall::FuncPtr func = nullptr;
if(u->type==FLOAT)
func = &uniform_wrapper<float, glUniform1fv>;
else if(u->type==FLOAT_VEC2)
void OpenGLRenderer::end()
{
- static_cast<Renderer *>(this)->commands.use_pipeline(0);
+ static_cast<Renderer *>(this)->commands.use_pipeline(nullptr);
}
} // namespace GL
for(unsigned i=0; i<n_levels; ++i)
{
unsigned lv_size = self.get_level_size(i);
- glTexImage1D(target, i, gl_fmt, lv_size, 0, comp, type, 0);
+ glTexImage1D(target, i, gl_fmt, lv_size, 0, comp, type, nullptr);
}
}
void sub_image(unsigned, int, unsigned, const void *);
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
for(unsigned i=0; i<n_levels; ++i)
{
auto lv_size = self.get_level_size(i);
- glTexImage2D(target, i, gl_fmt, lv_size.x, lv_size.y, 0, comp, type, 0);
+ glTexImage2D(target, i, gl_fmt, lv_size.x, lv_size.y, 0, comp, type, nullptr);
}
}
OpenGLTexture2D::AsyncTransfer::AsyncTransfer(AsyncTransfer &&other):
pixel_buffer(other.pixel_buffer)
{
- other.pixel_buffer = 0;
+ other.pixel_buffer = nullptr;
}
OpenGLTexture2D::AsyncTransfer &OpenGLTexture2D::AsyncTransfer::operator=(AsyncTransfer &&other)
{
delete pixel_buffer;
pixel_buffer = other.pixel_buffer;
- other.pixel_buffer = 0;
+ other.pixel_buffer = nullptr;
return *this;
}
pixel_buffer->unmap();
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixel_buffer->id);
- self.texture->OpenGLTexture2D::sub_image(self.level, self.x, self.y, self.width, self.height, 0);
+ self.texture->OpenGLTexture2D::sub_image(self.level, self.x, self.y, self.width, self.height, nullptr);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
class MSPGL_API AsyncTransfer: public NonCopyable
{
protected:
- Buffer *pixel_buffer = 0;
+ Buffer *pixel_buffer = nullptr;
AsyncTransfer() = default;
AsyncTransfer(AsyncTransfer &&);
void allocate();
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
for(unsigned i=0; i<n_levels; ++i)
{
auto lv_size = self.get_level_size(i);
- glTexImage3D(target, i, gl_fmt, lv_size.x, lv_size.y, lv_size.z, 0, comp, type, 0);
+ glTexImage3D(target, i, gl_fmt, lv_size.x, lv_size.y, lv_size.z, 0, comp, type, nullptr);
}
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, n_levels-1);
}
bool is_array() const;
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
if(scratch_binding)
{
glBindTexture(scratch_binding->target, 0);
- scratch_binding = 0;
+ scratch_binding = nullptr;
}
}
{
unsigned lv_size = static_cast<const TextureCube *>(this)->get_level_size(i);
for(unsigned j=0; j<6; ++j)
- glTexImage2D(get_gl_cube_face(j), i, gl_fmt, lv_size, lv_size, 0, comp, type, 0);
+ glTexImage2D(get_gl_cube_face(j), i, gl_fmt, lv_size, lv_size, 0, comp, type, nullptr);
}
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, n_levels-1);
}
void sub_image(unsigned, unsigned, int, int, unsigned, unsigned, const void *);
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
{
unsigned sem = get_attribute_semantic(a);
glDisableVertexAttribArray(sem);
- glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0);
+ glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, nullptr);
}
for(VertexAttribute a: self.inst_format)
if(!is_padding(a))
{
unsigned sem = get_attribute_semantic(a);
glDisableVertexAttribArray(sem);
- glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0);
+ glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, nullptr);
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
mapped_address(other.mapped_address),
debug_name(move(other.debug_name))
{
- other.handle = 0;
+ other.handle = nullptr;
other.memory_id = 0;
- other.mapped_address = 0;
+ other.mapped_address = nullptr;
}
VulkanBuffer::~VulkanBuffer()
bool VulkanBuffer::unmap()
{
device.get_allocator().unmap(memory_id);
- mapped_address = 0;
+ mapped_address = nullptr;
return true;
}
protected:
Device &device;
- VkBuffer handle = 0;
+ VkBuffer handle = nullptr;
unsigned memory_id = 0;
- void *mapped_address = 0;
+ void *mapped_address = nullptr;
std::string debug_name;
VulkanBuffer();
}
vk.BeginCommandBuffer(buffer, begin_info);
- last_pipeline = 0;
+ last_pipeline = nullptr;
}
void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_values)
viewport = pipeline_state->get_viewport();
if(!primary_buffer)
- begin_buffer(0);
+ begin_buffer(nullptr);
fb_is_swapchain = framebuffer->is_presentable();
framebuffer->refresh();
vkCmd.ExecuteCommands(1, &pass_buffer);
vkCmd.EndRenderPass();
- framebuffer = 0;
+ framebuffer = nullptr;
viewport = Rect::max();
- pass_buffer = 0;
+ pass_buffer = nullptr;
}
void VulkanCommands::begin_frame(unsigned fnum)
vk.QueueSubmit(1, &submit_info, command_pools[frame_index].fence.handle);
- primary_buffer = 0;
+ primary_buffer = nullptr;
}
void VulkanCommands::use_pipeline(const PipelineState *ps)
throw invalid_operation("VulkanCommands::draw_instanced");
if(!framebuffer)
- begin_render_pass(false, 0);
+ begin_render_pass(false, nullptr);
VulkanCommandRecorder vkCmd(device.get_functions(), pass_buffer);
pipeline_state->refresh();
pipeline_state->synchronize_resources();
device.get_synchronizer().barrier(vkCmd);
- pipeline_state->apply(vkCmd, 0, frame_index, false);
+ pipeline_state->apply(vkCmd, nullptr, frame_index, false);
vkCmd.Dispatch(count_x, count_y, count_z);
}
fence(move(other.fence)),
in_use(other.in_use)
{
- other.pool = 0;
+ other.pool = nullptr;
}
VulkanCommands::CommandPool::~CommandPool()
struct CommandPool
{
Device &device;
- VkCommandPool pool = 0;
+ VkCommandPool pool = nullptr;
CommandBuffers primary;
CommandBuffers secondary;
Fence fence;
std::vector<CommandPool> command_pools;
unsigned frame_number = 0;
unsigned frame_index = 0;
- VkCommandBuffer primary_buffer = 0;
- VkCommandBuffer pass_buffer = 0;
- const PipelineState *pipeline_state = 0;
- const PipelineState *last_pipeline = 0;
- const Framebuffer *framebuffer = 0;
+ VkCommandBuffer primary_buffer = nullptr;
+ VkCommandBuffer pass_buffer = nullptr;
+ const PipelineState *pipeline_state = nullptr;
+ const PipelineState *last_pipeline = nullptr;
+ const Framebuffer *framebuffer = nullptr;
Rect viewport = Rect::max();
bool fb_is_swapchain = false;
bool discard_fb_contents = false;
add_pool(capacity);
for(auto &s: sets)
- fill(s.begin(), s.end(), static_cast<VkDescriptorSet>(0));
+ fill(s.begin(), s.end(), static_cast<VkDescriptorSet>(nullptr));
used = Counts();
}
slot = next_slot++;
slots.emplace(i, hash, slot);
for(auto &s: sets)
- s.push_back(0);
+ s.push_back(nullptr);
}
if(ps.is_descriptor_set_dynamic(index))
for(unsigned i=0; i<n_writes; ++i)
writes[i].dstSet = handle_cast<::VkDescriptorSet>(desc_set);
- vk.UpdateDescriptorSets(n_writes, writes, 0, 0);
+ vk.UpdateDescriptorSets(n_writes, writes, 0, nullptr);
return desc_set;
}
private:
struct Entry
{
- void *handle = 0;
- void (*destroy_func)(const VulkanFunctions &, void *) = 0;
+ void *handle = nullptr;
+ void (*destroy_func)(const VulkanFunctions &, void *) = nullptr;
unsigned memory_id = 0;
unsigned on_frame = 0;
};
device(other.device),
handle(other.handle)
{
- other.handle = 0;
+ other.handle = nullptr;
}
Fence::~Fence()
handle(other.handle),
debug_name(move(other.debug_name))
{
- other.handle = 0;
+ other.handle = nullptr;
}
VulkanFramebuffer::~VulkanFramebuffer()
protected:
Device &device;
- mutable VkFramebuffer handle = 0;
+ mutable VkFramebuffer handle = nullptr;
mutable std::vector<VkImageView> view_handles;
std::string debug_name;
{
const VulkanFunctions &vk = device.get_functions();
vk.UnmapMemory(region.memory);
- region.mapped_address = 0;
+ region.mapped_address = nullptr;
}
}
{
int pool = -1;
bool direct = false;
- VkDeviceMemory memory = 0;
+ VkDeviceMemory memory = nullptr;
std::size_t size = 0;
- void *mapped_address = 0;
+ void *mapped_address = nullptr;
unsigned map_count = 0;
};
device(other.device),
handle(other.handle)
{
- other.handle = 0;
+ other.handle = nullptr;
}
VulkanSpirVModule::~VulkanSpirVModule()
protected:
Device &device;
- VkShaderModule handle = 0;
+ VkShaderModule handle = nullptr;
std::string debug_name;
VulkanSpirVModule();
if(type==VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO)
{
const VkComputePipelineCreateInfo *creation_info = reinterpret_cast<const VkComputePipelineCreateInfo *>(buffer.data());
- vk.CreateComputePipelines(0, 1, creation_info, &pipeline);
+ vk.CreateComputePipelines(nullptr, 1, creation_info, &pipeline);
}
else
{
const VkGraphicsPipelineCreateInfo *creation_info = reinterpret_cast<const VkGraphicsPipelineCreateInfo *>(buffer.data());
- vk.CreateGraphicsPipelines(0, 1, creation_info, &pipeline);
+ vk.CreateGraphicsPipelines(nullptr, 1, creation_info, &pipeline);
}
pipelines.insert(make_pair(key, pipeline));
viewport_info->sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewport_info->viewportCount = 1;
- viewport_info->pViewports = 0;
+ viewport_info->pViewports = nullptr;
viewport_info->scissorCount = 1;
- viewport_info->pScissors = 0;
+ viewport_info->pScissors = nullptr;
raster_info->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
raster_info->depthClampEnable = VK_FALSE;
multisample_info->rasterizationSamples = static_cast<VkSampleCountFlagBits>(get_vulkan_samples(format.get_samples()));
multisample_info->sampleShadingEnable = VK_FALSE;
multisample_info->minSampleShading = 1.0f;
- multisample_info->pSampleMask = 0;
+ multisample_info->pSampleMask = nullptr;
multisample_info->alphaToCoverageEnable = (format.get_samples()>1 && self.blend.alpha_to_coverage ? VK_TRUE : VK_FALSE);
multisample_info->alphaToOneEnable = VK_FALSE;
pipeline_info->sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipeline_info->pInputAssemblyState = input_assembly_info;
- pipeline_info->pTessellationState = (has_tessellation ? tessellation_info : 0);
+ pipeline_info->pTessellationState = (has_tessellation ? tessellation_info : nullptr);
pipeline_info->pViewportState = viewport_info;
pipeline_info->pRasterizationState = raster_info;
pipeline_info->pMultisampleState = multisample_info;
{
const PipelineState &self = *static_cast<const PipelineState *>(this);
- uint64_t result = hash<64>(0, 0);
+ uint64_t result = hash<64>(nullptr, 0);
bool empty = true;
auto i = lower_bound_member(self.resources, static_cast<int>(index)<<20, &PipelineState::BoundResource::binding);
self.descriptor_set_slots[i], self, i, frame));
vkCmd.BindDescriptorSets(bind_point, self.shprog->layout_handle,
- first_changed_desc_set, descriptor_set_handles.size(), descriptor_set_handles.data(), 0, 0);
+ first_changed_desc_set, descriptor_set_handles.size(), descriptor_set_handles.data(), 0, nullptr);
}
if(!self.shprog->is_compute() && (unapplied&(PipelineState::VIEWPORT|PipelineState::SCISSOR)))
Device &device;
mutable unsigned changes = 0;
mutable unsigned unapplied = 0;
- mutable VkPipeline handle = 0;
+ mutable VkPipeline handle = nullptr;
mutable std::vector<unsigned> descriptor_set_slots;
mutable unsigned first_changed_desc_set = 0;
mutable std::uint32_t push_const_compat = 0;
debug_name(move(other.debug_name))
{
other.desc_set_layout_handles.clear();
- other.layout_handle = 0;
+ other.layout_handle = nullptr;
}
VulkanProgram::~VulkanProgram()
const ReflectData &rd = static_cast<const Program *>(this)->reflect_data;
auto i = find_member(rd.blocks, static_cast<int>(ReflectData::PUSH_CONSTANT), &ReflectData::BlockInfo::bind_point);
- const ReflectData::BlockInfo *push_const_block = (i!=rd.blocks.end() ? &*i : 0);
+ const ReflectData::BlockInfo *push_const_block = (i!=rd.blocks.end() ? &*i : nullptr);
desc_set_layout_handles.resize(rd.n_descriptor_sets);
for(unsigned j=0; j<rd.n_descriptor_sets; ++j)
binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
binding.descriptorCount = 1;
binding.stageFlags = stage_flags;
- binding.pImmutableSamplers = 0;
+ binding.pImmutableSamplers = nullptr;
}
for(const ReflectData::UniformInfo &u: rd.uniforms)
binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
binding.descriptorCount = 1;
binding.stageFlags = stage_flags;
- binding.pImmutableSamplers = 0;
+ binding.pImmutableSamplers = nullptr;
}
VkDescriptorSetLayoutCreateInfo set_layout_info = { };
unsigned stage_flags = 0;
std::vector<char> creation_info;
std::vector<VkDescriptorSetLayout> desc_set_layout_handles;
- VkPipelineLayout layout_handle = 0;
+ VkPipelineLayout layout_handle = nullptr;
std::string debug_name;
VulkanProgram();
void VulkanRenderer::begin()
{
- begin_semaphore = 0;
- end_semaphore = 0;
+ begin_semaphore = nullptr;
+ end_semaphore = nullptr;
}
void VulkanRenderer::begin(Semaphore &sem)
void VulkanRenderer::end()
{
Renderer &self = *static_cast<Renderer *>(this);
- self.commands.use_pipeline(0);
+ self.commands.use_pipeline(nullptr);
self.commands.submit_frame(begin_semaphore, end_semaphore);
}
{
protected:
std::map<std::uintptr_t, PipelineState> pipeline_states;
- PipelineState *current_pipeline = 0;
- Semaphore *begin_semaphore = 0;
- Semaphore *end_semaphore = 0;
+ PipelineState *current_pipeline = nullptr;
+ Semaphore *begin_semaphore = nullptr;
+ Semaphore *end_semaphore = nullptr;
VulkanRenderer();
struct RenderPass
{
- const Framebuffer *framebuffer = 0;
+ const Framebuffer *framebuffer = nullptr;
Rect render_area;
bool clear = false;
- const ClearValue *clear_values = 0;
+ const ClearValue *clear_values = nullptr;
bool to_present = false;
bool discard_fb_contents = false;
- VkRenderPass handle = 0;
+ VkRenderPass handle = nullptr;
void update(Device &);
handle(other.handle),
debug_name(move(other.debug_name))
{
- other.handle = 0;
+ other.handle = nullptr;
}
VulkanSampler::~VulkanSampler()
protected:
Device &device;
- mutable VkSampler handle = 0;
+ mutable VkSampler handle = nullptr;
std::string debug_name;
VulkanSampler();
struct Part
{
std::size_t offset = 0;
- void *pointer = 0;
+ void *pointer = nullptr;
};
std::vector<char> &storage;
surface_caps.supportedCompositeAlpha&~(surface_caps.supportedCompositeAlpha-1));
uint32_t n_formats = 0;
- vk.GetPhysicalDeviceSurfaceFormats(surface, n_formats, 0);
+ vk.GetPhysicalDeviceSurfaceFormats(surface, n_formats, nullptr);
vector<VkSurfaceFormatKHR> surface_formats(n_formats);
vk.GetPhysicalDeviceSurfaceFormats(surface, n_formats, surface_formats.data());
throw runtime_error("no suitable swapchain pixelformat");
uint32_t n_present_modes = 0;
- vk.GetPhysicalDeviceSurfacePresentModes(surface, n_present_modes, 0);
+ vk.GetPhysicalDeviceSurfacePresentModes(surface, n_present_modes, nullptr);
vector<VkPresentModeKHR> present_modes(n_present_modes);
vk.GetPhysicalDeviceSurfacePresentModes(surface, n_present_modes, present_modes.data());
vk.CreateSwapchain(swapchain_info, handle);
uint32_t n_images = 0;
- vk.GetSwapchainImages(handle, n_images, 0);
+ vk.GetSwapchainImages(handle, n_images, nullptr);
vector<VkImage> image_handles(n_images);
vk.GetSwapchainImages(handle, n_images, image_handles.data());
const VulkanFunctions &vk = device.get_functions();
uint32_t image_index;
- vk.AcquireNextImage(handle, numeric_limits<uint64_t>::max(), sem.handle, 0, image_index);
+ vk.AcquireNextImage(handle, numeric_limits<uint64_t>::max(), sem.handle, nullptr, image_index);
current_index = image_index;
private:
Device &device;
- VkSwapchain handle = 0;
- VkSurface surface = 0;
+ VkSwapchain handle = nullptr;
+ VkSurface surface = nullptr;
unsigned width = 0;
unsigned height = 0;
std::vector<SwapChainTexture> images;
SwapChainTexture::~SwapChainTexture()
{
- handle = 0;
+ handle = nullptr;
}
} // namespace GL
if(!dst_stage)
dst_stage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
- vkCmd.PipelineBarrier(src_stage, dst_stage, 0, 0, 0,
+ vkCmd.PipelineBarrier(src_stage, dst_stage, 0, 0, nullptr,
buffer_barriers.size(), buffer_barriers.data(), image_barriers.size(), image_barriers.data());
for(auto i=buffer_accesses.begin(); i!=buffer_accesses.end(); )
private:
struct ImageAccess
{
- VkImage image = 0;
+ VkImage image = nullptr;
unsigned aspect;
int level = -1;
unsigned current_layout;
struct BufferAccess
{
- VkBuffer buffer = 0;
+ VkBuffer buffer = nullptr;
std::size_t offset = 0;
std::size_t size = 0;
bool was_written = false;
virtual void fill_mipmap_blit(unsigned, void *);
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
virtual void fill_mipmap_blit(unsigned, void *) { }
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
bool is_array() const;
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
view_type(other.view_type),
debug_name(move(other.debug_name))
{
- other.handle = 0;
- other.view_handle = 0;
+ other.handle = nullptr;
+ other.view_handle = nullptr;
other.memory_id = 0;
}
protected:
Device &device;
- VkImage handle = 0;
- VkImageView view_handle = 0;
+ VkImage handle = nullptr;
+ VkImageView view_handle = nullptr;
mutable std::vector<VkImageView> mip_view_handles;
unsigned memory_id = 0;
unsigned view_type;
virtual void fill_mipmap_blit(unsigned, void *);
public:
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) { return nullptr; }
virtual std::size_t get_data_size() const;
virtual void unload() { }
};
for(; i!=j; ++i)
{
- VkBuffer buffer = (i->buffer_index>=0 ? buffers[i->buffer_index].buffer : 0);
+ VkBuffer buffer = (i->buffer_index>=0 ? buffers[i->buffer_index].buffer : nullptr);
i->transfer(vkCmd, buffer, i->offset);
if(i->buffer_index>=0)
buffers[i->buffer_index].last_frame = current_frame;
used(other.used),
mapped_address(other.mapped_address)
{
- other.buffer = 0;
+ other.buffer = nullptr;
other.memory_id = 0;
- other.mapped_address = 0;
+ other.mapped_address = nullptr;
}
TransferQueue::StagingBuffer::~StagingBuffer()
struct StagingBuffer
{
Device &device;
- VkBuffer buffer = 0;
+ VkBuffer buffer = nullptr;
unsigned memory_id = 0;
std::size_t size = 0;
std::size_t used = 0;
- void *mapped_address = 0;
+ void *mapped_address = nullptr;
unsigned async_count = 0;
unsigned last_frame = 0;
struct PendingTransfer
{
- const void *object = 0;
+ const void *object = nullptr;
unsigned order = 0;
int buffer_index = -1;
std::size_t offset = 0;
std::size_t size = 0;
- void *staging_address = 0;
+ void *staging_address = nullptr;
std::function<void()> synchronize;
std::function<void(const VulkanCommandRecorder &, VkBuffer, std::size_t)> transfer;
};
{
const VertexSetup &self = *static_cast<const VertexSetup *>(this);
- uint64_t result = hash<64>(0, 0);
+ uint64_t result = hash<64>(nullptr, 0);
for(VertexAttribute a: self.vertex_format)
result = hash_update<64>(result, a);
for(VertexAttribute a: self.inst_format)
::VkPhysicalDevice physicalDevice;
::VkQueue graphicsQueue;
- PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = 0; // 5.1
- PFN_vkCreateCommandPool vkCreateCommandPool = 0; // 6.2
- PFN_vkResetCommandPool vkResetCommandPool = 0; // 6.2
- PFN_vkDestroyCommandPool vkDestroyCommandPool = 0; // 6.2
- PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = 0; // 6.3
- PFN_vkBeginCommandBuffer vkBeginCommandBuffer = 0; // 6.4
- PFN_vkEndCommandBuffer vkEndCommandBuffer = 0; // 6.4
- PFN_vkQueueSubmit vkQueueSubmit = 0; // 6.5
- PFN_vkCmdExecuteCommands vkCmdExecuteCommands = 0; // 6.7
- PFN_vkCreateFence vkCreateFence = 0; // 7.3
- PFN_vkDestroyFence vkDestroyFence = 0; // 7.3
- PFN_vkGetFenceStatus vkGetFenceStatus = 0; // 7.3
- PFN_vkResetFences vkResetFences = 0; // 7.3
- PFN_vkWaitForFences vkWaitForFences = 0; // 7.3
- PFN_vkCreateSemaphore vkCreateSemaphore = 0; // 7.4
- PFN_vkDestroySemaphore vkDestroySemaphore = 0; // 7.4
- PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier = 0; // 7.6
- PFN_vkQueueWaitIdle vkQueueWaitIdle = 0; // 7.8
- PFN_vkCreateRenderPass vkCreateRenderPass = 0; // 8.1
- PFN_vkCreateRenderPass2 vkCreateRenderPass2 = 0; // 8.1
- PFN_vkDestroyRenderPass vkDestroyRenderPass = 0; // 8.1
- PFN_vkCreateFramebuffer vkCreateFramebuffer = 0; // 8.3
- PFN_vkDestroyFramebuffer vkDestroyFramebuffer = 0; // 8.3
- PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass = 0; // 8.4
- PFN_vkCmdEndRenderPass vkCmdEndRenderPass = 0; // 8.4
- PFN_vkCreateShaderModule vkCreateShaderModule = 0; // 9.1
- PFN_vkDestroyShaderModule vkDestroyShaderModule = 0; // 9.1
- PFN_vkCreateComputePipelines vkCreateComputePipelines = 0; // 10.1
- PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines = 0; // 10.2
- PFN_vkDestroyPipeline vkDestroyPipeline = 0; // 10.4
- PFN_vkCmdBindPipeline vkCmdBindPipeline = 0; // 10.10
- PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties = 0; // 11.2.1
- PFN_vkAllocateMemory vkAllocateMemory = 0; // 11.2.3
- PFN_vkFreeMemory vkFreeMemory = 0; // 11.2.8
- PFN_vkMapMemory vkMapMemory = 0; // 11.2.9
- PFN_vkUnmapMemory vkUnmapMemory = 0; // 11.2.9
- PFN_vkCreateBuffer vkCreateBuffer = 0; // 12.1
- PFN_vkDestroyBuffer vkDestroyBuffer = 0; // 12.1
- PFN_vkCreateImage vkCreateImage = 0; // 12.3
- PFN_vkDestroyImage vkDestroyImage = 0; // 12.3
- PFN_vkCreateImageView vkCreateImageView = 0; // 12.5
- PFN_vkDestroyImageView vkDestroyImageView = 0; // 12.5
- PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements = 0; // 12.7
- PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements = 0; // 12.7
- PFN_vkBindBufferMemory vkBindBufferMemory = 0; // 12.7
- PFN_vkBindImageMemory vkBindImageMemory = 0; // 12.7
- PFN_vkCreateSampler vkCreateSampler = 0; // 13
- PFN_vkDestroySampler vkDestroySampler = 0; // 13
- PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout = 0; // 14.2.1
- PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout = 0; // 14.2.1
- PFN_vkCreatePipelineLayout vkCreatePipelineLayout = 0; // 14.2.2
- PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout = 0; // 14.2.2
- PFN_vkCreateDescriptorPool vkCreateDescriptorPool = 0; // 14.2.3
- PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool = 0; // 14.2.3
- PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets = 0; // 14.2.3
- PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets = 0; // 14.2.4
- PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets = 0; // 14.2.7
- PFN_vkCmdPushConstants vkCmdPushConstants = 0; // 14.2.10
- PFN_vkCmdCopyBuffer vkCmdCopyBuffer = 0; // 19.2
- PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage = 0; // 19.4
- PFN_vkCmdBlitImage vkCmdBlitImage = 0; // 19.5
- PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer = 0; // 20.3
- PFN_vkCmdDrawIndexed vkCmdDrawIndexed = 0; // 20.3
- PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers = 0; // 21.2
- PFN_vkCmdSetViewport vkCmdSetViewport = 0; // 24.5
- PFN_vkCmdSetScissor vkCmdSetScissor = 0; // 26.1
- PFN_vkCmdDispatch vkCmdDispatch = 0; // 28
- PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilities = 0; // 30.5.1
- PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormats = 0; // 30.5.2
- PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModes = 0; // 30.5.3
- PFN_vkCreateSwapchainKHR vkCreateSwapchain = 0; // 30.8
- PFN_vkDestroySwapchainKHR vkDestroySwapchain = 0; // 30.8
- PFN_vkGetSwapchainImagesKHR vkGetSwapchainImages = 0; // 30.8
- PFN_vkAcquireNextImageKHR vkAcquireNextImage = 0; // 30.8
- PFN_vkQueuePresentKHR vkQueuePresent = 0; // 30.8
- PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties = 0; // 39.2
- PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectName = 0; // 45.1.1
+ PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = nullptr; // 5.1
+ PFN_vkCreateCommandPool vkCreateCommandPool = nullptr; // 6.2
+ PFN_vkResetCommandPool vkResetCommandPool = nullptr; // 6.2
+ PFN_vkDestroyCommandPool vkDestroyCommandPool = nullptr; // 6.2
+ PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = nullptr; // 6.3
+ PFN_vkBeginCommandBuffer vkBeginCommandBuffer = nullptr; // 6.4
+ PFN_vkEndCommandBuffer vkEndCommandBuffer = nullptr; // 6.4
+ PFN_vkQueueSubmit vkQueueSubmit = nullptr; // 6.5
+ PFN_vkCmdExecuteCommands vkCmdExecuteCommands = nullptr; // 6.7
+ PFN_vkCreateFence vkCreateFence = nullptr; // 7.3
+ PFN_vkDestroyFence vkDestroyFence = nullptr; // 7.3
+ PFN_vkGetFenceStatus vkGetFenceStatus = nullptr; // 7.3
+ PFN_vkResetFences vkResetFences = nullptr; // 7.3
+ PFN_vkWaitForFences vkWaitForFences = nullptr; // 7.3
+ PFN_vkCreateSemaphore vkCreateSemaphore = nullptr; // 7.4
+ PFN_vkDestroySemaphore vkDestroySemaphore = nullptr; // 7.4
+ PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier = nullptr; // 7.6
+ PFN_vkQueueWaitIdle vkQueueWaitIdle = nullptr; // 7.8
+ PFN_vkCreateRenderPass vkCreateRenderPass = nullptr; // 8.1
+ PFN_vkCreateRenderPass2 vkCreateRenderPass2 = nullptr; // 8.1
+ PFN_vkDestroyRenderPass vkDestroyRenderPass = nullptr; // 8.1
+ PFN_vkCreateFramebuffer vkCreateFramebuffer = nullptr; // 8.3
+ PFN_vkDestroyFramebuffer vkDestroyFramebuffer = nullptr; // 8.3
+ PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass = nullptr; // 8.4
+ PFN_vkCmdEndRenderPass vkCmdEndRenderPass = nullptr; // 8.4
+ PFN_vkCreateShaderModule vkCreateShaderModule = nullptr; // 9.1
+ PFN_vkDestroyShaderModule vkDestroyShaderModule = nullptr; // 9.1
+ PFN_vkCreateComputePipelines vkCreateComputePipelines = nullptr; // 10.1
+ PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines = nullptr; // 10.2
+ PFN_vkDestroyPipeline vkDestroyPipeline = nullptr; // 10.4
+ PFN_vkCmdBindPipeline vkCmdBindPipeline = nullptr; // 10.10
+ PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties = nullptr; // 11.2.1
+ PFN_vkAllocateMemory vkAllocateMemory = nullptr; // 11.2.3
+ PFN_vkFreeMemory vkFreeMemory = nullptr; // 11.2.8
+ PFN_vkMapMemory vkMapMemory = nullptr; // 11.2.9
+ PFN_vkUnmapMemory vkUnmapMemory = nullptr; // 11.2.9
+ PFN_vkCreateBuffer vkCreateBuffer = nullptr; // 12.1
+ PFN_vkDestroyBuffer vkDestroyBuffer = nullptr; // 12.1
+ PFN_vkCreateImage vkCreateImage = nullptr; // 12.3
+ PFN_vkDestroyImage vkDestroyImage = nullptr; // 12.3
+ PFN_vkCreateImageView vkCreateImageView = nullptr; // 12.5
+ PFN_vkDestroyImageView vkDestroyImageView = nullptr; // 12.5
+ PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements = nullptr; // 12.7
+ PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements = nullptr; // 12.7
+ PFN_vkBindBufferMemory vkBindBufferMemory = nullptr; // 12.7
+ PFN_vkBindImageMemory vkBindImageMemory = nullptr; // 12.7
+ PFN_vkCreateSampler vkCreateSampler = nullptr; // 13
+ PFN_vkDestroySampler vkDestroySampler = nullptr; // 13
+ PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout = nullptr; // 14.2.1
+ PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout = nullptr; // 14.2.1
+ PFN_vkCreatePipelineLayout vkCreatePipelineLayout = nullptr; // 14.2.2
+ PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout = nullptr; // 14.2.2
+ PFN_vkCreateDescriptorPool vkCreateDescriptorPool = nullptr; // 14.2.3
+ PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool = nullptr; // 14.2.3
+ PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets = nullptr; // 14.2.3
+ PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets = nullptr; // 14.2.4
+ PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets = nullptr; // 14.2.7
+ PFN_vkCmdPushConstants vkCmdPushConstants = nullptr; // 14.2.10
+ PFN_vkCmdCopyBuffer vkCmdCopyBuffer = nullptr; // 19.2
+ PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage = nullptr; // 19.4
+ PFN_vkCmdBlitImage vkCmdBlitImage = nullptr; // 19.5
+ PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer = nullptr; // 20.3
+ PFN_vkCmdDrawIndexed vkCmdDrawIndexed = nullptr; // 20.3
+ PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers = nullptr; // 21.2
+ PFN_vkCmdSetViewport vkCmdSetViewport = nullptr; // 24.5
+ PFN_vkCmdSetScissor vkCmdSetScissor = nullptr; // 26.1
+ PFN_vkCmdDispatch vkCmdDispatch = nullptr; // 28
+ PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilities = nullptr; // 30.5.1
+ PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormats = nullptr; // 30.5.2
+ PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModes = nullptr; // 30.5.3
+ PFN_vkCreateSwapchainKHR vkCreateSwapchain = nullptr; // 30.8
+ PFN_vkDestroySwapchainKHR vkDestroySwapchain = nullptr; // 30.8
+ PFN_vkGetSwapchainImagesKHR vkGetSwapchainImages = nullptr; // 30.8
+ PFN_vkAcquireNextImageKHR vkAcquireNextImage = nullptr; // 30.8
+ PFN_vkQueuePresentKHR vkQueuePresent = nullptr; // 30.8
+ PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties = nullptr; // 39.2
+ PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectName = nullptr; // 45.1.1
public:
VulkanFunctions(const Graphics::VulkanContext &);
// Chapter 6: Command Buffers
Result CreateCommandPool(const VkCommandPoolCreateInfo &rCreateInfo, VkCommandPool &rCommandPool) const
- { return { vkCreateCommandPool(device, &rCreateInfo, 0, handle_cast<::VkCommandPool *>(&rCommandPool)), "vkCreateCommandPool" }; }
+ { return { vkCreateCommandPool(device, &rCreateInfo, nullptr, handle_cast<::VkCommandPool *>(&rCommandPool)), "vkCreateCommandPool" }; }
Result ResetCommandPool(VkCommandPool commandPool, VkCommandPoolResetFlags flags) const
{ return { vkResetCommandPool(device, handle_cast<::VkCommandPool>(commandPool), flags), "vkResetCommandPool" }; }
void DestroyCommandPool(VkCommandPool commandPool) const
- { vkDestroyCommandPool(device, handle_cast<::VkCommandPool>(commandPool), 0); }
+ { vkDestroyCommandPool(device, handle_cast<::VkCommandPool>(commandPool), nullptr); }
Result AllocateCommandBuffers(const VkCommandBufferAllocateInfo &rAllocateInfo, VkCommandBuffer *pCommandBuffers) const
{ return { vkAllocateCommandBuffers(device, &rAllocateInfo, handle_cast<::VkCommandBuffer *>(pCommandBuffers)), "vkAllocateCommandBuffers" }; }
// Chapter 7: Synchronization and Cache Control
Result CreateFence(const VkFenceCreateInfo &rCreateInfo, VkFence &rFence) const
- { return { vkCreateFence(device, &rCreateInfo, 0, handle_cast<::VkFence *>(&rFence)), "vkCreateFence" }; }
+ { return { vkCreateFence(device, &rCreateInfo, nullptr, handle_cast<::VkFence *>(&rFence)), "vkCreateFence" }; }
void DestroyFence(VkFence fence) const
- { vkDestroyFence(device, handle_cast<::VkFence>(fence), 0); }
+ { vkDestroyFence(device, handle_cast<::VkFence>(fence), nullptr); }
Result GetFenceStatus(VkFence fence) const
{ return { vkGetFenceStatus(device, handle_cast<::VkFence>(fence)), "vkGetFenceStatus" }; }
{ return { vkWaitForFences(device, fenceCount, handle_cast<const ::VkFence *>(pFences), waitAll, timeout), "vkWaitForFences" }; }
Result CreateSemaphore(const VkSemaphoreCreateInfo &rCreateInfo, VkSemaphore &rSemaphore) const
- { return { vkCreateSemaphore(device, &rCreateInfo, 0, handle_cast<::VkSemaphore *>(&rSemaphore)), "vkCreateSemaphore" }; }
+ { return { vkCreateSemaphore(device, &rCreateInfo, nullptr, handle_cast<::VkSemaphore *>(&rSemaphore)), "vkCreateSemaphore" }; }
void DestroySemaphore(VkSemaphore semaphore) const
- { vkDestroySemaphore(device, handle_cast<::VkSemaphore>(semaphore), 0); }
+ { vkDestroySemaphore(device, handle_cast<::VkSemaphore>(semaphore), nullptr); }
void CmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) const
{ vkCmdPipelineBarrier(handle_cast<::VkCommandBuffer>(commandBuffer), srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers); }
// Chapter 8: Render Pass
Result CreateRenderPass(const VkRenderPassCreateInfo &rCreateInfo, VkRenderPass &rRenderPass) const
- { return { vkCreateRenderPass(device, &rCreateInfo, 0, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass" }; }
+ { return { vkCreateRenderPass(device, &rCreateInfo, nullptr, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass" }; }
Result CreateRenderPass2(const VkRenderPassCreateInfo2 &rCreateInfo, VkRenderPass &rRenderPass) const
- { return { vkCreateRenderPass2(device, &rCreateInfo, 0, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass2" }; }
+ { return { vkCreateRenderPass2(device, &rCreateInfo, nullptr, handle_cast<::VkRenderPass *>(&rRenderPass)), "vkCreateRenderPass2" }; }
void DestroyRenderPass(VkRenderPass renderPass) const
- { vkDestroyRenderPass(device, handle_cast<::VkRenderPass>(renderPass), 0); }
+ { vkDestroyRenderPass(device, handle_cast<::VkRenderPass>(renderPass), nullptr); }
Result CreateFramebuffer(const VkFramebufferCreateInfo &rCreateInfo, VkFramebuffer &rFramebuffer) const
- { return { vkCreateFramebuffer(device, &rCreateInfo, 0, handle_cast<::VkFramebuffer *>(&rFramebuffer)), "vkCreateFramebuffer" }; }
+ { return { vkCreateFramebuffer(device, &rCreateInfo, nullptr, handle_cast<::VkFramebuffer *>(&rFramebuffer)), "vkCreateFramebuffer" }; }
void DestroyFramebuffer(VkFramebuffer framebuffer) const
- { vkDestroyFramebuffer(device, handle_cast<::VkFramebuffer>(framebuffer), 0); }
+ { vkDestroyFramebuffer(device, handle_cast<::VkFramebuffer>(framebuffer), nullptr); }
void CmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo &rRenderPassBegin, VkSubpassContents contents) const
{ vkCmdBeginRenderPass(handle_cast<::VkCommandBuffer>(commandBuffer), &rRenderPassBegin, contents); }
// Chapter 9: Shaders
Result CreateShaderModule(const VkShaderModuleCreateInfo &rCreateInfo, VkShaderModule &rShaderModule) const
- { return { vkCreateShaderModule(device, &rCreateInfo, 0, handle_cast<::VkShaderModule *>(&rShaderModule)), "vkCreateShaderModule" }; }
+ { return { vkCreateShaderModule(device, &rCreateInfo, nullptr, handle_cast<::VkShaderModule *>(&rShaderModule)), "vkCreateShaderModule" }; }
void DestroyShaderModule(VkShaderModule shaderModule) const
- { vkDestroyShaderModule(device, handle_cast<::VkShaderModule>(shaderModule), 0); }
+ { vkDestroyShaderModule(device, handle_cast<::VkShaderModule>(shaderModule), nullptr); }
// Chapter 10: Pipelines
Result CreateComputePipelines(VkPipelineCache pipelineCache, std::uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, VkPipeline *pPipelines) const
- { return { vkCreateComputePipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, 0, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateComputePipelines" }; }
+ { return { vkCreateComputePipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, nullptr, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateComputePipelines" }; }
Result CreateGraphicsPipelines(VkPipelineCache pipelineCache, std::uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, VkPipeline *pPipelines) const
- { return { vkCreateGraphicsPipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, 0, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateGraphicsPipelines" }; }
+ { return { vkCreateGraphicsPipelines(device, handle_cast<::VkPipelineCache>(pipelineCache), createInfoCount, pCreateInfos, nullptr, handle_cast<::VkPipeline *>(pPipelines)), "vkCreateGraphicsPipelines" }; }
void DestroyPipeline(VkPipeline pipeline) const
- { vkDestroyPipeline(device, handle_cast<::VkPipeline>(pipeline), 0); }
+ { vkDestroyPipeline(device, handle_cast<::VkPipeline>(pipeline), nullptr); }
void CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) const
{ vkCmdBindPipeline(handle_cast<::VkCommandBuffer>(commandBuffer), pipelineBindPoint, handle_cast<::VkPipeline>(pipeline)); }
{ vkGetPhysicalDeviceMemoryProperties(physicalDevice, &rMemoryProperties); }
Result AllocateMemory(const VkMemoryAllocateInfo &rAllocateInfo, VkDeviceMemory &rMemory) const
- { return { vkAllocateMemory(device, &rAllocateInfo, 0, handle_cast<::VkDeviceMemory *>(&rMemory)), "vkAllocateMemory" }; }
+ { return { vkAllocateMemory(device, &rAllocateInfo, nullptr, handle_cast<::VkDeviceMemory *>(&rMemory)), "vkAllocateMemory" }; }
Result MapMemory(VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData) const
{ return { vkMapMemory(device, handle_cast<::VkDeviceMemory>(memory), offset, size, flags, ppData), "vkMapMemory" }; }
{ vkUnmapMemory(device, handle_cast<::VkDeviceMemory>(memory)); }
void FreeMemory(VkDeviceMemory memory) const
- { vkFreeMemory(device, handle_cast<::VkDeviceMemory>(memory), 0); }
+ { vkFreeMemory(device, handle_cast<::VkDeviceMemory>(memory), nullptr); }
// Chapter 12: Resource Creation
Result CreateBuffer(const VkBufferCreateInfo &rCreateInfo, VkBuffer &rBuffer) const
- { return { vkCreateBuffer(device, &rCreateInfo, 0, handle_cast<::VkBuffer *>(&rBuffer)), "vkCreateBuffer" }; }
+ { return { vkCreateBuffer(device, &rCreateInfo, nullptr, handle_cast<::VkBuffer *>(&rBuffer)), "vkCreateBuffer" }; }
void DestroyBuffer(VkBuffer image) const
- { vkDestroyBuffer(device, handle_cast<::VkBuffer>(image), 0); }
+ { vkDestroyBuffer(device, handle_cast<::VkBuffer>(image), nullptr); }
Result CreateImage(const VkImageCreateInfo &rCreateInfo, VkImage &rImage) const
- { return { vkCreateImage(device, &rCreateInfo, 0, handle_cast<::VkImage *>(&rImage)), "vkCreateImage" }; }
+ { return { vkCreateImage(device, &rCreateInfo, nullptr, handle_cast<::VkImage *>(&rImage)), "vkCreateImage" }; }
void DestroyImage(VkImage image) const
- { vkDestroyImage(device, handle_cast<::VkImage>(image), 0); }
+ { vkDestroyImage(device, handle_cast<::VkImage>(image), nullptr); }
Result CreateImageView(const VkImageViewCreateInfo &rCreateInfo, VkImageView &rView) const
- { return { vkCreateImageView(device, &rCreateInfo, 0, handle_cast<::VkImageView *>(&rView)), "vkCreateImageView" }; }
+ { return { vkCreateImageView(device, &rCreateInfo, nullptr, handle_cast<::VkImageView *>(&rView)), "vkCreateImageView" }; }
void DestroyImageView(VkImageView imageView) const
- { vkDestroyImageView(device, handle_cast<::VkImageView>(imageView), 0); }
+ { vkDestroyImageView(device, handle_cast<::VkImageView>(imageView), nullptr); }
void GetBufferMemoryRequirements(VkBuffer image, VkMemoryRequirements &rMemoryRequirements) const
{ vkGetBufferMemoryRequirements(device, handle_cast<::VkBuffer>(image), &rMemoryRequirements); }
// Chapter 13: Samplers
Result CreateSampler(const VkSamplerCreateInfo &rCreateInfo, VkSampler &rSampler) const
- { return { vkCreateSampler(device, &rCreateInfo, 0, handle_cast<::VkSampler *>(&rSampler)), "vkCreateSampler" }; }
+ { return { vkCreateSampler(device, &rCreateInfo, nullptr, handle_cast<::VkSampler *>(&rSampler)), "vkCreateSampler" }; }
void DestroySampler(VkSampler sampler) const
- { vkDestroySampler(device, handle_cast<::VkSampler>(sampler), 0); }
+ { vkDestroySampler(device, handle_cast<::VkSampler>(sampler), nullptr); }
// Chapter 14: Resource Descriptors
Result CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo &rCreateInfo, VkDescriptorSetLayout &rSetLayout) const
- { return { vkCreateDescriptorSetLayout(device, &rCreateInfo, 0, handle_cast<::VkDescriptorSetLayout *>(&rSetLayout)), "vkCreateDescriptorSetLayout" }; }
+ { return { vkCreateDescriptorSetLayout(device, &rCreateInfo, nullptr, handle_cast<::VkDescriptorSetLayout *>(&rSetLayout)), "vkCreateDescriptorSetLayout" }; }
void DestroyDescriptorSetLayout(VkDescriptorSetLayout descriptorSetLayout) const
- { vkDestroyDescriptorSetLayout(device, handle_cast<::VkDescriptorSetLayout>(descriptorSetLayout), 0); }
+ { vkDestroyDescriptorSetLayout(device, handle_cast<::VkDescriptorSetLayout>(descriptorSetLayout), nullptr); }
Result CreatePipelineLayout(const VkPipelineLayoutCreateInfo &rCreateInfo, VkPipelineLayout &rPipelineLayout) const
- { return { vkCreatePipelineLayout(device, &rCreateInfo, 0, handle_cast<::VkPipelineLayout *>(&rPipelineLayout)), "vkCreatePipelineLayout" }; }
+ { return { vkCreatePipelineLayout(device, &rCreateInfo, nullptr, handle_cast<::VkPipelineLayout *>(&rPipelineLayout)), "vkCreatePipelineLayout" }; }
void DestroyPipelineLayout(VkPipelineLayout pipelineLayout) const
- { vkDestroyPipelineLayout(device, handle_cast<::VkPipelineLayout>(pipelineLayout), 0); }
+ { vkDestroyPipelineLayout(device, handle_cast<::VkPipelineLayout>(pipelineLayout), nullptr); }
Result CreateDescriptorPool(const VkDescriptorPoolCreateInfo &rCreateInfo, VkDescriptorPool &rDescriptorPool) const
- { return { vkCreateDescriptorPool(device, &rCreateInfo, 0, handle_cast<::VkDescriptorPool *>(&rDescriptorPool)), "vkCreateDescriptorPool" }; }
+ { return { vkCreateDescriptorPool(device, &rCreateInfo, nullptr, handle_cast<::VkDescriptorPool *>(&rDescriptorPool)), "vkCreateDescriptorPool" }; }
void DestroyDescriptorPool(VkDescriptorPool descriptorPool) const
- { vkDestroyDescriptorPool(device, handle_cast<::VkDescriptorPool>(descriptorPool), 0); }
+ { vkDestroyDescriptorPool(device, handle_cast<::VkDescriptorPool>(descriptorPool), nullptr); }
Result AllocateDescriptorSets(const VkDescriptorSetAllocateInfo &rAllocateInfo, VkDescriptorSet *pDescriptorSets) const
{ return { vkAllocateDescriptorSets(device, &rAllocateInfo, handle_cast<::VkDescriptorSet *>(pDescriptorSets)), "vkAllocateDescriptorSets" }; }
{ return { vkGetPhysicalDeviceSurfacePresentModes(physicalDevice, handle_cast<::VkSurfaceKHR>(surface), &rPresentModeCount, pPresentModes), "vkGetPhysicalDeviceSurfacePresentModes" }; }
Result CreateSwapchain(const VkSwapchainCreateInfoKHR &rCreateInfo, VkSwapchain &rSwapchain) const
- { return { vkCreateSwapchain(device, &rCreateInfo, 0, handle_cast<::VkSwapchainKHR *>(&rSwapchain)), "vkCreateSwapchain" }; }
+ { return { vkCreateSwapchain(device, &rCreateInfo, nullptr, handle_cast<::VkSwapchainKHR *>(&rSwapchain)), "vkCreateSwapchain" }; }
void DestroySwapchain(VkSwapchain swapchain) const
- { vkDestroySwapchain(device, handle_cast<::VkSwapchainKHR>(swapchain), 0); }
+ { vkDestroySwapchain(device, handle_cast<::VkSwapchainKHR>(swapchain), nullptr); }
void GetSwapchainImages(VkSwapchain swapchain, std::uint32_t &rSwapchainImageCount, VkImage *pSwapchainImages) const
{ vkGetSwapchainImages(device, handle_cast<::VkSwapchainKHR>(swapchain), &rSwapchainImageCount, handle_cast<::VkImage *>(pSwapchainImages)); }
class MSPGL_API VulkanWindowView: public View
{
protected:
- SwapChain *swap_chain = 0;
+ SwapChain *swap_chain = nullptr;
std::vector<Framebuffer> framebuffers;
- Framebuffer *current_target = 0;
+ Framebuffer *current_target = nullptr;
Semaphore semaphores[MAX_FRAMES_IN_FLIGHT*2];
unsigned frame_index = 0;
typedef std::map<CodePair, float> KerningMap;
typedef std::map<CodePair, unsigned> LigatureMap;
- const Texture2D *texture = 0;
+ const Texture2D *texture = nullptr;
float native_size = 1.0f;
float ascent = 1.0f;
float descent = 0.0f;
MeshBuilder::MeshBuilder(Mesh &m):
PrimitiveBuilder(m.vertices),
mesh(m),
- batch(0)
+ batch(nullptr)
{ }
MeshBuilder::~MeshBuilder()
{
mesh.add_batch(move(*batch));
delete batch;
- batch = 0;
+ batch = nullptr;
}
void MeshBuilder::element_(unsigned i)
renderables[r.slot_name] = r.renderable;
for(const SequenceTemplate::PostProcessor &p: tmpl.get_postprocessors())
if(!p.slot_name.empty())
- postprocessors[p.slot_name] = 0;
+ postprocessors[p.slot_name] = nullptr;
}
void SequenceBuilder::set_renderable(const string &name, Renderable &rend)
#endif
for(const SequenceTemplate::PostProcessor &p: tmpl.get_postprocessors())
{
- PostProcessor *proc = 0;
+ PostProcessor *proc = nullptr;
if(!p.slot_name.empty())
proc = get_item(postprocessors, p.slot_name);
if(!proc)
struct Renderable
{
- Effect::Template *effect_template = 0;
- GL::Renderable *renderable = 0;
- SequenceTemplate *sequence_template = 0;
+ Effect::Template *effect_template = nullptr;
+ GL::Renderable *renderable = nullptr;
+ SequenceTemplate *sequence_template = nullptr;
std::map<std::string, std::string> sequence_renderables;
std::string slot_name;
};
};
std::string tag;
- const Lighting *lighting = 0;
+ const Lighting *lighting = nullptr;
DepthTest depth_test;
StencilTest stencil_test;
std::string renderable_name;
GL::PostProcessor::Template *postprocessor_template;
std::string slot_name;
- PostProcessor(GL::PostProcessor::Template * = 0);
+ PostProcessor(GL::PostProcessor::Template * = nullptr);
};
private:
buffer(&b),
offset(o),
size(s),
- dest_addr(0)
+ dest_addr(nullptr)
{
allocate();
}
size(other.size),
dest_addr(other.dest_addr)
{
- other.dest_addr = 0;
+ other.dest_addr = nullptr;
}
Buffer::AsyncTransfer &Buffer::AsyncTransfer::operator=(AsyncTransfer &&other)
size = other.size;
dest_addr = other.dest_addr;
- other.dest_addr = 0;
+ other.dest_addr = nullptr;
return *this;
}
friend class Buffer;
private:
- Buffer *buffer = 0;
+ Buffer *buffer = nullptr;
std::size_t offset = 0;
std::size_t size = 0;
- void *dest_addr = 0;
+ void *dest_addr = nullptr;
AsyncTransfer(Buffer &, std::size_t, std::size_t);
public:
location_dirty(other.location_dirty),
dirty(other.dirty)
{
- other.buffer = 0;
- other.next_in_buffer = 0;
- other.prev_in_buffer = 0;
+ other.buffer = nullptr;
+ other.next_in_buffer = nullptr;
+ other.prev_in_buffer = nullptr;
if(next_in_buffer)
next_in_buffer->prev_in_buffer = this;
if(prev_in_buffer)
next_in_buffer->prev_in_buffer = prev_in_buffer;
next_in_buffer->update_offset();
}
- prev_in_buffer = 0;
- next_in_buffer = 0;
- buffer = 0;
+ prev_in_buffer = nullptr;
+ next_in_buffer = nullptr;
+ buffer = nullptr;
offset = 0;
}
};
private:
- Buffer *buffer = 0;
+ Buffer *buffer = nullptr;
std::size_t offset = 0;
- Bufferable *next_in_buffer = 0;
- Bufferable *prev_in_buffer = 0;
+ Bufferable *next_in_buffer = nullptr;
+ Bufferable *prev_in_buffer = nullptr;
mutable bool location_dirty = false;
mutable uint8_t dirty = 0;
buffer, and this object is inserted after it.
Data is not uploaded immediately, but only when refresh() is called. */
- void use_buffer(Buffer *, Bufferable *prev = 0);
+ void use_buffer(Buffer *, Bufferable *prev = nullptr);
/** Sets the buffer for the entire chain of objects. */
void change_buffer(Buffer *);
std::size_t get_required_buffer_size(bool = false) const;
/** Uploads new data into the buffer if necessary. */
- void refresh(unsigned f) const { if(dirty) upload_data(f, 0); }
+ void refresh(unsigned f) const { if(dirty) upload_data(f, nullptr); }
/** Returns an object which can be used to upload data to the buffer using
mapped memory. If data is not dirty, returns null. */
- AsyncUpdater *refresh_async() const { return dirty ? create_async_updater() : 0; }
+ AsyncUpdater *refresh_async() const { return dirty ? create_async_updater() : nullptr; }
private:
void unlink_from_buffer();
namespace Msp {
namespace GL {
-Device *Device::current = 0;
+Device *Device::current = nullptr;
Device::Device(Graphics::Window &w):
Device(w, create_default_options())
Device::~Device()
{
if(this==current)
- current = 0;
+ current = nullptr;
}
Device &Device::get_current()
void Framebuffer::attach(FrameAttachment attch, Texture2D &tex, unsigned level)
{
- set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, 0, 0);
+ set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, 0, 0);
}
void Framebuffer::attach(FrameAttachment attch, Texture2DMultisample &tex, Texture2D *res)
void Framebuffer::attach(FrameAttachment attch, Texture3D &tex, unsigned layer, unsigned level)
{
- set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, layer, 0);
+ set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, layer, 0);
}
void Framebuffer::attach(FrameAttachment attch, TextureCube &tex, TextureCubeFace face, unsigned level)
{
- set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, face, 0);
+ set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, face, 0);
}
void Framebuffer::attach_layered(FrameAttachment attch, Texture3D &tex, unsigned level)
{
require_layered();
- set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, -1, 0);
+ set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, -1, 0);
}
void Framebuffer::attach_layered(FrameAttachment attch, TextureCube &tex, unsigned level)
{
require_layered();
- set_attachment(make_typed_attachment(attch, tex.get_format()), tex, 0, level, -1, 0);
+ set_attachment(make_typed_attachment(attch, tex.get_format()), tex, nullptr, level, -1, 0);
}
void Framebuffer::detach(FrameAttachment attch)
const Texture *Framebuffer::get_attachment(FrameAttachment attch) const
{
if(attachments.empty())
- return 0;
+ return nullptr;
int i = format.index(attch);
- return (i>=0 ? attachments[i].tex : 0);
+ return (i>=0 ? attachments[i].tex : nullptr);
}
const Texture *Framebuffer::get_attachment(unsigned i) const
{
- return (i<attachments.size() ? attachments[i].tex : 0);
+ return (i<attachments.size() ? attachments[i].tex : nullptr);
}
const Texture *Framebuffer::get_resolve_attachment(FrameAttachment attch) const
{
if(attachments.empty())
- return 0;
+ return nullptr;
int i = format.index(attch);
- return (i>=0 ? attachments[i].resolve : 0);
+ return (i>=0 ? attachments[i].resolve : nullptr);
}
const Texture *Framebuffer::get_resolve_attachment(unsigned i) const
{
- return (i<attachments.size() ? attachments[i].resolve : 0);
+ return (i<attachments.size() ? attachments[i].resolve : nullptr);
}
bool Framebuffer::has_resolve_attachments() const
void Framebuffer::Attachment::clear()
{
- tex = 0;
+ tex = nullptr;
}
} // namespace GL
protected:
struct Attachment
{
- Texture *tex = 0;
- Texture *resolve = 0;
+ Texture *tex = nullptr;
+ Texture *resolve = nullptr;
unsigned level = 0;
int layer = 0;
face_winding(other.face_winding),
debug_name(move(other.debug_name))
{
- other.vbuf = 0;
- other.ibuf = 0;
+ other.vbuf = nullptr;
+ other.ibuf = nullptr;
}
Mesh::~Mesh()
{
- set_manager(0);
+ set_manager(nullptr);
batches.clear();
delete vbuf;
delete ibuf;
if(reallocate)
{
for(auto i=batches.end(); i!=batches.begin(); )
- (--i)->use_buffer(0);
+ (--i)->use_buffer(nullptr);
}
Batch *prev = &batches.back();
batches.emplace_back(move(b));
if(reallocate)
{
- prev = 0;
+ prev = nullptr;
for(Batch &a: batches)
{
a.use_buffer(ibuf, prev);
void Mesh::draw(Renderer &renderer) const
{
- draw(renderer, 0, 0);
+ draw(renderer, nullptr, 0);
}
void Mesh::draw_instanced(Renderer &renderer, const VertexSetup &vs, unsigned count) const
void Mesh::unload()
{
vertices.clear();
- vertices.use_buffer(0);
+ vertices.use_buffer(nullptr);
batches.clear();
vtx_setup.unload();
delete vbuf;
delete ibuf;
- vbuf = 0;
- ibuf = 0;
+ vbuf = nullptr;
+ ibuf = nullptr;
}
void Mesh::set_debug_name(const string &name)
else if(phase==3)
{
delete vertex_updater;
- vertex_updater = 0;
+ vertex_updater = nullptr;
delete index_updater;
- index_updater = 0;
+ index_updater = nullptr;
}
++phase;
private:
Mesh &mesh;
IO::Seekable &io;
- Bufferable::AsyncUpdater *vertex_updater = 0;
- Bufferable::AsyncUpdater *index_updater = 0;
+ Bufferable::AsyncUpdater *vertex_updater = nullptr;
+ Bufferable::AsyncUpdater *index_updater = nullptr;
unsigned phase = 0;
public:
VertexArray vertices;
std::vector<Batch> batches;
- Buffer *vbuf = 0;
- Buffer *ibuf = 0;
+ Buffer *vbuf = nullptr;
+ Buffer *ibuf = nullptr;
VertexSetup vtx_setup;
mutable unsigned short dirty = 0;
bool disallow_rendering = false;
public:
virtual int get_load_priority() const { return 1; }
- virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
+ virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = nullptr);
virtual std::uint64_t get_data_size() const;
virtual void unload();
void Module::load_source(IO::Base &io, const string &name)
{
- load_source(io, 0, name);
+ load_source(io, nullptr, name);
}
SL::Features Module::create_features() const
if(m.struct_type)
{
auto i = struct_indices.find(m.struct_type);
- m.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0);
+ m.struct_type = (i!=struct_indices.end() ? &structs[i->second] : nullptr);
}
const StructMember *last_member = &s.members.back();
if(v.struct_type)
{
auto i = struct_indices.find(v.struct_type);
- v.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0);
+ v.struct_type = (i!=struct_indices.end() ? &structs[i->second] : nullptr);
}
entry_points.reserve(reflection.entry_points.size());
for(const Variable *&v: entry.globals)
{
auto i = var_indices.find(v);
- v = (i!=var_indices.end() ? &variables[i->second] : 0);
+ v = (i!=var_indices.end() ? &variables[i->second] : nullptr);
}
}
for(InstructionBlock &b: blocks)
{
auto i = spec_indices.find(b.condition);
- b.condition = (i!=spec_indices.end() ? &spec_constants[i->second] : 0);
+ b.condition = (i!=spec_indices.end() ? &spec_constants[i->second] : nullptr);
if(b.condition)
specializable = true;
for(const Variable *&v: b.accessed_variables)
{
auto j = var_indices.find(v);
- v = (j!=var_indices.end() ? &variables[j->second] : 0);
+ v = (j!=var_indices.end() ? &variables[j->second] : nullptr);
}
for(const InstructionBlock *&s: b.successors)
{
auto j = block_indices.find(s);
- s = (j!=block_indices.end() ? &blocks[j->second] : 0);
+ s = (j!=block_indices.end() ? &blocks[j->second] : nullptr);
}
}
}
{
std::string name;
DataType type = VOID;
- const Structure *struct_type = 0;
+ const Structure *struct_type = nullptr;
unsigned offset = 0;
unsigned array_size = 0;
unsigned array_stride = 0;
std::string name;
unsigned id = 0;
DataType type = VOID;
- const Structure *struct_type = 0;
+ const Structure *struct_type = nullptr;
StorageClass storage = static_cast<StorageClass>(-1);
unsigned array_size = 0;
int location = -1;
{
unsigned id = 0;
bool negate_condition = false;
- const Constant *condition = 0;
+ const Constant *condition = nullptr;
std::vector<const Variable *> accessed_variables;
std::vector<const InstructionBlock *> successors;
};
struct TypeInfo
{
DataType type = VOID;
- const Structure *struct_type = 0;
+ const Structure *struct_type = nullptr;
unsigned array_size = 0;
unsigned array_stride = 0;
StorageClass storage = static_cast<StorageClass>(-1);
std::map<unsigned, InstructionBlock> blocks;
std::map<unsigned, unsigned> access_chain_bases;
Constant true_condition;
- InstructionBlock *current_block = 0;
+ InstructionBlock *current_block = nullptr;
static std::uint32_t get_opcode(std::uint32_t);
static CodeIterator get_op_end(const CodeIterator &);
void PipelineState::reset()
{
- set(framebuffer, static_cast<const Framebuffer *>(0), FRAMEBUFFER);
+ set(framebuffer, static_cast<const Framebuffer *>(nullptr), FRAMEBUFFER);
set(viewport, Rect::max(), VIEWPORT);
set(scissor, Rect::max(), SCISSOR);
- set(shprog, static_cast<const Program *>(0), SHPROG);
+ set(shprog, static_cast<const Program *>(nullptr), SHPROG);
for(BoundResource &r: resources)
{
r.changed = (r.type!=NO_RESOURCE);
r.type = NO_RESOURCE;
r.used = false;
- r.block = 0;
- r.buffer = 0;
+ r.block = nullptr;
+ r.buffer = nullptr;
}
- set(vertex_setup, static_cast<const VertexSetup *>(0), VERTEX_SETUP);
+ set(vertex_setup, static_cast<const VertexSetup *>(nullptr), VERTEX_SETUP);
set(primitive_type, TRIANGLES, PRIMITIVE_TYPE);
set(patch_size, 0U, PATCH_SIZE);
set(front_face, COUNTERCLOCKWISE, FACE_CULL);
i = resources.insert(i, BoundResource(binding));
ResourceType type = (block ? UNIFORM_BLOCK : NO_RESOURCE);
- const Buffer *buffer = (block ? block->get_buffer() : 0);
+ const Buffer *buffer = (block ? block->get_buffer() : nullptr);
if(i->type!=type || block!=i->block || buffer!=i->buffer || binding<0)
{
i->type = type;
void PipelineState::set_storage_block(unsigned binding, const Buffer *buffer)
{
- set_buffer_resource(binding, 0, buffer);
+ set_buffer_resource(binding, nullptr, buffer);
}
void PipelineState::set_texture(unsigned binding, const Texture *tex, const Sampler *samp)
void PipelineState::set_texture(unsigned binding, const Texture *tex, int level, const Sampler *samp)
{
- if((tex!=0)!=(samp!=0))
+ if((tex!=nullptr)!=(samp!=nullptr))
throw invalid_argument("PipelineState::set_texture");
if(level>=0 && !can_bind_tex_level(level))
throw invalid_operation("PipelineState::set_texture");
void PipelineState::set_storage_texture(unsigned binding, const Texture *tex)
{
- set_texture_resource(binding, tex, 0, 0);
+ set_texture_resource(binding, tex, 0, nullptr);
}
void PipelineState::set_buffer_resource(unsigned binding, const UniformBlock *block, const Buffer *buffer)
};
int mip_level = -1;
- BoundResource(int b): binding(b), texture(0), sampler(0) { }
+ BoundResource(int b): binding(b), texture(nullptr), sampler(nullptr) { }
};
enum ChangeMask
PATCH_SIZE = 4096
};
- const Framebuffer *framebuffer = 0;
+ const Framebuffer *framebuffer = nullptr;
Rect viewport = Rect::max();
Rect scissor = Rect::max();
- const Program *shprog = 0;
+ const Program *shprog = nullptr;
std::vector<BoundResource> resources;
- const VertexSetup *vertex_setup = 0;
+ const VertexSetup *vertex_setup = nullptr;
PrimitiveType primitive_type = TRIANGLES;
unsigned patch_size = 0;
FaceWinding front_face = COUNTERCLOCKWISE;
reflect_data(move(other.reflect_data)),
specialized_spirv(other.specialized_spirv)
{
- other.specialized_spirv = 0;
+ other.specialized_spirv = nullptr;
}
Program::~Program()
};
ReflectData reflect_data;
- SpirVModule *specialized_spirv = 0;
+ SpirVModule *specialized_spirv = nullptr;
public:
/// Constructs an empty Program with no shader stages attached.
struct UniformInfo
{
std::string name;
- const BlockInfo *block = 0;
+ const BlockInfo *block = nullptr;
union
{
int location = -1;
void Texture::Loader::image_data(const string &data)
{
if(obj.manager)
- obj.set_manager(0);
+ obj.set_manager(nullptr);
Graphics::Image img;
IO::Memory mem(data.data(), data.size());
void Texture::Loader::raw_data(const string &data)
{
if(obj.manager)
- obj.set_manager(0);
+ obj.set_manager(nullptr);
obj.image(0, data.data());
}
unsigned levels;
public:
- Loader(Texture &t): Loader(t, 0) { }
+ Loader(Texture &t): Loader(t, nullptr) { }
Loader(Texture &t, Collection &c): Loader(t, &c) { }
private:
Loader(Texture &, Collection *);
IO::Seekable &io;
Texture2D::AsyncTransfer transfer;
Graphics::Image image;
- Graphics::ImageLoader *img_loader = 0;
- DataFile::RawData *raw_data = 0;
+ Graphics::ImageLoader *img_loader = nullptr;
+ DataFile::RawData *raw_data = nullptr;
unsigned n_bytes = 0;
int phase = 0;
Texture2D::~Texture2D()
{
- set_manager(0);
+ set_manager(nullptr);
}
void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv)
width(wd),
height(ht),
data_size(width*height*get_pixel_size(texture->storage_fmt)),
- dest_addr(0)
+ dest_addr(nullptr)
{
dest_addr = allocate();
}
data_size(other.data_size),
dest_addr(other.dest_addr)
{
- other.dest_addr = 0;
+ other.dest_addr = nullptr;
}
Texture2D::AsyncTransfer &Texture2D::AsyncTransfer::operator=(AsyncTransfer &&other)
data_size = other.data_size;
dest_addr = other.dest_addr;
- other.dest_addr = 0;
+ other.dest_addr = nullptr;
return *this;
}
friend class Texture2DBackend::AsyncTransfer;
private:
- Texture2D *texture = 0;
+ Texture2D *texture = nullptr;
unsigned level = 0;
unsigned x = 0;
unsigned y = 0;
unsigned width = 0;
unsigned height = 0;
std::size_t data_size = 0;
- void *dest_addr = 0;
+ void *dest_addr = nullptr;
AsyncTransfer(Texture2D &, unsigned, unsigned, unsigned, unsigned, unsigned);
public:
LinAl::Vector<unsigned, 2> get_level_size(unsigned) const;
public:
- virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
+ virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = nullptr);
};
} // namespace GL
{
VertexSetupBackend::unload();
- vertex_array = 0;
+ vertex_array = nullptr;
vertex_format = VertexFormat();
- inst_array = 0;
+ inst_array = nullptr;
inst_format = VertexFormat();
- index_buffer = 0;
+ index_buffer = nullptr;
}
} // namespace GL
};
mutable unsigned dirty = 0;
- const VertexArray *vertex_array = 0;
+ const VertexArray *vertex_array = nullptr;
VertexFormat vertex_format;
- const VertexArray *inst_array = 0;
+ const VertexArray *inst_array = nullptr;
VertexFormat inst_format;
- const Buffer *index_buffer = 0;
+ const Buffer *index_buffer = nullptr;
DataType index_type = UNSIGNED_SHORT;
public:
renderer.set_pipeline_key(this);
renderer.set_framebuffer(&occlude_target.get_framebuffer());
- renderer.clear(0);
+ renderer.clear(nullptr);
quad.draw(renderer);
renderer.set_pipeline_key(this, 1);
renderer.set_framebuffer(out_fbo);
- renderer.clear(0);
+ renderer.clear(nullptr);
renderer.set_shader_program(&combine_shader);
quad.draw(renderer);
}
Renderer::Push push2(renderer);
renderer.set_pipeline_key(this, i);
renderer.set_framebuffer(&target[i]->get_framebuffer());
- renderer.clear(0);
+ renderer.clear(nullptr);
renderer.set_texture("source", (i ? &target[0]->get_target_texture(COLOR_ATTACHMENT) : &src), &nearest_sampler);
renderer.add_shader_data(blur_shdata[i]);
quad.draw(renderer);
}
renderer.set_pipeline_key(this, 2);
- renderer.clear(0);
+ renderer.clear(nullptr);
renderer.set_texture("source", &src, &nearest_sampler);
renderer.set_texture("blurred", &target[1]->get_target_texture(COLOR_ATTACHMENT), &linear_sampler);
renderer.set_shader_program(&combine_shader);
{
Renderer::Push push(renderer);
renderer.set_pipeline_key(this);
- renderer.clear(0);
+ renderer.clear(nullptr);
renderer.set_shader_program(&shprog, &shdata);
renderer.set_texture("source", &color_buf, &nearest_sampler);
renderer.set_texture("curve", &curve, &linear_sampler);
}
ShadowMap::ShadowMap(unsigned s, Renderable &c, const DirectionalLight &l, Renderable &sc):
- ShadowMap(s, s, c, 0)
+ ShadowMap(s, s, c, nullptr)
{
add_light(l, s, sc);
}
virtual void init_actions();
};
- const Light *light = 0;
+ const Light *light = nullptr;
unsigned size;
std::string shadow_caster_name;
};
unsigned width = 2048;
unsigned height = 2048;
- const Lighting *lighting = 0;
+ const Lighting *lighting = nullptr;
std::vector<ShadowedLight> lights;
Vector3 target;
float radius = 1.0f;
virtual void init_actions();
};
- DirectionalLight *sun = 0;
+ DirectionalLight *sun = nullptr;
virtual Sky *create(const std::map<std::string, Renderable *> &) const;
};
RefPtr<IO::Seekable> io = Resources::get_builtins().open("_builtin.glsl");
if(!io)
- return 0;
+ return nullptr;
builtins_module = new Module;
add_builtin_type(builtins_module->shared, "void", BasicTypeDeclaration::VOID, 0, true);
try
{
- Parser parser(0);
+ Parser parser(nullptr);
parser.parse(*builtins_module, *io, "<builtin>", BUILTIN_SOURCE);
}
catch(...)
{
- builtins_module = 0;
+ builtins_module = nullptr;
throw;
}
}
{
Module *module = get_builtins_module();
if(!module)
- return 0;
+ return nullptr;
if(type==Stage::SHARED)
return &module->shared;
auto i = find_member(module->stages, type, &Stage::type);
- return (i!=module->stages.end() ? &*i : 0);
+ return (i!=module->stages.end() ? &*i : nullptr);
}
} // namespace SL
{
clear();
imported_names.push_back(src_name);
- ModuleCache mod_cache(0);
+ ModuleCache mod_cache(nullptr);
append_module(mod_cache.add_module(source, src_name), mod_cache);
}
void Compiler::load_source(IO::Base &io, const string &src_name)
{
- load_source(io, 0, src_name);
+ load_source(io, nullptr, src_name);
}
void Compiler::specialize(const map<string, int> &sv)
++i;
}
- Stage *prev_stage = 0;
+ Stage *prev_stage = nullptr;
for(auto i=module->stages.begin(); i!=module->stages.end(); )
{
if(i->functions.empty())
void Compiler::append_stage(const Stage &stage)
{
- Stage *target = 0;
+ Stage *target = nullptr;
if(stage.type==Stage::SHARED)
target = &module->shared;
else
};
Features features;
- Module *module = 0;
+ Module *module = nullptr;
std::vector<std::string> imported_names;
bool compiled = false;
bool specialized = false;
/** Loads source code from an I/O object. If a collection is used, imports
can be fetched from it. */
- void load_source(IO::Base &, DataFile::Collection * = 0, const std::string & = "<file>");
+ void load_source(IO::Base &, DataFile::Collection * = nullptr, const std::string & = "<file>");
/** Loads source code from an I/O object. Only builtin imports are
available. */
std::string text;
Node *node;
- Branch(const char *t, Node *n = 0): text(t), node(n) { }
- Branch(const std::string &t, Node *n = 0): text(t), node(n) { }
+ Branch(const char *t, Node *n = nullptr): text(t), node(n) { }
+ Branch(const std::string &t, Node *n = nullptr): text(t), node(n) { }
Branch(Node *n): node(n) { }
};
{
if(offset>=0)
{
- int *layout_offset = 0;
+ int *layout_offset = nullptr;
bool has_matrix_order = false;
if(var.layout)
{
void StructuralFeatureConverter::visit(RefPtr<Expression> &expr)
{
- r_replaced_reference = 0;
+ r_replaced_reference = nullptr;
expr->visit(*this);
if(r_replaced_reference)
expr = r_replaced_reference;
- r_replaced_reference = 0;
+ r_replaced_reference = nullptr;
}
bool StructuralFeatureConverter::supports_stage(Stage::Type st) const
if(var.declaration==frag_out && !supports_unified_interface_syntax())
{
var.name = "gl_FragColor";
- var.declaration = 0;
+ var.declaration = nullptr;
}
r_flattened_interface = nodes_to_remove.count(var.declaration);
{
TraversingVisitor::visit(assign);
if(assign.target.declaration==frag_out && !supports_unified_interface_syntax())
- assign.target.declaration = 0;
+ assign.target.declaration = nullptr;
}
bool StructuralFeatureConverter::supports_unified_sampling_functions() const
}
if(var.layout->qualifiers.empty())
- var.layout = 0;
+ var.layout = nullptr;
else if(!check_version(Version(1, 40)))
unsupported("Layout qualifiers require GLSL 1.40");
}
class PrecisionConverter: private TraversingVisitor
{
private:
- Stage *stage = 0;
+ Stage *stage = nullptr;
std::set<std::string> have_default;
NodeList<Statement>::iterator insert_point;
std::set<Node *> nodes_to_remove;
class FeatureConverter: protected TraversingVisitor
{
protected:
- Stage *stage = 0;
+ Stage *stage = nullptr;
Features features;
FeatureConverter() = default;
class StructuralFeatureConverter: public FeatureConverter
{
private:
- VariableDeclaration *frag_out = 0;
+ VariableDeclaration *frag_out = nullptr;
NodeList<Statement>::iterator uniform_insert_point;
std::set<Node *> nodes_to_remove;
RefPtr<Expression> r_replaced_reference;
VariableDeclaration *InterfaceGenerator::generate_interface(VariableDeclaration &var, const string &iface, const string &name)
{
if(stage->content.variables.count(name))
- return 0;
+ return nullptr;
if(stage->type==Stage::GEOMETRY && var.interface=="out" && var.array)
- return 0;
+ return nullptr;
VariableDeclaration* iface_var = new VariableDeclaration;
iface_var->sampling = var.sampling;
{
/* For output variables in function scope, generate a global interface
and replace the local declaration with an assignment. */
- VariableDeclaration *out_var = 0;
+ VariableDeclaration *out_var = nullptr;
if(function_scope && (out_var=generate_interface(var, "out", var.name)))
{
out_var->source = var.source;
void ArraySizer::visit(MemberAccess &memacc)
{
- r_declaration = 0;
+ r_declaration = nullptr;
TraversingVisitor::visit(memacc);
- VariableDeclaration *member_declaration = 0;
+ VariableDeclaration *member_declaration = nullptr;
if(r_declaration)
if(StructDeclaration *strct = dynamic_cast<StructDeclaration *>(r_declaration->type_declaration))
{
void ArraySizer::visit(Swizzle &swizzle)
{
TraversingVisitor::visit(swizzle);
- r_declaration = 0;
+ r_declaration = nullptr;
}
void ArraySizer::visit(UnaryExpression &unary)
{
TraversingVisitor::visit(unary);
- r_declaration = 0;
+ r_declaration = nullptr;
}
void ArraySizer::visit(BinaryExpression &binary)
if(const Literal *literal_index = dynamic_cast<const Literal *>(binary.right.get()))
if(literal_index->value.has_type<int>())
{
- r_declaration = 0;
+ r_declaration = nullptr;
binary.left->visit(*this);
if(r_declaration)
{
void ArraySizer::visit(TernaryExpression &ternary)
{
TraversingVisitor::visit(ternary);
- r_declaration = 0;
+ r_declaration = nullptr;
}
void ArraySizer::visit(FunctionCall &call)
{
TraversingVisitor::visit(call);
- r_declaration = 0;
+ r_declaration = nullptr;
}
void ArraySizer::visit(InterfaceLayout &layout)
class InterfaceGenerator: private TraversingVisitor
{
private:
- Stage *stage = 0;
+ Stage *stage = nullptr;
std::string in_prefix;
std::string out_prefix;
bool function_scope = false;
bool copy_block = false;
std::vector<VariableDeclaration *> declared_inputs;
- Block *iface_target_block = 0;
+ Block *iface_target_block = nullptr;
NodeList<Statement>::iterator iface_insert_point;
NodeList<Statement>::iterator assignment_insert_point;
std::set<Node *> nodes_to_remove;
class LayoutDefaulter: private TraversingVisitor
{
private:
- InterfaceLayout *in_iface = 0;
+ InterfaceLayout *in_iface = nullptr;
bool need_winding = true;
bool need_spacing = true;
specializable = true;
qualifiers.erase(i);
if(qualifiers.empty())
- var.layout = 0;
+ var.layout = nullptr;
}
}
for(const RefPtr<Statement> &s: source_func->body.body)
{
- r_inlined_statement = 0;
+ r_inlined_statement = nullptr;
s->visit(*this);
if(!r_inlined_statement)
r_inlined_statement = s->clone();
void FunctionInliner::visit(RefPtr<Expression> &ptr)
{
- r_inline_result = 0;
+ r_inline_result = nullptr;
ptr->visit(*this);
if(r_inline_result)
{
ptr = r_inline_result;
r_any_inlined = true;
}
- r_inline_result = 0;
+ r_inline_result = nullptr;
}
void FunctionInliner::visit(Block &block)
void ExpressionInliner::visit(RefPtr<Expression> &expr)
{
- r_ref_info = 0;
+ r_ref_info = nullptr;
expr->visit(*this);
if(r_ref_info && r_ref_info->expression)
{
r_ref_info->uses.push_back(use);
}
r_oper = expr->oper;
- r_ref_info = 0;
+ r_ref_info = nullptr;
}
void ExpressionInliner::visit(VariableReference &var)
SetFlag set_write(access_write);
visit(assign.left);
}
- r_oper = 0;
+ r_oper = nullptr;
r_trivial = true;
visit(assign.right);
void ExpressionInliner::visit(VariableDeclaration &var)
{
- r_oper = 0;
+ r_oper = nullptr;
r_trivial = true;
TraversingVisitor::visit(var);
void AggregateDismantler::visit(RefPtr<Expression> &expr)
{
- r_aggregate_ref = 0;
+ r_aggregate_ref = nullptr;
expr->visit(*this);
if(r_aggregate_ref && r_reference.chain_len==1)
{
referenced. */
r_aggregate_ref->referenced = true;
}
- r_aggregate_ref = 0;
+ r_aggregate_ref = nullptr;
}
void AggregateDismantler::visit(VariableReference &var)
if(r_reference.declaration && r_reference.chain_len==1)
{
auto i = aggregates.find(r_reference.declaration);
- r_aggregate_ref = (i!=aggregates.end() ? &i->second : 0);
+ r_aggregate_ref = (i!=aggregates.end() ? &i->second : nullptr);
}
else
- r_aggregate_ref = 0;
+ r_aggregate_ref = nullptr;
}
void AggregateDismantler::visit(BinaryExpression &binary)
if(r_reference.declaration && r_reference.chain_len==1)
{
auto i = aggregates.find(r_reference.declaration);
- r_aggregate_ref = (i!=aggregates.end() ? &i->second : 0);
+ r_aggregate_ref = (i!=aggregates.end() ? &i->second : nullptr);
}
else
- r_aggregate_ref = 0;
+ r_aggregate_ref = nullptr;
}
else
{
/* The iteration variable is not normally inlined into expressions, so we
process it specially here. If the initial value causes the loop condition
to evaluate to false, then the expression can be folded. */
- iteration_var = 0;
+ iteration_var = nullptr;
if(iter.init_statement)
{
SetFlag set_init(iteration_init);
iter.condition = literal;
}
}
- iteration_var = 0;
+ iteration_var = nullptr;
iter.body.visit(*this);
if(iter.loop_expression)
void ConstantConditionEliminator::visit(RefPtr<Expression> &expr)
{
- r_ternary_result = 0;
+ r_ternary_result = nullptr;
expr->visit(*this);
if(r_ternary_result)
expr = r_ternary_result;
- r_ternary_result = 0;
+ r_ternary_result = nullptr;
}
void ConstantConditionEliminator::visit(UnaryExpression &unary)
if(result!=NOT_CONSTANT)
r_ternary_result = (result==CONSTANT_TRUE ? ternary.true_expr : ternary.false_expr);
else
- r_ternary_result = 0;
+ r_ternary_result = nullptr;
}
void ConstantConditionEliminator::visit(FunctionCall &call)
void UnusedVariableRemover::visit(ExpressionStatement &expr)
{
- r_assignment = 0;
+ r_assignment = nullptr;
r_side_effects = false;
TraversingVisitor::visit(expr);
if(r_assignment && r_assignment->target.declaration)
class ConstantSpecializer: private TraversingVisitor
{
private:
- const std::map<std::string, int> *values = 0;
+ const std::map<std::string, int> *values = nullptr;
public:
void apply(Stage &, const std::map<std::string, int> &);
private:
std::map<FunctionDeclaration *, unsigned> refcounts;
std::set<FunctionDeclaration *> inlineable;
- FunctionDeclaration *current_function = 0;
+ FunctionDeclaration *current_function = nullptr;
unsigned return_count = 0;
public:
RENAME
};
- FunctionDeclaration *source_func = 0;
+ FunctionDeclaration *source_func = nullptr;
Block staging_block;
Pass pass = REFERENCED;
RefPtr<Statement> r_inlined_statement;
class FunctionInliner: private TraversingVisitor
{
private:
- Stage *stage = 0;
+ Stage *stage = nullptr;
std::set<FunctionDeclaration *> inlineable;
- FunctionDeclaration *current_function = 0;
+ FunctionDeclaration *current_function = nullptr;
NodeList<Statement>::iterator insert_point;
RefPtr<Expression> r_inline_result;
bool r_any_inlined = false;
private:
struct ExpressionUse
{
- RefPtr<Expression> *reference = 0;
- Block *ref_scope = 0;
+ RefPtr<Expression> *reference = nullptr;
+ Block *ref_scope = nullptr;
bool blocked = false;
};
{
Assignment::Target target;
RefPtr<Expression> expression;
- Block *assign_scope = 0;
+ Block *assign_scope = nullptr;
std::vector<ExpressionUse> uses;
bool trivial = false;
bool blocked = false;
std::list<ExpressionInfo> expressions;
std::map<Assignment::Target, ExpressionInfo *> assignments;
- ExpressionInfo *r_ref_info = 0;
+ ExpressionInfo *r_ref_info = nullptr;
bool r_trivial = false;
bool access_read = true;
bool access_write = false;
bool iteration_init = false;
- Block *iteration_body = 0;
- const Operator *r_oper = 0;
+ Block *iteration_body = nullptr;
+ const Operator *r_oper = nullptr;
public:
bool apply(Stage &);
private:
struct AggregateMember
{
- const VariableDeclaration *declaration = 0;
+ const VariableDeclaration *declaration = nullptr;
unsigned index = 0;
RefPtr<Expression> initializer;
std::vector<RefPtr<Expression> *> references;
struct Aggregate
{
- VariableDeclaration *declaration = 0;
- Block *decl_scope = 0;
+ VariableDeclaration *declaration = nullptr;
+ Block *decl_scope = nullptr;
NodeList<Statement>::iterator insert_point;
std::vector<AggregateMember> members;
bool referenced = false;
std::map<Statement *, Aggregate> aggregates;
bool composite_reference = false;
Assignment::Target r_reference;
- Aggregate *r_aggregate_ref = 0;
+ Aggregate *r_aggregate_ref = nullptr;
public:
bool apply(Stage &);
class ConstantFolder: private TraversingVisitor
{
private:
- VariableDeclaration *iteration_var = 0;
+ VariableDeclaration *iteration_var = nullptr;
Variant iter_init_value;
Variant r_constant_value;
bool iteration_init = false;
private:
struct AssignmentInfo
{
- Node *node = 0;
+ Node *node = nullptr;
Assignment::Target target;
std::vector<Node *> used_by;
unsigned in_loop = 0;
typedef std::map<VariableDeclaration *, VariableInfo> BlockVariableMap;
- Stage *stage = 0;
+ Stage *stage = nullptr;
BlockVariableMap variables;
std::list<AssignmentInfo> assignments;
- Assignment *r_assignment = 0;
+ Assignment *r_assignment = nullptr;
bool assignment_target = false;
bool r_side_effects = false;
bool in_struct = false;
class Formatter: private TraversingVisitor
{
private:
- Stage *stage = 0;
+ Stage *stage = nullptr;
std::string formatted;
unsigned source_index = 0;
unsigned source_line = 1;
Parser::Parser(ModuleCache *s):
mod_cache(s),
preprocessor(tokenizer),
- module(0)
+ module(nullptr)
{
tokenizer.signal_preprocess.connect(sigc::mem_fun(&preprocessor, &Preprocessor::preprocess));
preprocessor.signal_version.connect(sigc::mem_fun(this, &Parser::set_required_version));
if(next_global_declaration)
{
cur_stage->content.body.push_back(next_global_declaration);
- next_global_declaration = 0;
+ next_global_declaration = nullptr;
}
}
return parse_variable_declaration();
}
else if(token.empty())
- return 0;
+ return nullptr;
else
throw parse_error(tokenizer.get_location(), token, "a global declaration");
}
{
unsigned outer_precedence = (outer_oper ? outer_oper->precedence+(outer_oper->assoc==Operator::RIGHT_TO_LEFT) : 20);
RefPtr<Expression> left;
- VariableReference *left_var = 0;
+ VariableReference *left_var = nullptr;
while(1)
{
string token = tokenizer.peek_token();
- const Operator *oper = 0;
+ const Operator *oper = nullptr;
for(const Operator *i=Operator::operators; (!oper && i->type); ++i)
if(token==i->token && (!left || i->type!=Operator::PREFIX) && (left || i->type!=Operator::POSTFIX))
oper = i;
left = parse_ternary(left, *oper);
else
throw parse_error(tokenizer.get_location(), token, "an operator");
- left_var = 0;
+ left_var = nullptr;
}
else
{
RefPtr<Layout> parse_layout();
template<typename T>
void parse_block(Block &, bool, RefPtr<T> (Parser::*)());
- RefPtr<Expression> parse_expression(const Operator * = 0);
+ RefPtr<Expression> parse_expression(const Operator * = nullptr);
RefPtr<Literal> parse_literal();
RefPtr<BinaryExpression> parse_binary(const RefPtr<Expression> &, const Operator &);
RefPtr<TernaryExpression> parse_ternary(const RefPtr<Expression> &, const Operator &);
if(is_vector_or_matrix(type) || type.kind==BasicTypeDeclaration::ARRAY)
{
BasicTypeDeclaration *basic_base = dynamic_cast<BasicTypeDeclaration *>(type.base_type);
- return (basic_base ? get_element_type(*basic_base) : 0);
+ return (basic_base ? get_element_type(*basic_base) : nullptr);
}
else
return &type;
Node *s = second;
first = &node;
first_tag = tag;
- second = 0;
+ second = nullptr;
s->visit(*this);
}
else if(!first || tag!=first_tag)
else
{
T *f = static_cast<T *>(first);
- first = 0;
+ first = nullptr;
return f;
}
- return 0;
+ return nullptr;
}
void TypeComparer::visit(Literal &literal)
class TypeComparer: private NodeVisitor
{
private:
- Node *first = 0;
- Node *second = 0;
+ Node *first = nullptr;
+ Node *second = nullptr;
unsigned first_tag = 0;
bool r_result = false;
void TypeResolver::resolve_type(TypeDeclaration *&type, const string &name, bool array, const Layout *layout)
{
- TypeDeclaration *resolved = 0;
+ TypeDeclaration *resolved = nullptr;
auto i = stage->types.find(name);
if(i!=stage->types.end())
{
{
resolve_type(var.type_declaration, var.type, var.array, var.layout.get());
- var.block_declaration = 0;
+ var.block_declaration = nullptr;
if(StructDeclaration *strct = dynamic_cast<StructDeclaration *>(get_ultimate_base_type(var.type_declaration)))
if(!strct->block_name.empty())
{
void VariableResolver::visit(RefPtr<Expression> &expr)
{
- r_replacement_expr = 0;
+ r_replacement_expr = nullptr;
expr->visit(*this);
if(r_replacement_expr)
{
expr = r_replacement_expr;
/* Don't record assignment target when doing a replacement, because chain
information won't be correct. */
- r_assignment_target.declaration = 0;
+ r_assignment_target.declaration = nullptr;
r_any_resolved = true;
}
- r_replacement_expr = 0;
+ r_replacement_expr = nullptr;
}
void VariableResolver::check_assignment_target(VariableDeclaration *declaration)
/* More than one reference found in assignment target. Unable to
determine what the primary target is. */
record_target = false;
- r_assignment_target.declaration = 0;
+ r_assignment_target.declaration = nullptr;
}
else
r_assignment_target.declaration = declaration;
void VariableResolver::visit(VariableReference &var)
{
- VariableDeclaration *declaration = 0;
+ VariableDeclaration *declaration = nullptr;
/* Look for variable declarations in the block hierarchy first. Interface
blocks are always defined in the top level so we can't accidentally skip
{
TraversingVisitor::visit(memacc);
- VariableDeclaration *declaration = 0;
+ VariableDeclaration *declaration = nullptr;
int index = -1;
if(StructDeclaration *strct = dynamic_cast<StructDeclaration *>(memacc.left->type))
{
TraversingVisitor::visit(var);
auto i = current_block->variables.find(var.name);
- VariableDeclaration *existing = 0;
- VariableDeclaration *block = 0;
+ VariableDeclaration *existing = nullptr;
+ VariableDeclaration *block = nullptr;
if(i!=current_block->variables.end())
existing = i->second;
else if(!current_block->parent)
if(assign && (compat==LEFT_CONVERTIBLE || elem_compat==LEFT_CONVERTIBLE))
return;
- TypeDeclaration *type = 0;
+ TypeDeclaration *type = nullptr;
char oper2 = binary.oper->token[1];
if((oper=='<' && oper2!='<') || (oper=='>' && oper2!='>'))
{
converted = convert_to_element(binary.right, *elem_left);
if(!converted)
- type = 0;
+ type = nullptr;
resolve(binary, type, assign);
}
if(!basic_cond || basic_cond->kind!=BasicTypeDeclaration::BOOL)
return;
- TypeDeclaration *type = 0;
+ TypeDeclaration *type = nullptr;
if(ternary.true_expr->type==ternary.false_expr->type)
type = ternary.true_expr->type;
else
void FunctionResolver::visit(FunctionCall &call)
{
- FunctionDeclaration *declaration = 0;
+ FunctionDeclaration *declaration = nullptr;
if(stage->types.count(call.name))
call.constructor = true;
else
{
if(declaration)
{
- declaration = 0;
+ declaration = nullptr;
break;
}
else
}
else
{
- FunctionDeclaration *definition = (stage_decl ? stage_decl->definition : 0);
+ FunctionDeclaration *definition = (stage_decl ? stage_decl->definition : nullptr);
r_any_resolved |= (definition!=func.definition);
func.definition = definition;
class TypeResolver: private TraversingVisitor
{
private:
- Stage *stage = 0;
+ Stage *stage = nullptr;
std::map<TypeDeclaration *, TypeDeclaration *> alias_map;
std::map<std::pair<TypeDeclaration *, bool>, TypeDeclaration *> array_types;
std::map<std::pair<ImageTypeDeclaration *, std::string>, ImageTypeDeclaration *> image_types;
NodeList<Statement>::iterator type_insert_point;
NodeList<Statement>::iterator block_member_type_ins_pt;
- VariableDeclaration *iface_block = 0;
+ VariableDeclaration *iface_block = nullptr;
bool r_any_resolved = false;
public:
private:
TypeDeclaration *get_or_create_array_type(TypeDeclaration &);
TypeDeclaration *get_or_create_image_type(ImageTypeDeclaration &, const std::string &);
- void resolve_type(TypeDeclaration *&, const std::string &, bool, const Layout * = 0);
+ void resolve_type(TypeDeclaration *&, const std::string &, bool, const Layout * = nullptr);
virtual void visit(Block &);
virtual void visit(BasicTypeDeclaration &);
virtual void visit(ImageTypeDeclaration &);
class VariableResolver: private TraversingVisitor
{
private:
- Stage *stage = 0;
+ Stage *stage = nullptr;
RefPtr<Expression> r_replacement_expr;
bool r_any_resolved = false;
bool record_target = false;
struct ArgumentInfo
{
- BasicTypeDeclaration *type = 0;
+ BasicTypeDeclaration *type = nullptr;
unsigned component_count = 0;
};
- Stage *stage = 0;
- const FunctionDeclaration *current_function = 0;
+ Stage *stage = nullptr;
+ const FunctionDeclaration *current_function = nullptr;
std::vector<BasicTypeDeclaration *> basic_types;
NodeList<Statement>::iterator insert_point;
bool r_any_resolved = false;
class FunctionResolver: private TraversingVisitor
{
private:
- Stage *stage = 0;
+ Stage *stage = nullptr;
std::map<std::string, std::vector<FunctionDeclaration *> > declarations;
bool r_any_resolved = false;
const SpirVGenerator::BuiltinFunctionInfo SpirVGenerator::builtin_functions[] =
{
- { "radians", "f", "GLSL.std.450", GLSL450_RADIANS, { 1 }, 0, 0 },
- { "degrees", "f", "GLSL.std.450", GLSL450_DEGREES, { 1 }, 0, 0 },
- { "sin", "f", "GLSL.std.450", GLSL450_SIN, { 1 }, 0, 0 },
- { "cos", "f", "GLSL.std.450", GLSL450_COS, { 1 }, 0, 0 },
- { "tan", "f", "GLSL.std.450", GLSL450_TAN, { 1 }, 0, 0 },
- { "asin", "f", "GLSL.std.450", GLSL450_ASIN, { 1 }, 0, 0 },
- { "acos", "f", "GLSL.std.450", GLSL450_ACOS, { 1 }, 0, 0 },
- { "atan", "f", "GLSL.std.450", GLSL450_ATAN, { 1 }, 0, 0 },
- { "atan", "ff", "GLSL.std.450", GLSL450_ATAN2, { 1, 2 }, 0, 0 },
- { "sinh", "f", "GLSL.std.450", GLSL450_SINH, { 1 }, 0, 0 },
- { "cosh", "f", "GLSL.std.450", GLSL450_COSH, { 1 }, 0, 0 },
- { "tanh", "f", "GLSL.std.450", GLSL450_TANH, { 1 }, 0, 0 },
- { "asinh", "f", "GLSL.std.450", GLSL450_ASINH, { 1 }, 0, 0 },
- { "acosh", "f", "GLSL.std.450", GLSL450_ACOSH, { 1 }, 0, 0 },
- { "atanh", "f", "GLSL.std.450", GLSL450_ATANH, { 1 }, 0, 0 },
- { "pow", "ff", "GLSL.std.450", GLSL450_POW, { 1, 2 }, 0, 0 },
- { "exp", "f", "GLSL.std.450", GLSL450_EXP, { 1 }, 0, 0 },
- { "log", "f", "GLSL.std.450", GLSL450_LOG, { 1 }, 0, 0 },
- { "exp2", "f", "GLSL.std.450", GLSL450_EXP2, { 1 }, 0, 0 },
- { "log2", "f", "GLSL.std.450", GLSL450_LOG2, { 1 }, 0, 0 },
- { "sqrt", "f", "GLSL.std.450", GLSL450_SQRT, { 1 }, 0, 0 },
- { "inversesqrt", "f", "GLSL.std.450", GLSL450_INVERSE_SQRT, { 1 }, 0, 0 },
- { "abs", "f", "GLSL.std.450", GLSL450_F_ABS, { 1 }, 0, 0 },
- { "abs", "i", "GLSL.std.450", GLSL450_S_ABS, { 1 }, 0, 0 },
- { "sign", "f", "GLSL.std.450", GLSL450_F_SIGN, { 1 }, 0, 0 },
- { "sign", "i", "GLSL.std.450", GLSL450_S_SIGN, { 1 }, 0, 0 },
- { "floor", "f", "GLSL.std.450", GLSL450_FLOOR, { 1 }, 0, 0 },
- { "trunc", "f", "GLSL.std.450", GLSL450_TRUNC, { 1 }, 0, 0 },
- { "round", "f", "GLSL.std.450", GLSL450_ROUND, { 1 }, 0, 0 },
- { "roundEven", "f", "GLSL.std.450", GLSL450_ROUND_EVEN, { 1 }, 0, 0 },
- { "ceil", "f", "GLSL.std.450", GLSL450_CEIL, { 1 }, 0, 0 },
- { "fract", "f", "GLSL.std.450", GLSL450_FRACT, { 1 }, 0, 0 },
- { "mod", "f", "", OP_F_MOD, { 1, 2 }, 0, 0 },
- { "min", "ff", "GLSL.std.450", GLSL450_F_MIN, { 1, 2 }, 0, 0 },
- { "min", "ii", "GLSL.std.450", GLSL450_S_MIN, { 1, 2 }, 0, 0 },
- { "min", "uu", "GLSL.std.450", GLSL450_U_MIN, { 1, 2 }, 0, 0 },
- { "max", "ff", "GLSL.std.450", GLSL450_F_MAX, { 1, 2 }, 0, 0 },
- { "max", "ii", "GLSL.std.450", GLSL450_S_MAX, { 1, 2 }, 0, 0 },
- { "max", "uu", "GLSL.std.450", GLSL450_U_MAX, { 1, 2 }, 0, 0 },
- { "clamp", "fff", "GLSL.std.450", GLSL450_F_CLAMP, { 1, 2, 3 }, 0, 0 },
- { "clamp", "iii", "GLSL.std.450", GLSL450_S_CLAMP, { 1, 2, 3 }, 0, 0 },
- { "clamp", "uuu", "GLSL.std.450", GLSL450_U_CLAMP, { 1, 2, 3 }, 0, 0 },
- { "mix", "fff", "GLSL.std.450", GLSL450_F_MIX, { 1, 2, 3 }, 0, 0 },
- { "mix", "ffb", "", OP_SELECT, { 3, 2, 1 }, 0, 0 },
- { "mix", "iib", "", OP_SELECT, { 3, 2, 1 }, 0, 0 },
- { "mix", "uub", "", OP_SELECT, { 3, 2, 1 }, 0, 0 },
- { "step", "ff", "GLSL.std.450", GLSL450_F_STEP, { 1, 2 }, 0, 0 },
- { "smoothstep", "fff", "GLSL.std.450", GLSL450_F_SMOOTH_STEP, { 1, 2, 3 }, 0, 0 },
- { "isnan", "f", "", OP_IS_NAN, { 1 }, 0, 0 },
- { "isinf", "f", "", OP_IS_INF, { 1 }, 0, 0 },
- { "fma", "fff", "GLSL.std.450", GLSL450_F_FMA, { 1, 2, 3 }, 0, 0 },
- { "length", "f", "GLSL.std.450", GLSL450_LENGTH, { 1 }, 0, 0 },
- { "distance", "ff", "GLSL.std.450", GLSL450_DISTANCE, { 1, 2 }, 0, 0 },
- { "dot", "ff", "", OP_DOT, { 1, 2 }, 0, 0 },
- { "cross", "ff", "GLSL.std.450", GLSL450_CROSS, { 1, 2 }, 0, 0 },
- { "normalize", "f", "GLSL.std.450", GLSL450_NORMALIZE, { 1 }, 0, 0 },
- { "faceforward", "fff", "GLSL.std.450", GLSL450_FACE_FORWARD, { 1, 2, 3 }, 0, 0 },
- { "reflect", "ff", "GLSL.std.450", GLSL450_REFLECT, { 1, 2 }, 0, 0 },
- { "refract", "fff", "GLSL.std.450", GLSL450_REFRACT, { 1, 2, 3 }, 0, 0 },
+ { "radians", "f", "GLSL.std.450", GLSL450_RADIANS, { 1 }, 0, nullptr },
+ { "degrees", "f", "GLSL.std.450", GLSL450_DEGREES, { 1 }, 0, nullptr },
+ { "sin", "f", "GLSL.std.450", GLSL450_SIN, { 1 }, 0, nullptr },
+ { "cos", "f", "GLSL.std.450", GLSL450_COS, { 1 }, 0, nullptr },
+ { "tan", "f", "GLSL.std.450", GLSL450_TAN, { 1 }, 0, nullptr },
+ { "asin", "f", "GLSL.std.450", GLSL450_ASIN, { 1 }, 0, nullptr },
+ { "acos", "f", "GLSL.std.450", GLSL450_ACOS, { 1 }, 0, nullptr },
+ { "atan", "f", "GLSL.std.450", GLSL450_ATAN, { 1 }, 0, nullptr },
+ { "atan", "ff", "GLSL.std.450", GLSL450_ATAN2, { 1, 2 }, 0, nullptr },
+ { "sinh", "f", "GLSL.std.450", GLSL450_SINH, { 1 }, 0, nullptr },
+ { "cosh", "f", "GLSL.std.450", GLSL450_COSH, { 1 }, 0, nullptr },
+ { "tanh", "f", "GLSL.std.450", GLSL450_TANH, { 1 }, 0, nullptr },
+ { "asinh", "f", "GLSL.std.450", GLSL450_ASINH, { 1 }, 0, nullptr },
+ { "acosh", "f", "GLSL.std.450", GLSL450_ACOSH, { 1 }, 0, nullptr },
+ { "atanh", "f", "GLSL.std.450", GLSL450_ATANH, { 1 }, 0, nullptr },
+ { "pow", "ff", "GLSL.std.450", GLSL450_POW, { 1, 2 }, 0, nullptr },
+ { "exp", "f", "GLSL.std.450", GLSL450_EXP, { 1 }, 0, nullptr },
+ { "log", "f", "GLSL.std.450", GLSL450_LOG, { 1 }, 0, nullptr },
+ { "exp2", "f", "GLSL.std.450", GLSL450_EXP2, { 1 }, 0, nullptr },
+ { "log2", "f", "GLSL.std.450", GLSL450_LOG2, { 1 }, 0, nullptr },
+ { "sqrt", "f", "GLSL.std.450", GLSL450_SQRT, { 1 }, 0, nullptr },
+ { "inversesqrt", "f", "GLSL.std.450", GLSL450_INVERSE_SQRT, { 1 }, 0, nullptr },
+ { "abs", "f", "GLSL.std.450", GLSL450_F_ABS, { 1 }, 0, nullptr },
+ { "abs", "i", "GLSL.std.450", GLSL450_S_ABS, { 1 }, 0, nullptr },
+ { "sign", "f", "GLSL.std.450", GLSL450_F_SIGN, { 1 }, 0, nullptr },
+ { "sign", "i", "GLSL.std.450", GLSL450_S_SIGN, { 1 }, 0, nullptr },
+ { "floor", "f", "GLSL.std.450", GLSL450_FLOOR, { 1 }, 0, nullptr },
+ { "trunc", "f", "GLSL.std.450", GLSL450_TRUNC, { 1 }, 0, nullptr },
+ { "round", "f", "GLSL.std.450", GLSL450_ROUND, { 1 }, 0, nullptr },
+ { "roundEven", "f", "GLSL.std.450", GLSL450_ROUND_EVEN, { 1 }, 0, nullptr },
+ { "ceil", "f", "GLSL.std.450", GLSL450_CEIL, { 1 }, 0, nullptr },
+ { "fract", "f", "GLSL.std.450", GLSL450_FRACT, { 1 }, 0, nullptr },
+ { "mod", "f", "", OP_F_MOD, { 1, 2 }, 0, nullptr },
+ { "min", "ff", "GLSL.std.450", GLSL450_F_MIN, { 1, 2 }, 0, nullptr },
+ { "min", "ii", "GLSL.std.450", GLSL450_S_MIN, { 1, 2 }, 0, nullptr },
+ { "min", "uu", "GLSL.std.450", GLSL450_U_MIN, { 1, 2 }, 0, nullptr },
+ { "max", "ff", "GLSL.std.450", GLSL450_F_MAX, { 1, 2 }, 0, nullptr },
+ { "max", "ii", "GLSL.std.450", GLSL450_S_MAX, { 1, 2 }, 0, nullptr },
+ { "max", "uu", "GLSL.std.450", GLSL450_U_MAX, { 1, 2 }, 0, nullptr },
+ { "clamp", "fff", "GLSL.std.450", GLSL450_F_CLAMP, { 1, 2, 3 }, 0, nullptr },
+ { "clamp", "iii", "GLSL.std.450", GLSL450_S_CLAMP, { 1, 2, 3 }, 0, nullptr },
+ { "clamp", "uuu", "GLSL.std.450", GLSL450_U_CLAMP, { 1, 2, 3 }, 0, nullptr },
+ { "mix", "fff", "GLSL.std.450", GLSL450_F_MIX, { 1, 2, 3 }, 0, nullptr },
+ { "mix", "ffb", "", OP_SELECT, { 3, 2, 1 }, 0, nullptr },
+ { "mix", "iib", "", OP_SELECT, { 3, 2, 1 }, 0, nullptr },
+ { "mix", "uub", "", OP_SELECT, { 3, 2, 1 }, 0, nullptr },
+ { "step", "ff", "GLSL.std.450", GLSL450_F_STEP, { 1, 2 }, 0, nullptr },
+ { "smoothstep", "fff", "GLSL.std.450", GLSL450_F_SMOOTH_STEP, { 1, 2, 3 }, 0, nullptr },
+ { "isnan", "f", "", OP_IS_NAN, { 1 }, 0, nullptr },
+ { "isinf", "f", "", OP_IS_INF, { 1 }, 0, nullptr },
+ { "fma", "fff", "GLSL.std.450", GLSL450_F_FMA, { 1, 2, 3 }, 0, nullptr },
+ { "length", "f", "GLSL.std.450", GLSL450_LENGTH, { 1 }, 0, nullptr },
+ { "distance", "ff", "GLSL.std.450", GLSL450_DISTANCE, { 1, 2 }, 0, nullptr },
+ { "dot", "ff", "", OP_DOT, { 1, 2 }, 0, nullptr },
+ { "cross", "ff", "GLSL.std.450", GLSL450_CROSS, { 1, 2 }, 0, nullptr },
+ { "normalize", "f", "GLSL.std.450", GLSL450_NORMALIZE, { 1 }, 0, nullptr },
+ { "faceforward", "fff", "GLSL.std.450", GLSL450_FACE_FORWARD, { 1, 2, 3 }, 0, nullptr },
+ { "reflect", "ff", "GLSL.std.450", GLSL450_REFLECT, { 1, 2 }, 0, nullptr },
+ { "refract", "fff", "GLSL.std.450", GLSL450_REFRACT, { 1, 2, 3 }, 0, nullptr },
{ "matrixCompMult", "ff", "", 0, { 0 }, 0, &SpirVGenerator::visit_builtin_matrix_comp_mult },
- { "outerProduct", "ff", "", OP_OUTER_PRODUCT, { 1, 2 }, 0, 0 },
- { "transpose", "f", "", OP_TRANSPOSE, { 1 }, 0, 0 },
- { "determinant", "f", "GLSL.std.450", GLSL450_DETERMINANT, { 1 }, 0, 0 },
- { "inverse", "f", "GLSL.std.450", GLSL450_MATRIX_INVERSE, { 1 }, 0, 0 },
- { "lessThan", "ff", "", OP_F_ORD_LESS_THAN, { 1, 2 }, 0, 0 },
- { "lessThan", "ii", "", OP_S_LESS_THAN, { 1, 2 }, 0, 0 },
- { "lessThan", "uu", "", OP_U_LESS_THAN, { 1, 2 }, 0, 0 },
- { "lessThanEqual", "ff", "", OP_F_ORD_LESS_THAN_EQUAL, { 1, 2 }, 0, 0 },
- { "lessThanEqual", "ii", "", OP_S_LESS_THAN_EQUAL, { 1, 2 }, 0, 0 },
- { "lessThanEqual", "uu", "", OP_U_LESS_THAN_EQUAL, { 1, 2 }, 0, 0 },
- { "greaterThan", "ff", "", OP_F_ORD_GREATER_THAN, { 1, 2 }, 0, 0 },
- { "greaterThan", "ii", "", OP_S_GREATER_THAN, { 1, 2 }, 0, 0 },
- { "greaterThan", "uu", "", OP_U_GREATER_THAN, { 1, 2 }, 0, 0 },
- { "greaterThanEqual", "ff", "", OP_F_ORD_GREATER_THAN_EQUAL, { 1, 2 }, 0, 0 },
- { "greaterThanEqual", "ii", "", OP_S_GREATER_THAN_EQUAL, { 1, 2 }, 0, 0 },
- { "greaterThanEqual", "uu", "", OP_U_GREATER_THAN_EQUAL, { 1, 2 }, 0, 0 },
- { "equal", "ff", "", OP_F_ORD_EQUAL, { 1, 2 }, 0, 0 },
- { "equal", "ii", "", OP_I_EQUAL, { 1, 2 }, 0, 0 },
- { "equal", "uu", "", OP_I_EQUAL, { 1, 2 }, 0, 0 },
- { "notEqual", "ff", "", OP_F_ORD_NOT_EQUAL, { 1, 2 }, 0, 0 },
- { "notEqual", "ii", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, 0 },
- { "notEqual", "uu", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, 0 },
- { "any", "b", "", OP_ANY, { 1 }, 0, 0 },
- { "all", "b", "", OP_ALL, { 1 }, 0, 0 },
- { "not", "b", "", OP_LOGICAL_NOT, { 1 }, 0, 0 },
- { "bitfieldExtract", "iii", "", OP_BIT_FIELD_S_EXTRACT, { 1, 2, 3 }, 0, 0 },
- { "bitfieldExtract", "uii", "", OP_BIT_FIELD_U_EXTRACT, { 1, 2, 3 }, 0, 0 },
- { "bitfieldInsert", "iiii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, 0 },
- { "bitfieldInsert", "uuii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, 0 },
- { "bitfieldReverse", "i", "", OP_BIT_REVERSE, { 1 }, 0, 0 },
- { "bitfieldReverse", "u", "", OP_BIT_REVERSE, { 1 }, 0, 0 },
- { "bitCount", "i", "", OP_BIT_COUNT, { 1 }, 0, 0 },
- { "findLSB", "i", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, 0 },
- { "findLSB", "u", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, 0 },
- { "findMSB", "i", "GLSL.std.450", GLSL450_FIND_S_MSB, { 1 }, 0, 0 },
- { "findMSB", "u", "GLSL.std.450", GLSL450_FIND_U_MSB, { 1 }, 0, 0 },
+ { "outerProduct", "ff", "", OP_OUTER_PRODUCT, { 1, 2 }, 0, nullptr },
+ { "transpose", "f", "", OP_TRANSPOSE, { 1 }, 0, nullptr },
+ { "determinant", "f", "GLSL.std.450", GLSL450_DETERMINANT, { 1 }, 0, nullptr },
+ { "inverse", "f", "GLSL.std.450", GLSL450_MATRIX_INVERSE, { 1 }, 0, nullptr },
+ { "lessThan", "ff", "", OP_F_ORD_LESS_THAN, { 1, 2 }, 0, nullptr },
+ { "lessThan", "ii", "", OP_S_LESS_THAN, { 1, 2 }, 0, nullptr },
+ { "lessThan", "uu", "", OP_U_LESS_THAN, { 1, 2 }, 0, nullptr },
+ { "lessThanEqual", "ff", "", OP_F_ORD_LESS_THAN_EQUAL, { 1, 2 }, 0, nullptr },
+ { "lessThanEqual", "ii", "", OP_S_LESS_THAN_EQUAL, { 1, 2 }, 0, nullptr },
+ { "lessThanEqual", "uu", "", OP_U_LESS_THAN_EQUAL, { 1, 2 }, 0, nullptr },
+ { "greaterThan", "ff", "", OP_F_ORD_GREATER_THAN, { 1, 2 }, 0, nullptr },
+ { "greaterThan", "ii", "", OP_S_GREATER_THAN, { 1, 2 }, 0, nullptr },
+ { "greaterThan", "uu", "", OP_U_GREATER_THAN, { 1, 2 }, 0, nullptr },
+ { "greaterThanEqual", "ff", "", OP_F_ORD_GREATER_THAN_EQUAL, { 1, 2 }, 0, nullptr },
+ { "greaterThanEqual", "ii", "", OP_S_GREATER_THAN_EQUAL, { 1, 2 }, 0, nullptr },
+ { "greaterThanEqual", "uu", "", OP_U_GREATER_THAN_EQUAL, { 1, 2 }, 0, nullptr },
+ { "equal", "ff", "", OP_F_ORD_EQUAL, { 1, 2 }, 0, nullptr },
+ { "equal", "ii", "", OP_I_EQUAL, { 1, 2 }, 0, nullptr },
+ { "equal", "uu", "", OP_I_EQUAL, { 1, 2 }, 0, nullptr },
+ { "notEqual", "ff", "", OP_F_ORD_NOT_EQUAL, { 1, 2 }, 0, nullptr },
+ { "notEqual", "ii", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, nullptr },
+ { "notEqual", "uu", "", OP_I_NOT_EQUAL, { 1, 2 }, 0, nullptr },
+ { "any", "b", "", OP_ANY, { 1 }, 0, nullptr },
+ { "all", "b", "", OP_ALL, { 1 }, 0, nullptr },
+ { "not", "b", "", OP_LOGICAL_NOT, { 1 }, 0, nullptr },
+ { "bitfieldExtract", "iii", "", OP_BIT_FIELD_S_EXTRACT, { 1, 2, 3 }, 0, nullptr },
+ { "bitfieldExtract", "uii", "", OP_BIT_FIELD_U_EXTRACT, { 1, 2, 3 }, 0, nullptr },
+ { "bitfieldInsert", "iiii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, nullptr },
+ { "bitfieldInsert", "uuii", "", OP_BIT_FIELD_INSERT, { 1, 2, 3, 4 }, 0, nullptr },
+ { "bitfieldReverse", "i", "", OP_BIT_REVERSE, { 1 }, 0, nullptr },
+ { "bitfieldReverse", "u", "", OP_BIT_REVERSE, { 1 }, 0, nullptr },
+ { "bitCount", "i", "", OP_BIT_COUNT, { 1 }, 0, nullptr },
+ { "findLSB", "i", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, nullptr },
+ { "findLSB", "u", "GLSL.std.450", GLSL450_FIND_I_LSB, { 1 }, 0, nullptr },
+ { "findMSB", "i", "GLSL.std.450", GLSL450_FIND_S_MSB, { 1 }, 0, nullptr },
+ { "findMSB", "u", "GLSL.std.450", GLSL450_FIND_U_MSB, { 1 }, 0, nullptr },
{ "textureSize", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query },
{ "textureQueryLod", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query },
{ "textureQueryLevels", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query },
{ "imageSamples", "", "", 0, { }, CAP_IMAGE_QUERY, &SpirVGenerator::visit_builtin_texture_query },
{ "imageLoad", "", "", 0, { }, 0, &SpirVGenerator::visit_builtin_texture_fetch },
{ "imageStore", "", "", 0, { }, 0, &SpirVGenerator::visit_builtin_texture_store },
- { "EmitVertex", "", "", OP_EMIT_VERTEX, { }, 0, 0 },
- { "EndPrimitive", "", "", OP_END_PRIMITIVE, { }, 0, 0 },
- { "dFdx", "f", "", OP_DP_DX, { 1 }, 0, 0 },
- { "dFdy", "f", "", OP_DP_DY, { 1 }, 0, 0 },
- { "dFdxFine", "f", "", OP_DP_DX_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 },
- { "dFdyFine", "f", "", OP_DP_DY_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 },
- { "dFdxCoarse", "f", "", OP_DP_DX_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 },
- { "dFdyCoarse", "f", "", OP_DP_DY_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 },
- { "fwidth", "f", "", OP_FWIDTH, { 1 }, 0, 0 },
- { "fwidthFine", "f", "", OP_FWIDTH_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 },
- { "fwidthCoarse", "f", "", OP_FWIDTH_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, 0 },
+ { "EmitVertex", "", "", OP_EMIT_VERTEX, { }, 0, nullptr },
+ { "EndPrimitive", "", "", OP_END_PRIMITIVE, { }, 0, nullptr },
+ { "dFdx", "f", "", OP_DP_DX, { 1 }, 0, nullptr },
+ { "dFdy", "f", "", OP_DP_DY, { 1 }, 0, nullptr },
+ { "dFdxFine", "f", "", OP_DP_DX_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr },
+ { "dFdyFine", "f", "", OP_DP_DY_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr },
+ { "dFdxCoarse", "f", "", OP_DP_DX_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr },
+ { "dFdyCoarse", "f", "", OP_DP_DY_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr },
+ { "fwidth", "f", "", OP_FWIDTH, { 1 }, 0, nullptr },
+ { "fwidthFine", "f", "", OP_FWIDTH_FINE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr },
+ { "fwidthCoarse", "f", "", OP_FWIDTH_COARSE, { 1 }, CAP_DERIVATIVE_CONTROL, nullptr },
{ "interpolateAtCentroid", "", "", 0, { }, CAP_INTERPOLATION_FUNCTION, &SpirVGenerator::visit_builtin_interpolate },
{ "interpolateAtSample", "", "", 0, { }, CAP_INTERPOLATION_FUNCTION, &SpirVGenerator::visit_builtin_interpolate },
{ "interpolateAtOffset", "", "", 0, { }, CAP_INTERPOLATION_FUNCTION, &SpirVGenerator::visit_builtin_interpolate },
- { "", "", "", 0, { }, 0, 0 }
+ { "", "", "", 0, { }, 0, nullptr }
};
SpirVGenerator::SpirVGenerator():
{
if(!composite_access)
{
- r_composite_base = 0;
+ r_composite_base = nullptr;
r_composite_base_id = 0;
r_composite_chain.clear();
}
swap_operands = (basic_right.kind==BasicTypeDeclaration::VECTOR);
}
}
- else if((basic_left.base_type!=0)!=(basic_right.base_type!=0))
+ else if((basic_left.base_type!=nullptr)!=(basic_right.base_type!=nullptr))
{
/* One operand is scalar and the other is a vector or a matrix.
Expand the scalar to a vector of appropriate size. */
throw internal_error("const variable without initializer");
int spec_id = get_layout_value(var.layout.get(), "constant_id");
- Id *spec_var_id = (spec_id>=0 ? &declared_spec_ids[spec_id] : 0);
+ Id *spec_var_id = (spec_id>=0 ? &declared_spec_ids[spec_id] : nullptr);
if(spec_id>=0 && *spec_var_id)
{
insert_unique(declared_ids, &var, Declaration(*spec_var_id, type_id));
};
Features features;
- Stage *stage = 0;
- FunctionDeclaration *current_function = 0;
+ Stage *stage = nullptr;
+ FunctionDeclaration *current_function = nullptr;
std::vector<const InterfaceLayout *> interface_layouts;
SpirVContent content;
SpirVWriter writer;
bool reachable = false;
bool composite_access = false;
Id r_composite_base_id = 0;
- Node *r_composite_base = 0;
+ Node *r_composite_base = nullptr;
std::vector<unsigned> r_composite_chain;
Id assignment_source_id = 0;
Id loop_merge_block_id = 0;
SpirVWriter::SpirVWriter(SpirVContent &c):
content(c),
- op_target(0),
+ op_target(nullptr),
op_head_pos(0),
current_block_id(0)
{ }
else
op_head |= (words<<16);
- op_target = 0;
+ op_target = nullptr;
op_head_pos = 0;
}
VariableDeclaration::~VariableDeclaration()
{
if(linked_declaration && linked_declaration->linked_declaration==this)
- linked_declaration->linked_declaration = 0;
+ linked_declaration->linked_declaration = nullptr;
}
void VariableDeclaration::visit(NodeVisitor &visitor)
overrd(other.overrd),
body(other.body),
signature(other.signature),
- definition(other.definition==&other ? this : 0)
+ definition(other.definition==&other ? this : nullptr)
// Do not copy return type declaration
{ }
TypeDeclaration *get_ultimate_base_type(TypeDeclaration *type)
{
if(!type)
- return 0;
+ return nullptr;
while(const BasicTypeDeclaration *basic = dynamic_cast<const BasicTypeDeclaration *>(type))
{
if(!basic->base_type)
public:
NodePtr() = default;
NodePtr(T *p): RefPtr<T>(p) { }
- NodePtr(const NodePtr &p): RefPtr<T>(p ? p->clone() : 0) { }
+ NodePtr(const NodePtr &p): RefPtr<T>(p ? p->clone() : nullptr) { }
NodePtr &operator=(const NodePtr &p) = default;
template<typename U>
bool use_braces = false;
std::map<std::string, VariableDeclaration *> variables;
- Block *parent = 0;
+ Block *parent = nullptr;
Block() = default;
Block(const Block &);
struct Expression: Node
{
- const Operator *oper = 0;
+ const Operator *oper = nullptr;
- TypeDeclaration *type = 0;
+ TypeDeclaration *type = nullptr;
bool lvalue = false;
virtual Expression *clone() const = 0;
{
std::string name;
- VariableDeclaration *declaration = 0;
+ VariableDeclaration *declaration = nullptr;
VariableReference() = default;
VariableReference(const VariableReference &);
NodePtr<Expression> left;
std::string member;
- VariableDeclaration *declaration = 0;
+ VariableDeclaration *declaration = nullptr;
int index = -1;
MemberAccess() = default;
ARRAY = 0xC0
};
- VariableDeclaration *declaration = 0;
+ VariableDeclaration *declaration = nullptr;
std::uint8_t chain_len = 0;
std::uint8_t chain[7] = { };
- Target(VariableDeclaration *d = 0): declaration(d) { }
+ Target(VariableDeclaration *d = nullptr): declaration(d) { }
bool operator<(const Target &) const;
};
bool constructor = false;
NodeArray<Expression> arguments;
- FunctionDeclaration *declaration = 0;
+ FunctionDeclaration *declaration = nullptr;
FunctionCall() = default;
FunctionCall(const FunctionCall &);
bool extended_alignment = false;
std::string base;
- TypeDeclaration *base_type = 0;
+ TypeDeclaration *base_type = nullptr;
BasicTypeDeclaration() = default;
BasicTypeDeclaration(const BasicTypeDeclaration &);
std::string base;
std::string format;
- TypeDeclaration *base_type = 0;
- ImageTypeDeclaration *base_image = 0;
+ TypeDeclaration *base_type = nullptr;
+ ImageTypeDeclaration *base_image = nullptr;
virtual ImageTypeDeclaration *clone() const { return new ImageTypeDeclaration(*this); }
virtual void visit(NodeVisitor &);
std::string block_name;
bool extended_alignment = false;
- VariableDeclaration *block_declaration = 0;
+ VariableDeclaration *block_declaration = nullptr;
StructDeclaration();
StructDeclaration(const StructDeclaration &);
NodePtr<Expression> array_size;
NodePtr<Expression> init_expression;
- TypeDeclaration *type_declaration = 0;
- StructDeclaration *block_declaration = 0;
- VariableDeclaration *linked_declaration = 0;
+ TypeDeclaration *type_declaration = nullptr;
+ StructDeclaration *block_declaration = nullptr;
+ VariableDeclaration *linked_declaration = nullptr;
VariableDeclaration() = default;
VariableDeclaration(const VariableDeclaration &);
Block body;
std::string signature;
- FunctionDeclaration *definition = 0;
- TypeDeclaration *return_type_declaration = 0;
+ FunctionDeclaration *definition = nullptr;
+ TypeDeclaration *return_type_declaration = nullptr;
FunctionDeclaration() = default;
FunctionDeclaration(const FunctionDeclaration &);
};
Type type;
- Stage *previous = 0;
+ Stage *previous = nullptr;
Block content;
std::map<std::string, TypeDeclaration *> types;
std::map<std::string, VariableDeclaration *> interface_blocks;
features = f;
s.content.visit(*this);
- Node *global_err_node = 0;
+ Node *global_err_node = nullptr;
auto i = s.functions.find("main()");
if(i!=s.functions.end())
global_err_node = i->second;
class Validator: protected TraversingVisitor
{
protected:
- Stage *stage = 0;
- Node *last_provoker = 0;
+ Stage *stage = nullptr;
+ Node *last_provoker = nullptr;
Validator() = default;
Features features;
ScopeType scope = GLOBAL;
- InterfaceLayout *iface_layout = 0;
- VariableDeclaration *iface_block = 0;
- VariableDeclaration *variable = 0;
+ InterfaceLayout *iface_layout = nullptr;
+ VariableDeclaration *iface_block = nullptr;
+ VariableDeclaration *variable = nullptr;
bool have_input_primitive = false;
bool have_output_primitive = false;
bool have_output_vertex_count = false;
SPEC_CONSTANT
};
- FunctionDeclaration *current_function = 0;
+ FunctionDeclaration *current_function = nullptr;
bool in_struct = false;
ConstantKind constant_expression = NOT_CONSTANT;
private:
struct Uniform
{
- Node *node = 0;
- TypeDeclaration *type = 0;
+ Node *node = nullptr;
+ TypeDeclaration *type = nullptr;
std::string name;
int location = -1;
unsigned loc_count = 1;
string key = format("%s %s", strct.block_declaration->interface, strct.block_name);
remove_from_map(stage->interface_blocks, key, *strct.block_declaration);
remove_from_map(stage->interface_blocks, strct.block_declaration->name, *strct.block_declaration);
- strct.block_declaration->block_declaration = 0;
+ strct.block_declaration->block_declaration = nullptr;
}
}
}
{
remove_from_map(stage->interface_blocks, format("%s %s", var.interface, var.block_declaration->block_name), var);
remove_from_map(stage->interface_blocks, var.name, var);
- var.block_declaration->block_declaration = 0;
+ var.block_declaration->block_declaration = nullptr;
}
stage->locations.erase(var.name);
if(var.linked_declaration)
- var.linked_declaration->linked_declaration = 0;
+ var.linked_declaration->linked_declaration = nullptr;
}
else if(var.init_expression && to_remove->count(var.init_expression.get()))
- var.init_expression = 0;
+ var.init_expression = nullptr;
}
void NodeRemover::visit(FunctionDeclaration &func)
void NodeRemover::visit(Iteration &iter)
{
if(to_remove->count(iter.init_statement.get()))
- iter.init_statement = 0;
+ iter.init_statement = nullptr;
TraversingVisitor::visit(iter);
}
class TraversingVisitor: public NodeVisitor
{
protected:
- Block *current_block = 0;
+ Block *current_block = nullptr;
TraversingVisitor() = default;
class NodeRemover: private TraversingVisitor
{
private:
- Stage *stage = 0;
- const std::set<Node *> *to_remove = 0;
+ Stage *stage = nullptr;
+ const std::set<Node *> *to_remove = nullptr;
public:
void apply(Stage &, const std::set<Node *> &);
class NodeReorderer: private TraversingVisitor
{
private:
- Node *reorder_before = 0;
- const std::set<Node *> *to_reorder = 0;
+ Node *reorder_before = nullptr;
+ const std::set<Node *> *to_reorder = nullptr;
public:
void apply(Stage &, Node &, const std::set<Node *> &);
void BasicMaterial::fill_program_info(string &module_name, map<string, int> &spec_values) const
{
module_name = "phong.glsl";
- spec_values["use_diffuse_map"] = (diffuse.texture!=0);
+ spec_values["use_diffuse_map"] = (diffuse.texture!=nullptr);
bool use_specular = (specular.texture || specular.value.r || specular.value.g || specular.value.b);
spec_values["use_specular"] = use_specular;
- spec_values["use_specular_map"] = (specular.texture!=0);
- spec_values["use_shininess_map"] = (use_specular && shininess.texture!=0);
- spec_values["use_normal_map"] = (normal.texture!=0);
+ spec_values["use_specular_map"] = (specular.texture!=nullptr);
+ spec_values["use_shininess_map"] = (use_specular && shininess.texture!=nullptr);
+ spec_values["use_normal_map"] = (normal.texture!=nullptr);
bool use_emission = (emission.texture || emission.value.r || emission.value.g || emission.value.b);
spec_values["use_emission"] = use_emission;
- spec_values["use_emission_map"] = (emission.texture!=0);
- spec_values["use_reflectivity"] = (reflectivity.value!=0 || reflectivity.texture!=0);
- spec_values["use_reflectivity_map"] = (reflectivity.texture!=0);
+ spec_values["use_emission_map"] = (emission.texture!=nullptr);
+ spec_values["use_reflectivity"] = (reflectivity.value!=0 || reflectivity.texture!=nullptr);
+ spec_values["use_reflectivity_map"] = (reflectivity.texture!=nullptr);
}
const Texture *BasicMaterial::get_texture(Tag tag) const
else if(tag==texture_tags[5])
return reflectivity.texture;
else
- return 0;
+ return nullptr;
}
void BasicMaterial::set_diffuse(const Color &color)
T value;
const Texture *texture;
- Property(): value(T()), texture(0) { }
+ Property(): value(T()), texture(nullptr) { }
};
template<typename C>
};
protected:
- const Sampler *sampler = 0;
+ const Sampler *sampler = nullptr;
float alpha_cutoff = 0.0f;
float alpha_feather = 1.0f;
ProgramData shdata;
void PbrMaterial::fill_program_info(string &module_name, map<string, int> &spec_values) const
{
module_name = "pbr_material.glsl";
- spec_values["use_base_color_map"] = (base_color.texture!=0);
- spec_values["use_normal_map"] = (normal.texture!=0);
- spec_values["use_metalness_map"] = (metalness.texture!=0);
- spec_values["use_roughness_map"] = (roughness.texture!=0);
- spec_values["use_occlusion_map"] = (occlusion.texture!=0);
+ spec_values["use_base_color_map"] = (base_color.texture!=nullptr);
+ spec_values["use_normal_map"] = (normal.texture!=nullptr);
+ spec_values["use_metalness_map"] = (metalness.texture!=nullptr);
+ spec_values["use_roughness_map"] = (roughness.texture!=nullptr);
+ spec_values["use_occlusion_map"] = (occlusion.texture!=nullptr);
bool use_emission = (emission.texture || emission.value.r || emission.value.g || emission.value.b);
spec_values["use_emission"] = use_emission;
- spec_values["use_emission_map"] = (emission.texture!=0);
+ spec_values["use_emission_map"] = (emission.texture!=nullptr);
}
const Texture *PbrMaterial::get_texture(Tag tag) const
else if(tag==texture_tags[6])
return &fresnel_lookup;
else
- return 0;
+ return nullptr;
}
const Sampler *PbrMaterial::get_sampler(Tag tag) const
add_property("roughness", &PbrMaterial::set_roughness, &PbrMaterial::set_roughness_map);
add_property("occlusion", &PbrMaterial::set_occlusion_map);
add_property("emission", &PbrMaterial::set_emission, &PbrMaterial::set_emission_map, false);
- add_property("tint", &PbrMaterial::set_tint, 0, true);
+ add_property("tint", &PbrMaterial::set_tint, nullptr, true);
}
} // namespace GL
debug_name(move(other.debug_name))
{
other.blocks.clear();
- other.buffer = 0;
+ other.buffer = nullptr;
}
ProgramData::~ProgramData()
if(shared.dirty==ALL_ONES)
update_block_uniform_indices(shared, b);
prog_begin->masks.used |= shared.used;
- j->block = (shared.used ? shared.block : 0);
+ j->block = (shared.used ? shared.block : nullptr);
++j;
}
}
block_hash(h),
used(0),
dirty(0),
- block(0)
+ block(nullptr)
{
indices.type_flag = 0xFD;
}
unsigned generation = 0;
mutable std::vector<SharedBlock> blocks;
mutable std::vector<ProgramBlock> programs;
- mutable UniformBlock *last_buffer_block = 0;
- mutable Buffer *buffer = 0;
+ mutable UniformBlock *last_buffer_block = nullptr;
+ mutable Buffer *buffer = nullptr;
bool streaming = false;
mutable Mask dirty = 0;
std::string debug_name;
public:
- ProgramData(const Program * = 0);
+ ProgramData(const Program * = nullptr);
ProgramData(ProgramData &&);
~ProgramData();
shdata->copy_uniforms(*data);
}
else
- shdata = 0;
+ shdata = nullptr;
maybe_create_material_shader();
}
const Texture *texture;
const Sampler *sampler;
- TextureSlot(Tag t): tag(t), texture(0), sampler(0) { }
+ TextureSlot(Tag t): tag(t), texture(nullptr), sampler(nullptr) { }
};
- const Program *shprog = 0;
+ const Program *shprog = nullptr;
bool shprog_from_material = false;
RefPtr<ProgramData> shdata;
std::map<Tag, Tag> uniform_slots;
- const Material *material = 0;
+ const Material *material = nullptr;
std::string material_slot;
std::vector<TextureSlot> textures;
CullMode face_cull = NO_CULL;
const Material *get_material() const { return material; }
const std::string &get_material_slot_name() const { return material_slot; }
- void set_texture(Tag, const Texture *, const Sampler * = 0);
+ void set_texture(Tag, const Texture *, const Sampler * = nullptr);
Tag get_texture_tag(const std::string &) const;
const Texture *get_texture(Tag) const;
const Sampler *get_sampler(Tag) const;
else if(tag==texture_tags[6])
return &fresnel_lookup;
else
- return 0;
+ return nullptr;
}
const Sampler *SplatMaterial::get_sampler(Tag tag) const
struct MapArray
{
- Texture2DArray *texture = 0;
+ Texture2DArray *texture = nullptr;
PixelFormat format = NO_PIXELFORMAT;
unsigned width = 0;
unsigned height = 0;
const RenderMethod *Technique::find_method(Tag tag) const
{
auto i = methods.find(tag);
- return (i!=methods.end() ? &i->second : 0);
+ return (i!=methods.end() ? &i->second : nullptr);
}
bool Technique::replace_texture(const string &slot, const Texture &tex)
void UnlitMaterial::fill_program_info(string &module_name, map<string, int> &spec_values) const
{
module_name = "unlit.glsl";
- spec_values["use_texture"] = (texture!=0);
+ spec_values["use_texture"] = (texture!=nullptr);
spec_values["use_vertex_color"] = vertex_color;
}
if(tag==texture_tags[0])
return texture;
else
- return 0;
+ return nullptr;
}
void UnlitMaterial::set_texture(const Texture *tex)
{
Material::PropertyLoader<UnlitMaterial>::init_actions();
add("texture", &Loader::property_texture, &UnlitMaterial::set_texture);
- add_property("color", &UnlitMaterial::set_color, 0, true);
+ add_property("color", &UnlitMaterial::set_color, nullptr, true);
add("vertex_color", &UnlitMaterial::vertex_color);
}
};
private:
- const Texture *texture = 0;
+ const Texture *texture = nullptr;
Color color;
bool vertex_color = false;
private:
struct Block
{
- char *begin = 0;
- char *end = 0;
+ char *begin = nullptr;
+ char *end = nullptr;
};
struct Slot
const Object &object;
VertexArray instance_data;
- Buffer *instance_buffer = 0;
+ Buffer *instance_buffer = nullptr;
VertexSetup vtx_setup;
int matrix_location = -1;
unsigned matrix_offset = 0;
const Mesh *Object::get_mesh(unsigned i) const
{
if(i>=lods.size())
- return 0;
+ return nullptr;
return lods[i].mesh;
}
const Technique *Object::get_technique(unsigned i) const
{
if(i>=lods.size())
- return 0;
+ return nullptr;
return lods[i].technique;
}
j++->renderable = r;
for(; j!=occluded_cache.end(); ++j)
{
- j->renderable = 0;
+ j->renderable = nullptr;
j->in_frustum = false;
}
private:
struct OccludedRenderable
{
- Renderable *renderable = 0;
- const Geometry::BoundingSphere<float, 3> *bounding_sphere = 0;
+ Renderable *renderable = nullptr;
+ const Geometry::BoundingSphere<float, 3> *bounding_sphere = nullptr;
bool in_frustum = false;
bool occluder = false;
};
/** Returns the model matrix of the Renderable. Null is returned if no such
matrix exists. The matrix should be in world space for some effects to work
correctly. */
- virtual const Matrix *get_matrix() const { return 0; }
+ virtual const Matrix *get_matrix() const { return nullptr; }
/** Returns a bounding sphere that completely encloses the Renderable. The
bounding sphere is expressed in the renderable's coordinates. Null is
returned if the bounding sphere cannot be determined. */
- virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return 0; }
+ virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return nullptr; }
/** Called when starting to render a new frame. */
virtual void setup_frame(Renderer &) { }
RendererBackend::end();
- current_state = 0;
+ current_state = nullptr;
state_stack.clear();
texture_stack.clear();
shdata_stack.clear();
}
}
else
- samp = 0;
+ samp = nullptr;
set_resource(texture_stack, state.texture_count, tag, { tex, samp, level });
}
void Renderer::set_storage_texture(Tag tag, const Texture *tex)
{
State &state = get_state();
- set_resource(texture_stack, state.texture_count, tag, { tex, 0, 0 });
+ set_resource(texture_stack, state.texture_count, tag, { tex, nullptr, 0 });
}
template<typename T>
private:
struct SampledTexture
{
- const Texture *texture = 0;
- const Sampler *sampler = 0;
+ const Texture *texture = nullptr;
+ const Sampler *sampler = nullptr;
int level = -1;
SampledTexture() = default;
struct State
{
std::uintptr_t pipeline_key = 0;
- const Camera *camera = 0;
+ const Camera *camera = nullptr;
Matrix model_matrix;
- const Framebuffer *framebuffer = 0;
- const Rect *viewport = 0;
- const Rect *scissor = 0;
+ const Framebuffer *framebuffer = nullptr;
+ const Rect *viewport = nullptr;
+ const Rect *scissor = nullptr;
unsigned texture_count = 0;
- const Program *shprog = 0;
+ const Program *shprog = nullptr;
unsigned shdata_count = 0;
unsigned buffer_count = 0;
- const VertexSetup *vertex_setup = 0;
+ const VertexSetup *vertex_setup = nullptr;
FaceWinding front_face = NON_MANIFOLD;
CullMode face_cull = NO_CULL;
- const DepthTest *depth_test = 0;
- const StencilTest *stencil_test = 0;
- const Blend *blend = 0;
+ const DepthTest *depth_test = nullptr;
+ const StencilTest *stencil_test = nullptr;
+ const Blend *blend = nullptr;
unsigned object_lod_bias = 0;
};
unsigned frame_number = 0;
unsigned char changed = 0;
std::vector<State> state_stack;
- State *current_state = 0;
+ State *current_state = nullptr;
ProgramData standard_shdata;
std::vector<BoundProgramData> shdata_stack;
std::vector<BoundResource<const Buffer *>> buffer_stack;
std::vector<BoundResource<SampledTexture>> texture_stack;
- const Texture *placeholder_texture = 0;
- const Sampler *default_sampler = 0;
- PipelineState *last_pipeline = 0;
+ const Texture *placeholder_texture = nullptr;
+ const Sampler *default_sampler = nullptr;
+ PipelineState *last_pipeline = nullptr;
Commands commands;
static const Tag world_obj_matrix_tag;
/** Sets the shader program to use. As a convenience, uniform values may be
specified at the same time. */
- void set_shader_program(const Program *prog, const ProgramData *data = 0);
+ void set_shader_program(const Program *prog, const ProgramData *data = nullptr);
/** Adds uniform values, which will be available for shader programs. If
multiple ProgramData objects with the same uniforms are added, the one added
void set_storage_buffer(Tag, const Buffer *);
- void set_texture(Tag, const Texture *, const Sampler * = 0);
- void set_texture(Tag, const Texture *, int, const Sampler * = 0);
+ void set_texture(Tag, const Texture *, const Sampler * = nullptr);
+ void set_texture(Tag, const Texture *, int, const Sampler * = nullptr);
void set_storage_texture(Tag, const Texture *);
private:
static unsigned inline_counter;
public:
- Loader(Scene &s, Collection &c): Loader(s, c, 0) { }
+ Loader(Scene &s, Collection &c): Loader(s, c, nullptr) { }
Loader(Scene &s, Collection &c, ContentMap &m) : Loader(s, c, &m) { }
private:
Loader(Scene &, Collection &, ContentMap *);
source = target_ms;
}
- renderer.set_depth_test(0);
- renderer.set_stencil_test(0);
- renderer.set_blend(0);
+ renderer.set_depth_test(nullptr);
+ renderer.set_stencil_test(nullptr);
+ renderer.set_blend(nullptr);
for(unsigned i=0; i<postproc.size(); ++i)
{
Sequence::Step::Step(Tag t, Renderable *r):
tag(t),
- lighting(0),
+ lighting(nullptr),
renderable(r)
{ }
private:
struct OwnedObject
{
- void *pointer = 0;
- void (*delete_func)(void *) = 0;
+ void *pointer = nullptr;
+ void (*delete_func)(void *) = nullptr;
OwnedObject(void *p, void (*d)(void *)): pointer(p), delete_func(d) { }
};
unsigned width = 0;
unsigned height = 0;
FrameFormat target_format;
- RenderTarget *target[2] = { 0, 0 };
- RenderTarget *target_ms = 0;
+ RenderTarget *target[2] = { nullptr, nullptr };
+ RenderTarget *target_ms = nullptr;
bool clear_enabled = false;
std::vector<Color> clear_colors;
float clear_depth = 1.0f;
const Matrix *Slot::get_matrix() const
{
- return content ? content->get_matrix() : 0;
+ return content ? content->get_matrix() : nullptr;
}
const Geometry::BoundingSphere<float, 3> *Slot::get_bounding_sphere() const
{
- return content ? content->get_bounding_sphere() : 0;
+ return content ? content->get_bounding_sphere() : nullptr;
}
void Slot::setup_frame(Renderer &renderer)
class MSPGL_API Slot: public Renderable
{
private:
- Renderable *content = 0;
+ Renderable *content = nullptr;
public:
void set(Renderable *);
}
else
{
- object.set_technique(0);
+ object.set_technique(nullptr);
texture_tag = Tag();
sampler = nullptr;
}
float width = 0.0f;
public:
- Text(const Font &, const Technique * = 0, Tag = Tag());
+ Text(const Font &, const Technique * = nullptr, Tag = Tag());
const Mesh *get_mesh() const { return &mesh; }
content(other.content),
internal_renderer(other.internal_renderer)
{
- other.internal_renderer = 0;
+ other.internal_renderer = nullptr;
}
void View::set_camera(Camera *c)
class MSPGL_API View: public NonCopyable
{
protected:
- Camera *camera = 0;
- Renderable *content = 0;
- Renderer *internal_renderer = 0;
+ Camera *camera = nullptr;
+ Renderable *content = nullptr;
+ Renderer *internal_renderer = nullptr;
View() = default;
public:
manager->move_resource(other, *this);
manager_data = manager->get_data_for_resource(*this);
}
- other.manager = 0;
- other.manager_data = 0;
+ other.manager = nullptr;
+ other.manager_data = nullptr;
}
void Resource::set_manager(ResourceManager *m)
manager_data = manager->get_data_for_resource(*this);
}
else
- manager_data = 0;
+ manager_data = nullptr;
}
bool Resource::is_loaded() const
};
protected:
- ResourceManager *manager = 0;
- void *manager_data = 0;
+ ResourceManager *manager = nullptr;
+ void *manager_data = nullptr;
Resource() = default;
Resource(Resource &&);
ResourceManager *get_manager() const { return manager; }
void *get_manager_data() const { return manager_data; }
virtual int get_load_priority() const { return 0; }
- virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) = 0;
+ virtual AsyncLoader *load(IO::Seekable &, const Resources * = nullptr) = 0;
virtual bool is_loaded() const;
/** Returns the amount of graphics memory used by this resource. The
thread.terminate();
while(!resources.empty())
- resources.begin()->second.resource->set_manager(0);
+ resources.begin()->second.resource->set_manager(nullptr);
}
void ResourceManager::set_loading_policy(LoadingPolicy p)
const ResourceManager::ResourceLocation *ResourceManager::get_resource_location(const Resource &r) const
{
const ManagedResource &managed = get_managed_resource(r);
- return managed.location.collection ? &managed.location : 0;
+ return managed.location.collection ? &managed.location : nullptr;
}
void ResourceManager::load_resource(Resource &r)
while(total_data_size>size_limit)
{
- ManagedResource *best = 0;
+ ManagedResource *best = nullptr;
uint64_t best_impact = 0;
for(auto &kvp: resources)
if(kvp.second.state==ManagedResource::LOADED && kvp.second.last_used<unload_limit)
ResourceManager::ResourceLocation::ResourceLocation():
- collection(0)
+ collection(nullptr)
{ }
ResourceManager::ResourceLocation::ResourceLocation(DataFile::Collection &c, const string &n):
ResourceManager::ManagedResource::ManagedResource(Resource &r):
resource(&r),
load_priority(r.get_load_priority()),
- io(0),
- loader(0),
+ io(nullptr),
+ loader(nullptr),
state(NOT_LOADED),
last_used(0),
data_size(0)
if(!loader)
{
delete io;
- io = 0;
+ io = nullptr;
throw logic_error("no loader created");
}
state = LOADING;
void ResourceManager::ManagedResource::finish_loading(bool successful)
{
delete loader;
- loader = 0;
+ loader = nullptr;
delete io;
- io = 0;
+ io = nullptr;
if(successful)
{
{
MutexLock lock(queue_mutex);
if(que.empty())
- return 0;
+ return nullptr;
return que.front();
}
void init_shaderlib(DataFile::BuiltinSource &);
void init_builtin_data(DataFile::BuiltinSource &);
-Resources *Resources::global_resources = 0;
+Resources *Resources::global_resources = nullptr;
Resources::Resources(bool set_as_global):
- resource_manager(0)
+ resource_manager(nullptr)
{
add_type<Animation>().suffix(".anim").keyword("animation");
add_type<Armature>().suffix(".arma").keyword("armature");
add_type<BasicMaterial>().base<Material>().suffix(".mat")
- .creator([this](const string &n) -> BasicMaterial * { create_generic<Material>(n); return 0; })
+ .creator([this](const string &n) -> BasicMaterial * { create_generic<Material>(n); return nullptr; })
.notify(&set_debug_name<Material>);
add_type<Camera>().keyword("camera")
.notify(&set_debug_name<Camera>);
add_type<DirectionalLight>().base<Light>().suffix(".light")
- .creator([this](const string &n) -> DirectionalLight * { create_generic<Light>(n); return 0; });
+ .creator([this](const string &n) -> DirectionalLight * { create_generic<Light>(n); return nullptr; });
add_type<Font>().keyword("font");
add_type<KeyFrame>().suffix(".kframe").keyword("keyframe");
add_type<Lighting>().suffix(".lightn").keyword("lighting")
.notify(&set_debug_name<Module>);
add_type<Object>().base<Renderable>().keyword("object");
add_type<OccludedScene>().base<Scene>().base<Renderable>().suffix(".scene")
- .creator([this](const string &n) -> OccludedScene * { create_generic<Scene>(n); return 0; });
+ .creator([this](const string &n) -> OccludedScene * { create_generic<Scene>(n); return nullptr; });
add_type<OrderedScene>().base<Scene>().base<Renderable>().suffix(".scene")
- .creator([this](const string &n) -> OrderedScene * { create_generic<Scene>(n); return 0; });
+ .creator([this](const string &n) -> OrderedScene * { create_generic<Scene>(n); return nullptr; });
add_type<PbrMaterial>().base<Material>().suffix(".mat")
- .creator([this](const string &n) -> PbrMaterial * { create_generic<Material>(n); return 0; })
+ .creator([this](const string &n) -> PbrMaterial * { create_generic<Material>(n); return nullptr; })
.notify(&set_debug_name<Material>);
add_type<PointLight>().base<Light>().suffix(".light")
- .creator([this](const string &n) -> PointLight * { create_generic<Light>(n); return 0; });
+ .creator([this](const string &n) -> PointLight * { create_generic<Light>(n); return nullptr; });
add_type<SequenceTemplate>().suffix(".seq").keyword("sequence");
add_type<Pose>().keyword("pose");
add_type<Program>().keyword("shader")
add_type<Sampler>().suffix(".samp").keyword("sampler")
.notify(&set_debug_name<Sampler>);
add_type<SimpleScene>().base<Scene>().base<Renderable>().suffix(".scene")
- .creator([this](const string &n) -> SimpleScene * { create_generic<Scene>(n); return 0; });
+ .creator([this](const string &n) -> SimpleScene * { create_generic<Scene>(n); return nullptr; });
add_type<SplatMaterial>().base<Material>().suffix(".mat")
- .creator([this](const string &n) -> SplatMaterial * { create_generic<Material>(n); return 0; })
+ .creator([this](const string &n) -> SplatMaterial * { create_generic<Material>(n); return nullptr; })
.notify(&set_debug_name<Material>);
add_type<Technique>().suffix(".tech").keyword("technique")
.notify(&set_debug_name<Technique>);
add_type<Texture1D>().base<Texture>().suffix(".tex")
- .creator([this](const string &n) -> Texture1D * { create_texture(n); return 0; })
+ .creator([this](const string &n) -> Texture1D * { create_texture(n); return nullptr; })
.notify(&set_debug_name<Texture1D>);
add_type<Texture2D>().base<Texture>().suffix(".tex").suffix(".png").suffix(".jpg")
- .creator([this](const string &n) -> Texture2D * { create_texture(n); return 0; })
+ .creator([this](const string &n) -> Texture2D * { create_texture(n); return nullptr; })
.notify(&set_debug_name<Texture2D>);
add_type<Texture3D>().base<Texture>().suffix(".tex")
- .creator([this](const string &n) -> Texture3D * { create_texture(n); return 0; })
+ .creator([this](const string &n) -> Texture3D * { create_texture(n); return nullptr; })
.notify(&set_debug_name<Texture3D>);
add_type<TextureCube>().base<Texture>().suffix(".tex")
- .creator([this](const string &n) -> TextureCube * { create_texture(n); return 0; })
+ .creator([this](const string &n) -> TextureCube * { create_texture(n); return nullptr; })
.notify(&set_debug_name<TextureCube>);
add_type<Texture2DArray>().base<Texture>().suffix(".tex")
- .creator([this](const string &n) -> Texture2DArray * { create_texture(n); return 0; })
+ .creator([this](const string &n) -> Texture2DArray * { create_texture(n); return nullptr; })
.notify(&set_debug_name<Texture2DArray>);
add_type<UnlitMaterial>().base<Material>().suffix(".mat")
- .creator([this](const string &n) -> UnlitMaterial * { create_generic<Material>(n); return 0; })
+ .creator([this](const string &n) -> UnlitMaterial * { create_generic<Material>(n); return nullptr; })
.notify(&set_debug_name<Material>);
add_type<ZSortedScene>().base<Scene>().base<Renderable>().suffix(".scene")
- .creator([this](const string &n) -> ZSortedScene * { create_generic<Scene>(n); return 0; });
+ .creator([this](const string &n) -> ZSortedScene * { create_generic<Scene>(n); return nullptr; });
add_source(get_builtins());
Resources::~Resources()
{
if(this==global_resources)
- global_resources = 0;
+ global_resources = nullptr;
}
Resources &Resources::get_global()
ldr.store_object(*this, name);
}
- return 0;
+ return nullptr;
}
Mesh *Resources::create_mesh(const string &name)
{
if(!resource_manager || name[0]=='_')
- return 0;
+ return nullptr;
if(RefPtr<IO::Seekable> io = open_raw(name))
{
return mesh.release();
}
- return 0;
+ return nullptr;
}
Texture *Resources::create_texture(const string &name)
tex.release();
}
- return 0;
+ return nullptr;
}
Module *Resources::create_module(const string &name)
{
string ext = FS::extpart(name);
if(ext!=".glsl" && ext!=".spv")
- return 0;
+ return nullptr;
if(RefPtr<IO::Seekable> io = open_raw(name))
{
}
}
- return 0;
+ return nullptr;
}
Program *Resources::create_program(const string &name)
return shprog.release();
}
- return 0;
+ return nullptr;
}
template<typename T>
gl_device(window),
mouse(window),
view(window),
- sequence(0),
- renderable(0),
- anim_object(0),
- anim_player(0),
+ sequence(nullptr),
+ renderable(nullptr),
+ anim_object(nullptr),
+ anim_player(nullptr),
distance(10),
dragging(0)
{
}
}
- GL::Object *object = 0;
+ GL::Object *object = nullptr;
string ext = FS::extpart(opts.renderable_name);
if(ext==".mesh")
{
- GL::Mesh *mesh = 0;
+ GL::Mesh *mesh = nullptr;
if(FS::exists(opts.renderable_name))
{
mesh = new GL::Mesh;
object = new GL::Object;
GL::Technique *tech = new GL::Technique;
- tech->add_method(0);
+ tech->add_method(GL::Tag());
object->set_mesh(mesh);
object->set_technique(tech);
renderable = object;
sequence = new GL::Sequence();
sequence->set_debug_name("Sequence");
sequence->set_clear_enabled(true);
- GL::Sequence::Step &step = sequence->add_step(0, *renderable);
+ GL::Sequence::Step &step = sequence->add_step(GL::Tag(), *renderable);
step.set_lighting(&lighting);
step.set_depth_test(GL::LEQUAL);
}