alaingalvan / CrossWindow

💻📱 A cross platform system abstraction library written in C++ for managing windows and performing OS tasks.
https://alain.xyz/libraries/crosswindow
MIT License
632 stars 50 forks source link

Resize events are delayed (freezes the 04-cross-platform-hello-triangle for several seconds) #13

Open drywolf opened 2 years ago

drywolf commented 2 years ago

I am testing CrossWindow on Windows 10, mainly the 04-cross-platform-hello-triangle

When I pick one of the corners of the window and move my mouse around for a couple of seconds, and then let go of the mouse button, the CrossWindow freezes up completely and I have to wait a couple seconds more for it to render/respond again.

The problem is very likely caused by how event-queueing is implemented (i.e. class EventQueue) and how it is used by the Window class. The input events seem to get queued up during the resizing of the window, and CrossWindow only starts actually processing the events (emptying the queue) when the mouse button is released.

This also means that no content is visible in the window while it is being resized, but only white/black artifacts are shown. (Ideally the resizing would happen in realtime, and content will be shown at all times)

PS:

D3D12 log:

D3D12 MESSAGE: GPU-BASED VALIDATION: TRACE BEGIN: PreDraw [ EXECUTION MESSAGE #1014: BEGIN_EVENT]
D3D12 MESSAGE: GPU-BASED VALIDATION: TRACE END: PreDraw [ EXECUTION MESSAGE #1015: END_EVENT]
D3D12 ERROR: GPU-BASED VALIDATION: DrawInstanced, RenderTarget state invalid, Slot [0], Incompatible resource state: Resource: 0x000002AE7558FB70:'Unnamed ID3D12Resource Object', Subresource Index: [0], Resource State: D3D12_RESOURCE_STATE_[COMMON|PRESENT](0x0), Required State Bits: D3D12_RESOURCE_STATE_RENDER_TARGET(0x4), Draw Count [0], Dispatch Count [0], Command List: 0x000002AE75A5C9C0:'Unnamed ID3D12GraphicsCommandList Object',  [ EXECUTION ERROR #942: GPU_BASED_VALIDATION_INCOMPATIBLE_RESOURCE_STATE]
D3D12 ERROR: GPU-BASED VALIDATION: ResourceBarrier, StateBefore invalid, Barrier array index [0], Incompatible resource state: Resource: 0x000002AE7558FB70:'Unnamed ID3D12Resource Object', Subresource Index: [0], Resource State: D3D12_RESOURCE_STATE_[COMMON|PRESENT](0x0), Required State Bits: D3D12_RESOURCE_STATE_RENDER_TARGET(0x4), Draw Count [0], Dispatch Count [0], Command List: 0x000002AE75A5C9C0:'Unnamed ID3D12GraphicsCommandList Object',  [ EXECUTION ERROR #942: GPU_BASED_VALIDATION_INCOMPATIBLE_RESOURCE_STATE]
D3D12 ERROR: ID3D12CommandList::DrawIndexedInstanced: No pipeline state has been set in this command list.  The runtime will use a default no-op pipeline state. [ EXECUTION ERROR #1045: COMMAND_LIST_PIPELINE_STATE_NOT_SET]
D3D12 ERROR: ID3D12CommandQueue::ExecuteCommandLists: Using Draw on Command List (0x000002AE75A5C9C0:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]) of resource (0x000002AE75590920:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a render target.  Expected State Bits (all): 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET, Actual State: 0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Missing State: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]
D3D12 ERROR: ID3D12CommandQueue::ExecuteCommandLists: Using ResourceBarrier on Command List (0x000002AE75A5C9C0:'Unnamed ID3D12GraphicsCommandList Object'): Before state (0x4: D3D12_RESOURCE_STATE_RENDER_TARGET) of resource (0x000002AE75590920:'Unnamed ID3D12Resource Object') (subresource: 0) specified by transition barrier does not match with the state (0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]) specified in the previous call to ResourceBarrier [ RESOURCE_MANIPULATION ERROR #527: RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH]
D3D12 MESSAGE: GPU-BASED VALIDATION: TRACE BEGIN: PreDraw [ EXECUTION MESSAGE #1014: BEGIN_EVENT]
D3D12 MESSAGE: GPU-BASED VALIDATION: TRACE END: PreDraw [ EXECUTION MESSAGE #1015: END_EVENT]
D3D12 ERROR: GPU-BASED VALIDATION: DrawInstanced, RenderTarget state invalid, Slot [0], Incompatible resource state: Resource: 0x000002AE75590920:'Unnamed ID3D12Resource Object', Subresource Index: [0], Resource State: D3D12_RESOURCE_STATE_[COMMON|PRESENT](0x0), Required State Bits: D3D12_RESOURCE_STATE_RENDER_TARGET(0x4), Draw Count [0], Dispatch Count [0], Command List: 0x000002AE75A5C9C0:'Unnamed ID3D12GraphicsCommandList Object',  [ EXECUTION ERROR #942: GPU_BASED_VALIDATION_INCOMPATIBLE_RESOURCE_STATE]
D3D12 ERROR: GPU-BASED VALIDATION: ResourceBarrier, StateBefore invalid, Barrier array index [0], Incompatible resource state: Resource: 0x000002AE75590920:'Unnamed ID3D12Resource Object', Subresource Index: [0], Resource State: D3D12_RESOURCE_STATE_[COMMON|PRESENT](0x0), Required State Bits: D3D12_RESOURCE_STATE_RENDER_TARGET(0x4), Draw Count [0], Dispatch Count [0], Command List: 0x000002AE75A5C9C0:'Unnamed ID3D12GraphicsCommandList Object',  [ EXECUTION ERROR #942: GPU_BASED_VALIDATION_INCOMPATIBLE_RESOURCE_STATE]
D3D12 ERROR: ID3D12CommandList::DrawIndexedInstanced: No pipeline state has been set in this command list.  The runtime will use a default no-op pipeline state. [ EXECUTION ERROR #1045: COMMAND_LIST_PIPELINE_STATE_NOT_SET]
D3D12 ERROR: ID3D12CommandQueue::ExecuteCommandLists: Using Draw on Command List (0x000002AE75A5C9C0:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]) of resource (0x000002AE7558FB70:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a render target.  Expected State Bits (all): 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET, Actual State: 0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Missing State: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]

D3D11 log:

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]