server_rpw.cpp revision f0b06b8e4de2a0d9ddb10ac0a30d68fafd73d8c1
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/* $Id$ */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** @file
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VBox crOpenGL: Read Pixels worker
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/*
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Copyright (C) 2010-2013 Oracle Corporation
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * available from http://www.virtualbox.org. This file is free software;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * you can redistribute it and/or modify it under the terms of the GNU
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * General Public License (GPL) as published by the Free Software
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#include "server.h"
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#include "cr_string.h"
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#include "cr_mem.h"
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#include "cr_vreg.h"
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#include "render/renderspu.h"
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic void crServerRpwWorkerGpuSubmit(PRTLISTNODE pWorkList)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY *pCurEntry;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListForEach(pWorkList, pCurEntry, CR_SERVER_RPW_ENTRY, WorkerWorkEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, CR_SERVER_RPW_ENTRY_TEX(pCurEntry, Worker));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (CR_SERVER_RPW_ENTRY_PBO_IS_ACTIVE(pCurEntry))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, CR_SERVER_RPW_ENTRY_PBO_CUR(pCurEntry));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /*read the texture, note pixels are NULL for PBO case as it's offset in the buffer*/
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_PBO_FLIP(pCurEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync void *pvData = crAlloc(4*pCurEntry->Size.cx*pCurEntry->Size.cy);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (pvData)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pvData);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pCurEntry->pfnData(pCurEntry, pvData);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crFree(pvData);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync else
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync crWarning("crAlloc failed");
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, 0);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync}
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic void crServerRpwWorkerGpuComplete(PRTLISTNODE pGpuSubmitedList)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY *pCurEntry;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListForEach(pGpuSubmitedList, pCurEntry, CR_SERVER_RPW_ENTRY, GpuSubmittedEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(CR_SERVER_RPW_ENTRY_PBO_IS_ACTIVE(pCurEntry));
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, CR_SERVER_RPW_ENTRY_PBO_COMPLETED(pCurEntry));
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync void *pvData = cr_server.head_spu->dispatch_table.MapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pCurEntry->pfnData(pCurEntry, pvData);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.UnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync}
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic void crServerRpwWorkerGpuMarkGpuCompletedSubmitedLocked(PRTLISTNODE pGpuSubmitedList, PRTLISTNODE pWorkList)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY *pCurEntry, *pNextEntry;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListForEachSafe(pGpuSubmitedList, pCurEntry, pNextEntry, CR_SERVER_RPW_ENTRY, GpuSubmittedEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_INVALIDATE(pCurEntry, Gpu);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListNodeRemove(&pCurEntry->GpuSubmittedEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(RTListIsEmpty(pGpuSubmitedList));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListForEachSafe(pWorkList, pCurEntry, pNextEntry, CR_SERVER_RPW_ENTRY, WorkerWorkEntry)
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pCurEntry, Worker));
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync RTListNodeRemove(&pCurEntry->WorkerWorkEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (CR_SERVER_RPW_ENTRY_PBO_IS_ACTIVE(pCurEntry))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* PBO mode, put to the GPU submitted queue*/
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTListAppend(pGpuSubmitedList, &pCurEntry->GpuSubmittedEntry);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync CR_SERVER_RPW_ENTRY_TEX_PROMOTE(pCurEntry, Worker, Gpu);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* no PBO, we are already done entry data processing, free it right away */
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync Assert(!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pCurEntry, Gpu));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_INVALIDATE(pCurEntry, Worker);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic void crServerRpwWorkerGetWorkLocked(CR_SERVER_RPW *pWorker, PRTLISTNODE pWorkList)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY *pCurEntry, *pNextEntry;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListForEachSafe(&pWorker->WorkList, pCurEntry, pNextEntry, CR_SERVER_RPW_ENTRY, WorkEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListNodeRemove(&pCurEntry->WorkEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListAppend(pWorkList, &pCurEntry->WorkerWorkEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_PROMOTE(pCurEntry, Submitted, Worker);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsyncstatic DECLCALLBACK(int) crServerRpwWorkerThread(RTTHREAD ThreadSelf, void *pvUser)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW *pWorker = (CR_SERVER_RPW *)pvUser;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTMSINTERVAL cWaitMillis = RT_INDEFINITE_WAIT;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTLISTNODE WorkList, GpuSubmittedList;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_CTL_TYPE enmCtlType = CR_SERVER_RPW_CTL_TYPE_UNDEFINED;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync CR_SERVER_RPW_ENTRY *pCtlEntry = NULL;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRMuralInfo *pDummyMural = crServerGetDummyMural(pWorker->ctxVisBits);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync bool fExit = false;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync bool fForceComplete = false;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync CRASSERT(pDummyMural);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync int rc = RTSemEventSignal(pWorker->hSubmitEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync crWarning("RTSemEventSignal failed rc %d", rc);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync RTListInit(&WorkList);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListInit(&GpuSubmittedList);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync cr_server.head_spu->dispatch_table.MakeCurrent(pDummyMural->spuWindow, 0, pWorker->ctxId);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTCritSectEnter(&pWorker->CritSect);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync if (!RT_SUCCESS(rc))
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTCritSectEnter failed, rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync goto end;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync for (;;)
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* the crit sect is locked here */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (pWorker->Ctl.enmType != CR_SERVER_RPW_CTL_TYPE_UNDEFINED)
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync enmCtlType = pWorker->Ctl.enmType;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pCtlEntry = pWorker->Ctl.pEntry;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pWorker->Ctl.enmType = CR_SERVER_RPW_CTL_TYPE_UNDEFINED;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pWorker->Ctl.pEntry = NULL;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync crServerRpwWorkerGetWorkLocked(pWorker, &WorkList);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectLeave(&pWorker->CritSect);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (enmCtlType != CR_SERVER_RPW_CTL_TYPE_UNDEFINED)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync switch (enmCtlType)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync case CR_SERVER_RPW_CTL_TYPE_WAIT_COMPLETE:
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync break;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync case CR_SERVER_RPW_CTL_TYPE_TERM:
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync fExit = true;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync break;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync default:
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("unexpected CtlType %d", enmCtlType);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync break;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync enmCtlType = CR_SERVER_RPW_CTL_TYPE_UNDEFINED;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pCtlEntry = NULL;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync bool fNewItems = !RTListIsEmpty(&WorkList);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync bool fCompleted = false;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (fNewItems)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crServerRpwWorkerGpuSubmit(&WorkList);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RTListIsEmpty(&GpuSubmittedList))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (fForceComplete || fNewItems)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync crServerRpwWorkerGpuComplete(&GpuSubmittedList);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync fForceComplete = false;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync fCompleted = true;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTCritSectEnter(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTCritSectEnter failed, rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync break;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* fNewGpuItems means new entries arrived. WorkList contains new GPU submitted data
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * fCompleted means completion was performed, GpuSubmittedList contains old GPU submitted data,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * which is now completed and should be released */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (fNewItems || fCompleted)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crServerRpwWorkerGpuMarkGpuCompletedSubmitedLocked(&GpuSubmittedList, &WorkList);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (fExit || !fNewItems)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectLeave(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (fExit)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync break;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RTListIsEmpty(&GpuSubmittedList))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cWaitMillis = 17; /* ~60Hz */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cWaitMillis = RT_INDEFINITE_WAIT;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTSemEventWait(pWorker->hSubmitEvent, cWaitMillis);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc) && rc != VERR_TIMEOUT)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTSemEventWait failed, rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync break;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (rc == VERR_TIMEOUT)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(!RTListIsEmpty(&GpuSubmittedList));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync fForceComplete = true;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncend:
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.MakeCurrent(0, 0, 0);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic int crServerRpwCtlNotify(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = RTSemEventSignal(pWorker->hSubmitEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTSemEventWait(pWorker->Ctl.hCompleteEvent, RT_INDEFINITE_WAIT);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = pWorker->Ctl.rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("WdCtl command failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTSemEventWait failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int tmpRc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTSemEventSignal failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync tmpRc = RTCritSectEnter(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(tmpRc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->Ctl.enmType = CR_SERVER_RPW_CTL_TYPE_UNDEFINED;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->Ctl.pEntry = NULL;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectLeave(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTSemEventSignal failed tmpRc %d", tmpRc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic int crServerRpwCtl(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_CTL_TYPE enmType, CR_SERVER_RPW_ENTRY *pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = RTCritSectEnter(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->Ctl.enmType = enmType;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->Ctl.pEntry = pEntry;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectLeave(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTCritSectEnter failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = crServerRpwCtlNotify(pWorker, pEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwCtlNotify failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwInit(CR_SERVER_RPW *pWorker)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync memset(pWorker, 0, sizeof (*pWorker));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListInit(&pWorker->WorkList);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTCritSectInit(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTSemEventCreate(&pWorker->hSubmitEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTSemEventCreate(&pWorker->Ctl.hCompleteEvent);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRASSERT(cr_server.MainContextInfo.CreateInfo.visualBits);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRASSERT(cr_server.MainContextInfo.SpuContext);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->ctxId = cr_server.head_spu->dispatch_table.CreateContext("", cr_server.MainContextInfo.CreateInfo.visualBits, cr_server.MainContextInfo.SpuContext);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (pWorker->ctxId)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRMuralInfo *pDummyMural;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->ctxVisBits = cr_server.MainContextInfo.CreateInfo.visualBits;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pDummyMural = crServerGetDummyMural(pWorker->ctxVisBits);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (pDummyMural)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* since CreateContext does not actually create it on some platforms, e.g. on win,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * we need to do MakeCurrent to ensure it is created.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * There is some black magic in doing that to work around ogl driver bugs
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * (i.e. we need to switch offscreen rendering off before doing make current) */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_CTX_SWITCH CtxSwitch;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_serverCtxSwitchPrepare(&CtxSwitch, NULL);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.Flush();
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.MakeCurrent(pDummyMural->spuWindow, 0, pWorker->ctxId);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (cr_server.currentCtxInfo)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRASSERT(cr_server.currentMural);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.MakeCurrent(cr_server.currentMural->spuWindow, 0,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.currentCtxInfo->SpuContext > 0 ? cr_server.currentCtxInfo->SpuContext : cr_server.MainContextInfo.SpuContext);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.MakeCurrent(CR_RENDER_DEFAULT_WINDOW_ID, 0, CR_RENDER_DEFAULT_CONTEXT_ID);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_serverCtxSwitchPostprocess(&CtxSwitch);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTThreadCreate(&pWorker->hThread, crServerRpwWorkerThread, pWorker, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "CrServerDw");
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTSemEventWait(pWorker->hSubmitEvent, RT_INDEFINITE_WAIT);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTSemEventWait failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTThreadCreate failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("Failed to get dummy mural");
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = VERR_GENERAL_FAILURE;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.DestroyContext(pWorker->ctxId);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("CreateContext failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTSemEventDestroy(pWorker->Ctl.hCompleteEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTSemEventCreate failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTSemEventDestroy(pWorker->hSubmitEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTSemEventCreate failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectDelete(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTCritSectInit failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwEntryResizeCleaned(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRContext *pContext;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!width || !height)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!cr_server.currentCtxInfo)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRMuralInfo *pDummy = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.visualBits);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!pDummy)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerGetDummyMural failed");
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VERR_GENERAL_FAILURE;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crServerPerformMakeCurrent(pDummy, &cr_server.MainContextInfo);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(width);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync Assert(height);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pContext = cr_server.currentCtxInfo->pContext;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync for (int i = 0; i < 4; ++i)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.GenTextures(1, &pEntry->aidWorkerTexs[i]);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, pEntry->aidWorkerTexs[i]);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexDraw = -pEntry->iTexDraw;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pContext->bufferobject.unpackBuffer->hwid);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (cr_server.bUsePBOForReadback)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync for (int i = 0; i < 2; ++i)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.GenBuffersARB(1, &pEntry->aidPBOs[i]);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pEntry->aidPBOs[i]);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width*height*4, 0, GL_STREAM_READ_ARB);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pContext->bufferobject.packBuffer->hwid);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iCurPBO = 0;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync GLuint uid = pContext->texture.unit[pContext->texture.curTextureUnit].currentTexture2D->hwid;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, uid);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->Size.cx = width;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->Size.cy = height;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crServerRpwEntryDbgVerify(pEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwEntryCleanup(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!pEntry->Size.cx)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = crServerRpwEntryCancel(pWorker, pEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwEntryCancel failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!cr_server.currentCtxInfo)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CRMuralInfo *pDummy = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.visualBits);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!pDummy)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerGetDummyMural failed");
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VERR_GENERAL_FAILURE;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crServerPerformMakeCurrent(pDummy, &cr_server.MainContextInfo);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.DeleteTextures(4, pEntry->aidWorkerTexs);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (CR_SERVER_RPW_ENTRY_PBO_IS_ACTIVE(pEntry))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync cr_server.head_spu->dispatch_table.DeleteBuffersARB(2, pEntry->aidPBOs);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync memset(pEntry->aidPBOs, 0, sizeof (pEntry->aidPBOs));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iCurPBO = -1;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync memset(pEntry->aidWorkerTexs, 0, sizeof (pEntry->aidWorkerTexs));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Submitted);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Worker);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Gpu);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexDraw = -1;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexSubmitted = -2;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexWorker = -3;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexGpu = -4;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->Size.cx = 0;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->Size.cy = 0;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwEntryResize(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!width || !height)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync width = 0;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync height = 0;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (width == pEntry->Size.cx && width == pEntry->Size.cy)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = crServerRpwEntryCleanup(pWorker, pEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwEntryCleanup failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = crServerRpwEntryResizeCleaned(pWorker, pEntry, width, height);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwEntryResizeCleaned failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwEntryInit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height, PFNCR_SERVER_RPW_DATA pfnData)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync memset(pEntry, 0, sizeof (*pEntry));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexDraw = -1;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexSubmitted = -2;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexWorker = -3;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iTexGpu = -4;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->iCurPBO = -1;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry->pfnData = pfnData;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = crServerRpwEntryResizeCleaned(pWorker, pEntry, width, height);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwEntryResizeCleaned failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwEntrySubmit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Draw))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("submitting empty entry, ignoting");
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(!pEntry->Size.cx);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(!pEntry->Size.cy);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VERR_INVALID_PARAMETER;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(pEntry->Size.cx);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(pEntry->Size.cy);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = RTCritSectEnter(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(pWorker->Ctl.enmType == CR_SERVER_RPW_CTL_TYPE_UNDEFINED);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Submitted))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_PROMOTE_KEEPVALID(pEntry, Draw, Submitted);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListAppend(&pWorker->WorkList, &pEntry->WorkEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_XCHG_VALID(pEntry, Draw, Submitted);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectLeave(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTSemEventSignal(pWorker->hSubmitEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTCritSectEnter failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic int crServerRpwEntryCancelCtl(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, CR_SERVER_RPW_CTL_TYPE enmType)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (CR_SERVER_RPW_CTL_TYPE_TERM == enmType && pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("Entry should be null for term request");
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pEntry = NULL;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = RTCritSectEnter(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Submitted))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_INVALIDATE(pEntry, Submitted);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListNodeRemove(&pEntry->WorkEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Worker) && !CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Gpu))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* can cancel it wight away */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectLeave(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY *pCurEntry, *pNextEntry;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListForEachSafe(&pWorker->WorkList, pCurEntry, pNextEntry, CR_SERVER_RPW_ENTRY, WorkEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pCurEntry, Submitted);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync CR_SERVER_RPW_ENTRY_TEX_INVALIDATE(pEntry, Submitted);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTListNodeRemove(&pCurEntry->WorkEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->Ctl.enmType = enmType;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pWorker->Ctl.pEntry = pEntry;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectLeave(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTCritSectEnter failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = crServerRpwCtlNotify(pWorker, pEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwCtlNotify failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwEntryWaitComplete(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = crServerRpwCtl(pWorker, CR_SERVER_RPW_CTL_TYPE_WAIT_COMPLETE, pEntry);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwCtl failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwEntryCancel(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return crServerRpwEntryCancelCtl(pWorker, pEntry, CR_SERVER_RPW_CTL_TYPE_WAIT_COMPLETE);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic int crServerRpwCtlTerm(CR_SERVER_RPW *pWorker)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = crServerRpwEntryCancelCtl(pWorker, NULL, CR_SERVER_RPW_CTL_TYPE_TERM);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwCtl failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncint crServerRpwTerm(CR_SERVER_RPW *pWorker)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = crServerRpwCtlTerm(pWorker);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("crServerRpwCtlTerm failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = RTThreadWait(pWorker->hThread, RT_INDEFINITE_WAIT, NULL);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (!RT_SUCCESS(rc))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync crWarning("RTThreadWait failed rc %d", rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return rc;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTSemEventDestroy(pWorker->Ctl.hCompleteEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTSemEventDestroy(pWorker->hSubmitEvent);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTCritSectDelete(&pWorker->CritSect);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync