Commit b854c12a authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Replace the GE_WRAP macro with a function.

parent bff2bbc9
...@@ -5087,6 +5087,12 @@ static inline void wined3d_resource_reference(struct wined3d_resource *resource) ...@@ -5087,6 +5087,12 @@ static inline void wined3d_resource_reference(struct wined3d_resource *resource)
resource->access_time = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head; resource->access_time = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head;
} }
static inline BOOL wined3d_ge_wrap(ULONG x, ULONG y)
{
return (x - y) < UINT_MAX / 2;
}
C_ASSERT(WINED3D_CS_QUEUE_SIZE < UINT_MAX / 4);
static inline void wined3d_resource_wait_idle(const struct wined3d_resource *resource) static inline void wined3d_resource_wait_idle(const struct wined3d_resource *resource)
{ {
const struct wined3d_cs *cs = resource->device->cs; const struct wined3d_cs *cs = resource->device->cs;
...@@ -5100,11 +5106,11 @@ static inline void wined3d_resource_wait_idle(const struct wined3d_resource *res ...@@ -5100,11 +5106,11 @@ static inline void wined3d_resource_wait_idle(const struct wined3d_resource *res
/* The basic idea is that a resource is busy if tail < access_time <= head. /* The basic idea is that a resource is busy if tail < access_time <= head.
* But we have to be careful about wrap-around of the head and tail. The * But we have to be careful about wrap-around of the head and tail. The
* GE_WRAP macro below considers x >= y if x - y is smaller than half the * wined3d_ge_wrap function considers x >= y if x - y is smaller than half the
* UINT range. Head is at most WINED3D_CS_QUEUE_SIZE ahead of tail, because * UINT range. Head is at most WINED3D_CS_QUEUE_SIZE ahead of tail, because
* otherwise the queue memory is considered full and queue_require_space * otherwise the queue memory is considered full and queue_require_space
* stalls. Thus GE_WRAP(head, tail) is always true. The C_ASSERT below ensures * stalls. Thus wined3d_ge_wrap(head, tail) is always true. The C_ASSERT above
* this in case we decide to grow the queue size in the future. * ensures this in case we decide to grow the queue size in the future.
* *
* It is possible that a resource has not been used for a long time and is idle, but the head and * It is possible that a resource has not been used for a long time and is idle, but the head and
* tail wrapped around in such a way that the previously set access time falls between head and tail. * tail wrapped around in such a way that the previously set access time falls between head and tail.
...@@ -5117,8 +5123,7 @@ static inline void wined3d_resource_wait_idle(const struct wined3d_resource *res ...@@ -5117,8 +5123,7 @@ static inline void wined3d_resource_wait_idle(const struct wined3d_resource *res
* Note that the access time is set before the command is submitted, so we have to wait until the * Note that the access time is set before the command is submitted, so we have to wait until the
* tail is bigger than access_time, not equal. */ * tail is bigger than access_time, not equal. */
#define GE_WRAP(x, y) (((x)-(y)) < (UINT_MAX / 2)) if (!wined3d_ge_wrap(head, access_time))
if (!GE_WRAP(head, access_time))
return; return;
while (1) while (1)
...@@ -5127,14 +5132,12 @@ static inline void wined3d_resource_wait_idle(const struct wined3d_resource *res ...@@ -5127,14 +5132,12 @@ static inline void wined3d_resource_wait_idle(const struct wined3d_resource *res
if (head == tail) /* Queue empty. */ if (head == tail) /* Queue empty. */
break; break;
if (!GE_WRAP(access_time, tail) && access_time != tail) if (!wined3d_ge_wrap(access_time, tail) && access_time != tail)
break; break;
YieldProcessor(); YieldProcessor();
} }
#undef GE_WRAP
} }
C_ASSERT(WINED3D_CS_QUEUE_SIZE < UINT_MAX / 4);
/* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
* fixed function semantics as D3DCOLOR or FLOAT16 */ * fixed function semantics as D3DCOLOR or FLOAT16 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment