Added sprite and better vertex format. works, but now I lost texturing

This commit is contained in:
2019-08-05 18:08:58 -07:00
parent cce893a0c8
commit 1f33d96ae5
9 changed files with 98 additions and 130 deletions

View File

@@ -1,6 +1,6 @@
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, DeviceLocalBuffer, ImmutableBuffer, BufferAccess};
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, StdDescriptorPoolAlloc};
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, StdDescriptorPoolAlloc, DescriptorSetDesc};
use vulkano::device::{Device, DeviceExtensions, QueuesIter, Queue};
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice, QueueFamily};
use vulkano::pipeline::{ComputePipeline, GraphicsPipeline, GraphicsPipelineAbstract, GraphicsPipelineBuilder};
@@ -18,7 +18,7 @@ use image::GenericImage;
use shade_runner::{ComputeLayout, CompileError, FragLayout, FragInput, FragOutput, VertInput, VertOutput, VertLayout, CompiledShaders, Entry};
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSetBuf, PersistentDescriptorSetImg, PersistentDescriptorSetSampler};
use shaderc::CompileOptions;
use vulkano::framebuffer::{Subpass, RenderPass, RenderPassAbstract, Framebuffer, FramebufferAbstract};
use vulkano::framebuffer::{Subpass, RenderPass, RenderPassAbstract, Framebuffer, FramebufferAbstract, RenderPassDesc};
use vulkano::pipeline::shader::{GraphicsShaderType, ShaderModule, GraphicsEntryPoint, SpecializationConstants, SpecializationMapEntry};
use vulkano::swapchain::{Swapchain, PresentMode, SurfaceTransform, Surface, SwapchainCreationError, AcquireError};
use vulkano::swapchain::acquire_next_image;
@@ -26,7 +26,7 @@ use vulkano::image::swapchain::SwapchainImage;
use winit::{EventsLoop, WindowBuilder, Window, Event, WindowEvent};
use vulkano_win::VkSurfaceBuild;
use vulkano::pipeline::vertex::{SingleBufferDefinition, Vertex};
use vulkano::descriptor::PipelineLayoutAbstract;
use vulkano::descriptor::{PipelineLayoutAbstract, DescriptorSet};
use std::alloc::Layout;
use vulkano::pipeline::viewport::Viewport;
use image::ImageFormat;
@@ -37,6 +37,7 @@ use vulkano::format::Format;
use vulkano::sampler::{Sampler, Filter, MipmapMode, SamplerAddressMode};
use image::flat::NormalForm::ColumnMajorPacked;
use crate::vkprocessor::SimpleSpecializationConstants;
use crate::vertex_2d::ColoredVertex2D;
struct EntryPoint<'a> {
compiled_shaders: CompiledShaders,
@@ -46,35 +47,18 @@ struct EntryPoint<'a> {
fragment_shader_module: Arc<ShaderModule>,
}
#[derive(Default, Debug, Clone)]
struct tVertex { position: [f32; 2] }
#[derive(Clone)]
pub struct ShaderKernels {
pub swapchain : Arc<Swapchain<Window>>,
pub swapchain_images: Vec<Arc<SwapchainImage<Window>>>, // Surface which is drawn to
//pub physical: PhysicalDevice<'a>,
//shader: CompiledShaders,
//options: CompileOptions<'a>,
pub render_pass: Arc<RenderPassAbstract + Send + Sync>,
pub graphics_pipeline: Option<Arc<GraphicsPipelineAbstract + Sync + Send>>,
device: Arc<Device>,
// entry_point: EntryPoint<'a>,
}
// return the frame buffers
/*
let mut framebuffers =
window_size_dependent_setup(&self.images.clone().unwrap().clone(),
self.render_pass.clone().unwrap().clone(),
&mut self.dynamic_state);
*/
impl ShaderKernels {
fn get_path(filename: String) -> (PathBuf, PathBuf) {
@@ -237,7 +221,6 @@ impl ShaderKernels {
}
).unwrap());
vulkano::impl_vertex!(tVertex, position);
ShaderKernels {
@@ -250,7 +233,7 @@ impl ShaderKernels {
// We need to indicate the layout of the vertices.
// The type `SingleBufferDefinition` actually contains a template parameter corresponding
// to the type of each vertex. But in this code it is automatically inferred.
.vertex_input_single_buffer::<tVertex>()
.vertex_input_single_buffer::<ColoredVertex2D>()
// A Vulkan shader can in theory contain multiple entry points, so we have to specify
// which one. The `main` word of `main_entry_point` actually corresponds to the name of
@@ -261,7 +244,7 @@ impl ShaderKernels {
third_constant: 0.0,
})
// The content of the vertex buffer describes a list of triangles.
.triangle_fan()
.triangle_list_with_adjacency()
// Use a resizable viewport set to draw over the entire window
.viewports_dynamic_scissors_irrelevant(1)
// See `vertex_shader`.