已确认几个2D范例均可正常DEPTH TEST/WRITE,但在使用CAMERA后得出的无法写入DEPTH
This commit is contained in:
parent
13e9bd19e7
commit
4412766ddf
@ -116,8 +116,6 @@ private:
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetMainRenderPass(),device->GetExtent());
|
||||
pipeline_creater->SetDepthTest(false);
|
||||
pipeline_creater->SetDepthWrite(false);
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLE_FAN);
|
||||
|
||||
|
@ -139,8 +139,6 @@ private:
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetMainRenderPass(),device->GetExtent());
|
||||
pipeline_creater->SetDepthTest(true);
|
||||
pipeline_creater->SetDepthWrite(true);
|
||||
pipeline_creater->Set(PRIM_LINES);
|
||||
|
||||
pipeline_line=pipeline_creater->Create();
|
||||
@ -172,7 +170,7 @@ private:
|
||||
bool InitScene()
|
||||
{
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_twoside,descriptor_sets,ro_dome));
|
||||
//render_root.Add(db->CreateRenderableInstance(pipeline_twoside,descriptor_sets,ro_dome));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_twoside,descriptor_sets,ro_torus));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_cube ),translate(-10, 0, 5)*scale(10,10,10));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_sphere ),translate( 10, 0, 5)*scale(10,10,10));
|
||||
|
@ -301,11 +301,11 @@ public:
|
||||
|
||||
virtual void Draw()override
|
||||
{
|
||||
const uint32_t index=AcquireNextImage();
|
||||
|
||||
camera.Refresh(); //更新相机矩阵
|
||||
ubo_world_matrix->Write(&camera.matrix); //写入缓冲区
|
||||
|
||||
const uint32_t index=AcquireNextImage();
|
||||
|
||||
BuildCommandBuffer(index);
|
||||
|
||||
SubmitDraw(index);
|
||||
|
@ -105,8 +105,6 @@ private:
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetMainRenderPass(),device->GetExtent());
|
||||
pipeline_creater->SetDepthTest(false);
|
||||
pipeline_creater->SetDepthWrite(false);
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
|
@ -109,8 +109,6 @@ private:
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetMainRenderPass(),device->GetExtent());
|
||||
pipeline_creater->SetDepthTest(false);
|
||||
pipeline_creater->SetDepthWrite(false);
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
|
@ -150,8 +150,6 @@ private:
|
||||
{
|
||||
AutoDelete<vulkan::PipelineCreater>
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetMainRenderPass(),device->GetExtent());
|
||||
pipeline_creater->SetDepthTest(false);
|
||||
pipeline_creater->SetDepthWrite(false);
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
|
@ -125,7 +125,7 @@ public: //material相关
|
||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
}
|
||||
|
||||
Texture2D *CreateAttachmentTexture(const VkFormat video_format,uint32_t width,uint32_t height,const VkImageAspectFlags aspectMask,const VkImageUsageFlagBits usage,const VkImageLayout image_layout)
|
||||
Texture2D *CreateAttachmentTexture(const VkFormat video_format,uint32_t width,uint32_t height,const VkImageAspectFlags aspectMask,const uint usage,const VkImageLayout image_layout)
|
||||
{
|
||||
return CreateTexture2D(video_format,width,height,aspectMask,usage|VK_IMAGE_USAGE_SAMPLED_BIT,image_layout);
|
||||
}
|
||||
@ -142,7 +142,7 @@ public: //material相关
|
||||
{
|
||||
return CreateAttachmentTexture( video_format,width,height,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT,//|VK_IMAGE_ASPECT_STENCIL_BIT,
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,8 @@ public:
|
||||
void SetDepthCompareOp( VkCompareOp op) {depthStencilState.depthCompareOp=op;}
|
||||
void SetDepthBoundsTest(bool dbt) {depthStencilState.depthBoundsTestEnable=dbt;}
|
||||
void SetDepthBounds( float min_depth,
|
||||
float max_depth) {depthStencilState.minDepthBounds=min_depth;
|
||||
float max_depth) {depthStencilState.depthBoundsTestEnable=VK_TRUE;
|
||||
depthStencilState.minDepthBounds=min_depth;
|
||||
depthStencilState.maxDepthBounds=max_depth;}
|
||||
void SetStencilTest( bool st) {depthStencilState.stencilTestEnable=st;}
|
||||
|
||||
|
@ -8,7 +8,7 @@ layout(binding = 0) uniform WorldMatrix
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
mat4 mvp;
|
||||
mat3 normal;
|
||||
vec4 view_pos;
|
||||
} world;
|
||||
|
||||
layout(push_constant) uniform Consts {
|
||||
@ -21,5 +21,5 @@ void main()
|
||||
{
|
||||
FragmentColor=vec4(1.0);
|
||||
|
||||
gl_Position=vec4(Vertex,1.0)*pc.local_to_world*world.mvp;
|
||||
gl_Position=vec4(Vertex,1.0)*(pc.local_to_world*world.mvp);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ layout(binding = 0) uniform WorldMatrix
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
mat4 mvp;
|
||||
mat3 normal;
|
||||
vec4 view_pos;
|
||||
} world;
|
||||
|
||||
layout(push_constant) uniform Consts {
|
||||
@ -22,5 +22,5 @@ void main()
|
||||
{
|
||||
FragmentColor=Color;
|
||||
|
||||
gl_Position=vec4(Vertex,1.0)*pc.local_to_world*world.mvp;
|
||||
gl_Position=vec4(Vertex,1.0)*(pc.local_to_world*world.mvp);
|
||||
}
|
||||
|
@ -115,6 +115,12 @@ namespace
|
||||
swapchain_ci.imageColorSpace=VK_COLORSPACE_SRGB_NONLINEAR_KHR;
|
||||
swapchain_ci.imageUsage=VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
if(rsa->surface_caps.supportedUsageFlags&VK_IMAGE_USAGE_TRANSFER_SRC_BIT)
|
||||
swapchain_ci.imageUsage|=VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
|
||||
if(rsa->surface_caps.supportedUsageFlags&VK_IMAGE_USAGE_TRANSFER_DST_BIT)
|
||||
swapchain_ci.imageUsage|=VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
|
||||
uint32_t queueFamilyIndices[2]={rsa->graphics_family, rsa->present_family};
|
||||
if(rsa->graphics_family!=rsa->present_family)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user