mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-01-19 11:52:16 +01:00
started adding support for present modes
This commit is contained in:
parent
4290dcd39d
commit
53db3a60d8
@ -253,6 +253,23 @@ void modeset_destroy_fb(int fd, _image* buf)
|
||||
drmModeRmFB(fd, buf->fb);
|
||||
}
|
||||
|
||||
typedef struct vsyncData
|
||||
{
|
||||
_image* i;
|
||||
modeset_display_surface* s;
|
||||
} vsyncData;
|
||||
|
||||
static void modeset_page_flip_event(int fd, unsigned int frame,
|
||||
unsigned int sec, unsigned int usec,
|
||||
void *data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
vsyncData* d = data;
|
||||
//TODO image is now available for rendering
|
||||
}
|
||||
}
|
||||
|
||||
void modeset_present(int fd, _image *buf, modeset_display_surface* surface)
|
||||
{
|
||||
if(!surface->savedState)
|
||||
@ -277,15 +294,26 @@ void modeset_present(int fd, _image *buf, modeset_display_surface* surface)
|
||||
int ret = drmModeSetCrtc(fd, surface->crtc->crtc_id, buf->fb, 0, 0, &surface->connector->connector_id, 1, &surface->connector->modes[surface->modeID]);
|
||||
if(ret)
|
||||
{
|
||||
fprintf(stderr, "cannot flip CRTC for connector %u (%d): %m\n",
|
||||
fprintf(stderr, "cannot set CRTC for connector %u: %m\n",
|
||||
surface->connector->connector_id, errno);
|
||||
}
|
||||
|
||||
saved_state_guard = 0;
|
||||
}
|
||||
|
||||
//TODO add vsync support eventually
|
||||
drmModePageFlip(fd, surface->crtc->crtc_id, buf->fb, 0, 0);
|
||||
//TODO use DRM_MODE_PAGE_FLIP_EVENT to catch when an image can be used again (eg. for acquireimagekhr)
|
||||
|
||||
if(buf->presentMode == VK_PRESENT_MODE_IMMEDIATE_KHR)
|
||||
{
|
||||
drmModePageFlip(fd, surface->crtc->crtc_id, buf->fb, DRM_MODE_PAGE_FLIP_ASYNC, 0);
|
||||
}
|
||||
else if(buf->presentMode == VK_PRESENT_MODE_FIFO_KHR)
|
||||
{
|
||||
vsyncData d;
|
||||
d.i = buf;
|
||||
d.s = surface;
|
||||
drmModePageFlip(fd, surface->crtc->crtc_id, buf->fb, DRM_MODE_PAGE_FLIP_EVENT, 0);
|
||||
}
|
||||
|
||||
//modeset_debug_print(fd);
|
||||
}
|
||||
|
@ -581,10 +581,8 @@ static VkPerformanceCounterDescriptionKHR performanceCounterDescriptions[] =
|
||||
|
||||
static VkPresentModeKHR supportedPresentModes[] =
|
||||
{
|
||||
//VK_PRESENT_MODE_IMMEDIATE_KHR,
|
||||
//VK_PRESENT_MODE_MAILBOX_KHR,
|
||||
VK_PRESENT_MODE_FIFO_KHR,
|
||||
//VK_PRESENT_MODE_FIFO_RELAXED_KHR
|
||||
VK_PRESENT_MODE_IMMEDIATE_KHR,
|
||||
VK_PRESENT_MODE_FIFO_KHR
|
||||
};
|
||||
|
||||
#define numSupportedPresentModes (sizeof(supportedPresentModes)/sizeof(VkPresentModeKHR))
|
||||
|
18
driver/wsi.c
18
driver/wsi.c
@ -184,14 +184,14 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkGetPhysicalDeviceSurfaceCapabilitiesKHR
|
||||
pSurfaceCapabilities->maxImageCount = 2; //TODO max 2 for double buffering for now...
|
||||
pSurfaceCapabilities->currentExtent.width = width;
|
||||
pSurfaceCapabilities->currentExtent.height = height;
|
||||
pSurfaceCapabilities->minImageExtent.width = width; //TODO
|
||||
pSurfaceCapabilities->minImageExtent.height = height; //TODO
|
||||
pSurfaceCapabilities->maxImageExtent.width = width; //TODO
|
||||
pSurfaceCapabilities->maxImageExtent.height = height; //TODO
|
||||
pSurfaceCapabilities->minImageExtent.width = width;
|
||||
pSurfaceCapabilities->minImageExtent.height = height;
|
||||
pSurfaceCapabilities->maxImageExtent.width = width;
|
||||
pSurfaceCapabilities->maxImageExtent.height = height;
|
||||
pSurfaceCapabilities->maxImageArrayLayers = 1;
|
||||
pSurfaceCapabilities->supportedTransforms = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; //TODO no rotation for now
|
||||
pSurfaceCapabilities->currentTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; //TODO get this from dev
|
||||
pSurfaceCapabilities->supportedCompositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; //TODO no alpha compositing for now
|
||||
pSurfaceCapabilities->supportedTransforms = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||
pSurfaceCapabilities->currentTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||
pSurfaceCapabilities->supportedCompositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||
pSurfaceCapabilities->supportedUsageFlags =
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | //well we want to draw on the screen right
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT | //for clears
|
||||
@ -286,7 +286,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkGetPhysicalDeviceSurfacePresentModesKHR
|
||||
|
||||
for(int c = 0; c < elementsWritten; ++c)
|
||||
{
|
||||
//TODO
|
||||
pPresentModes[c] = supportedPresentModes[c];
|
||||
}
|
||||
|
||||
@ -327,7 +326,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkCreateSwapchainKHR)(
|
||||
_swapchain* s = *pSwapchain;
|
||||
|
||||
//TODO flags, layers, queue sharing, pretransform, composite alpha..., clipped, oldswapchain
|
||||
//TODO present mode
|
||||
|
||||
s->images = ALLOCATE(sizeof(_image) * pCreateInfo->minImageCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if(!s->images)
|
||||
@ -515,8 +513,6 @@ VKAPI_ATTR VkResult VKAPI_CALL RPIFUNC(vkQueuePresentKHR)(
|
||||
PROFILEEND(&frameProfile);
|
||||
}
|
||||
|
||||
//TODO vsync flip modes etc.
|
||||
|
||||
assert(queue);
|
||||
assert(pPresentInfo);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user