Пример #1
0
TEST_F(MapaDBTest, noDeberiaEjecutarBatchEnQueFallaraUnaAccion) {
    Batch batch;
    batch.put("key", "value");
    batch.modify("key2", "value2"); // No existe key2, este falla
    EXPECT_FALSE(db->writeBatch(batch));
    EXPECT_THROW(db->get("key"), KeyNotFound);
}
Пример #2
0
void GLBackend::renderPassDraw(Batch& batch) {
    _transform._objectsItr = _transform._objectOffsets.begin();
    _transform._camerasItr = _transform._cameraOffsets.begin();
    const size_t numCommands = batch.getCommands().size();
    const Batch::Commands::value_type* command = batch.getCommands().data();
    const Batch::CommandOffsets::value_type* offset = batch.getCommandOffsets().data();
    for (_commandIndex = 0; _commandIndex < numCommands; ++_commandIndex) {
        switch (*command) {
            // Ignore these commands on this pass, taken care of in the transfer pass
            // Note we allow COMMAND_setViewportTransform to occur in both passes
            // as it both updates the transform object (and thus the uniforms in the 
            // UBO) as well as executes the actual viewport call
            case Batch::COMMAND_setModelTransform:
            case Batch::COMMAND_setViewTransform:
            case Batch::COMMAND_setProjectionTransform:
                break;

            default: {
                CommandCall call = _commandCalls[(*command)];
                (this->*(call))(batch, *offset);
                break;
            }
        }

        command++;
        offset++;
    }
}
Пример #3
0
void GLBackend::render(const Batch& batch) {
    _transform._skybox = _stereo._skybox = batch.isSkyboxEnabled();
    // Allow the batch to override the rendering stereo settings
    // for things like full framebuffer copy operations (deferred lighting passes)
    bool savedStereo = _stereo._enable;
    if (!batch.isStereoEnabled()) {
        _stereo._enable = false;
    }
	// Reset jitter
	_transform._projectionJitter = Vec2(0.0f, 0.0f);
    
    {
        PROFILE_RANGE(render_gpu_gl_detail, "Transfer");
        renderPassTransfer(batch);
    }

#ifdef GPU_STEREO_DRAWCALL_INSTANCED
    if (_stereo.isStereo()) {
        glEnable(GL_CLIP_DISTANCE0);
    }
#endif
    {
        PROFILE_RANGE(render_gpu_gl_detail, _stereo.isStereo() ? "Render Stereo" : "Render");
        renderPassDraw(batch);
    }
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
    if (_stereo.isStereo()) {
        glDisable(GL_CLIP_DISTANCE0);
    }
#endif

    // Restore the saved stereo state for the next batch
    _stereo._enable = savedStereo;
}
Пример #4
0
Batch ManejadorMetadatos::armarBatchEliminarArchivo (const string& jsonMetadatos, const string& username,
        const string& filepath, const string& pathCompletoPapelera) {
    Batch batch;
    string jsonMetadatosConFechaModif = this->actualizarUsuarioFechaModificacion(jsonMetadatos, username);
    MetadatoArchivo metadatoConFechaModif = ParserJson::deserializarMetadatoArchivo(jsonMetadatosConFechaModif);
    for (auto &usuario : metadatoConFechaModif.usuariosHabilitados) {
        if (usuario == metadatoConFechaModif.propietario)
            continue;

        string permisosUsuario = PERMISOS + "/" + usuario;
        if (validador->existeMetadato(permisosUsuario)) {
            string archivosStr = dbMetadatos->get(permisosUsuario);
            vector<string> archivos = ParserURI::parsear(archivosStr, RESERVED_CHAR);
            archivos.erase(remove(archivos.begin(), archivos.end(), filepath), archivos.end());
            string joined = ParserURI::join(archivos, RESERVED_CHAR);
            batch.modify(permisosUsuario, joined);
        } else {
            Logger::logWarn("No existe en dbMetadatos " + permisosUsuario + " al armar batch de eliminar archivo");
        }
    }
    metadatoConFechaModif.usuariosHabilitados.clear();
    metadatoConFechaModif.usuariosHabilitados.push_back(metadatoConFechaModif.propietario);
    string nuevoJson = ParserJson::serializarMetadatoArchivo(metadatoConFechaModif);

    batch.erase(filepath);
    batch.put(pathCompletoPapelera, nuevoJson);
    return batch;
}
Пример #5
0
bool ManejadorMetadatos::agregarPermiso (string usernameOrigen, string filepath, string usernameDestino) {
    if (not validador->verificarPermisos(usernameOrigen, filepath))
        return false;
    if (not dbMetadatos->contains(filepath)) {
        Logger::logWarn("Se quiso agregar un permiso al archivo " + filepath + " pero este no existe.");
        return false;
    }
    string pathPermisos = PERMISOS + "/" + usernameDestino;
    if (not dbMetadatos->contains(pathPermisos)) {
        Logger::logWarn("Se quiso agregar un permiso al usuario " + usernameDestino + " pero este no existe.");
        return false;
    }
    string jsonArchivo = dbMetadatos->get(filepath);

    MetadatoArchivo metadato = ParserJson::deserializarMetadatoArchivo(jsonArchivo);
    metadato.usuariosHabilitados.push_back(usernameDestino);
    string jsonModificado = ParserJson::serializarMetadatoArchivo(metadato);

    Batch batch;
    batch.modify(filepath, jsonModificado);
//	Como este metodo se llama directamente desde actualizarMetadatos, ya la fecha viene modificada

    string archivosPermitidos = dbMetadatos->get(pathPermisos);
    if (archivosPermitidos != "")
        archivosPermitidos += RESERVED_CHAR;
    archivosPermitidos += filepath;
    batch.modify(pathPermisos, archivosPermitidos);
    dbMetadatos->writeBatch(batch);

    return true;
}
Пример #6
0
void GLBackend::render(Batch& batch) {
    // Finalize the batch by moving all the instanced rendering into the command buffer
    batch.preExecute();

    _stereo._skybox = batch.isSkyboxEnabled();
    // Allow the batch to override the rendering stereo settings
    // for things like full framebuffer copy operations (deferred lighting passes)
    bool savedStereo = _stereo._enable;
    if (!batch.isStereoEnabled()) {
        _stereo._enable = false;
    }

    {
        PROFILE_RANGE("Transfer");
        renderPassTransfer(batch);
    }

    {
        PROFILE_RANGE(_stereo._enable ? "LeftRender" : "Render");
        renderPassDraw(batch);
    }

    if (_stereo._enable) {
        PROFILE_RANGE("RightRender");
        _stereo._pass = 1;
        renderPassDraw(batch);
        _stereo._pass = 0;
    }

    // Restore the saved stereo state for the next batch
    _stereo._enable = savedStereo;
}
Пример #7
0
TEST_F(MapaDBTest, deberiaEjecutarUnBatchDePutsCorrectoCompleto) {
    Batch batch;
    batch.put("key", "value");
    batch.put("key2", "value2");
    db->writeBatch(batch);
    EXPECT_EQ("value", db->get("key"));
    EXPECT_EQ("value2", db->get("key2"));
}
Пример #8
0
void Chunk::addCube(Batch& batch, uint8_t x, uint8_t y, uint8_t z)
{
	std::vector<glm::vec3> vertices(6 * 6);
	std::vector<glm::vec2> texCoords(6 * 6);

    glm::vec3 v0(x, y, z);
    glm::vec3 v1(x, y + 1.0f, z);
    glm::vec3 v2(x + 1.0f, y, z);
    glm::vec3 v3(x + 1.0f, y + 1.0f, z);
    glm::vec3 v4(x, y + 1.0f, z + 1.0f);
    glm::vec3 v5(x, y, z + 1.0f);
    glm::vec3 v6(x + 1.0f, y, z + 1.0f);
    glm::vec3 v7(x + 1.0f, y + 1.0f, z + 1.0f);   

	glm::vec2 t0(0.0f, 0.0f);
	glm::vec2 t1(0.0f, 1.0f);
	glm::vec2 t2(1.0f, 0.0f);
	glm::vec2 t3(1.0f, 1.0f);

    // Front Face
    vertices.push_back(v1); vertices.push_back(v0); vertices.push_back(v2);
	texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
    vertices.push_back(v2); vertices.push_back(v3); vertices.push_back(v1);
	texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);
    
    // Right Face
	vertices.push_back(v3); vertices.push_back(v2); vertices.push_back(v6);
	texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
	vertices.push_back(v6); vertices.push_back(v7); vertices.push_back(v3);
	texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);

    // Back Face
	vertices.push_back(v7); vertices.push_back(v6); vertices.push_back(v5);
	texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
	vertices.push_back(v5); vertices.push_back(v4); vertices.push_back(v7);
	texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);

    // Left Face
	vertices.push_back(v4); vertices.push_back(v5); vertices.push_back(v0);
	texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
	vertices.push_back(v0); vertices.push_back(v1); vertices.push_back(v4);
	texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);

    // Top Face
	vertices.push_back(v4); vertices.push_back(v1); vertices.push_back(v3);
	texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
	vertices.push_back(v3); vertices.push_back(v7); vertices.push_back(v4);
	texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);

    // Bottom Face
	vertices.push_back(v0); vertices.push_back(v5); vertices.push_back(v6);
	texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
	vertices.push_back(v6); vertices.push_back(v2); vertices.push_back(v0);
	texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);

	batch.vertices(vertices);
	batch.textures(texCoords);
}
Пример #9
0
bool ManejadorMetadatos::restaurarMetadatos (const string& pathEnPapeleraSinFS, const string& username,
        const string& pathRealSinFS) {
    string metadatosJson = dbMetadatos->get(pathEnPapeleraSinFS);
    string nuevosMetadatosJson = this->actualizarUsuarioFechaModificacion(metadatosJson, username);
    Batch batch;
    batch.erase(pathEnPapeleraSinFS);
    batch.put(pathRealSinFS, nuevosMetadatosJson);
    return dbMetadatos->writeBatch(batch);
}
Пример #10
0
nsresult sbMockDevice::ProcessBatch(Batch & aBatch)
{
  std::insert_iterator<std::vector<nsRefPtr<sbRequestItem> > >
    insertIter(mBatch, mBatch.end());
  std::copy(aBatch.begin(), aBatch.end(), insertIter);

  /* don't process, let the js deal with it */
  return NS_OK;
}
Пример #11
0
TEST_F(MapaDBTest, deberiaEjecutarUnBatchModifyEraseCorrectoCompleto) {
    db->put("key", "value");
    db->put("key2", "value2");
    Batch batch;
    batch.modify("key", "otro");
    batch.erase("key2");
    ASSERT_TRUE(db->writeBatch(batch));
    EXPECT_EQ("otro", db->get("key"));
    EXPECT_FALSE(db->contains("key2"));
}
Пример #12
0
void GLBackend::renderPassTransfer(Batch& batch) {
    const size_t numCommands = batch.getCommands().size();
    const Batch::Commands::value_type* command = batch.getCommands().data();
    const Batch::CommandOffsets::value_type* offset = batch.getCommandOffsets().data();

    { // Sync all the buffers
        PROFILE_RANGE("syncGPUBuffer");

        for (auto& cached : batch._buffers._items) {
            if (cached._data) {
                syncGPUObject(*cached._data);
            }
        }
    }

    { // Sync all the buffers
        PROFILE_RANGE("syncCPUTransform");
        _transform._cameras.clear();
        _transform._cameraOffsets.clear();

        for (_commandIndex = 0; _commandIndex < numCommands; ++_commandIndex) {
            switch (*command) {
                case Batch::COMMAND_draw:
                case Batch::COMMAND_drawIndexed:
                case Batch::COMMAND_drawInstanced:
                case Batch::COMMAND_drawIndexedInstanced:
                case Batch::COMMAND_multiDrawIndirect:
                case Batch::COMMAND_multiDrawIndexedIndirect:
                    _transform.preUpdate(_commandIndex, _stereo);
                    break;

                case Batch::COMMAND_setViewportTransform:
                case Batch::COMMAND_setViewTransform:
                case Batch::COMMAND_setProjectionTransform: {
                    CommandCall call = _commandCalls[(*command)];
                    (this->*(call))(batch, *offset);
                    break;
                }

                default:
                    break;
            }
            command++;
            offset++;
        }
    }

    { // Sync the transform buffers
        PROFILE_RANGE("syncGPUTransform");
        _transform.transfer(batch);
    }


}
void OplogBufferCollection::pushEvenIfFull(OperationContext* txn, const Value& value) {
    // This oplog entry is a sentinel
    if (value.isEmpty()) {
        stdx::lock_guard<stdx::mutex> lk(_mutex);
        _sentinels.push(_lastPushedTimestamp);
        _count++;
        _cvNoLongerEmpty.notify_all();
        return;
    }
    Batch valueBatch = {value};
    pushAllNonBlocking(txn, valueBatch.begin(), valueBatch.end());
}
Пример #14
0
void GLBackend::render(Batch& batch) {

    uint32 numCommands = batch.getCommands().size();
    const Batch::Commands::value_type* command = batch.getCommands().data();
    const Batch::CommandOffsets::value_type* offset = batch.getCommandOffsets().data();

    for (unsigned int i = 0; i < numCommands; i++) {
        CommandCall call = _commandCalls[(*command)];
        (this->*(call))(batch, *offset);
        command++;
        offset++;
    }
}
nsresult sbRequestThreadQueue::PopBatch(Batch & aBatch)
{
  TRACE_FUNCTION("");
  NS_ENSURE_STATE(mLock);

  nsAutoLock lock(mLock);

  aBatch.clear();

  // If nothing was found then just return with an empty batch
  if (mRequestQueue.empty()) {
    LOG("No requests found\n");
    return NS_OK;
  }

  // If we're in the middle of a batch just return an empty batch
  if (mBatchDepth > 0) {
    LOG("Waiting on batch to complete\n");
    return NS_OK;
  }
  RequestQueue::iterator queueIter = mRequestQueue.begin();
  // request queue holds on to the object
  sbRequestItem * request = *queueIter;

  // If this isn't countable just return it by itself
  if (!request->GetIsCountable()) {
    LOG("Single non-batch request found\n");
    aBatch.push_back(request);
    mRequestQueue.erase(queueIter);
    // Release our reference to the request, aBatch is holding a reference to it
    NS_RELEASE(request);
    return NS_OK;
  }

  const PRUint32 requestBatchId = request->GetBatchId();

  // find the end of the batch and keep track of the matching batch entries
  const RequestQueue::const_iterator queueEnd = mRequestQueue.end();
  while (queueIter != queueEnd &&
         requestBatchId == (*queueIter)->GetBatchId()) {
    request = *queueIter++;
    aBatch.push_back(request);
    // Release our reference to the request, aBatch is holding a reference to it
    NS_RELEASE(request);
  }

  // Remove all the items we pushed onto the batch
  mRequestQueue.erase(mRequestQueue.begin(), queueIter);

  return NS_OK;
}
Пример #16
0
void ManejadorMetadatos::actualizarPermisosPorRenombrado (const string& filepath, const string& nuevoFilename,
        const MetadatoArchivo& metadatosNuevos, const string& nuevoJson) {
    MetadatoArchivo metadatosViejos = ParserJson::deserializarMetadatoArchivo(dbMetadatos->get(filepath));
    string nuevoFilepath = ParserURI::pathConNuevoFilename(filepath, nuevoFilename);
    list<string> usuariosHabilitados = (metadatosNuevos.usuariosHabilitados.empty()) ?
                                       metadatosViejos.usuariosHabilitados : metadatosNuevos.usuariosHabilitados;
    usuariosHabilitados.remove(metadatosNuevos.propietario);
    if ( not usuariosHabilitados.empty() ) //Si estaba compartido
        actualizarPermisosPathArchivo(filepath, nuevoFilepath, usuariosHabilitados);	// actualiza el path del archivo en quienes tienen permiso
    Batch batch;
    batch.erase(filepath);
    batch.put(nuevoFilepath, nuevoJson);
    dbMetadatos->writeBatch(batch);
}
Пример #17
0
BatchPointer Context::acquireBatch(const char* name) {
    Batch* rawBatch = nullptr;
    {
        Lock lock(_batchPoolMutex);
        if (!_batchPool.empty()) {
            rawBatch = _batchPool.front();
            _batchPool.pop_front();
        }
    }
    if (!rawBatch) {
        rawBatch = new Batch();
    }
    rawBatch->setName(name);
    return BatchPointer(rawBatch, [this](Batch* batch) { releaseBatch(batch); });
}
Пример #18
0
void GLBackend::do_setViewportTransform(const Batch& batch, size_t paramOffset) {
    memcpy(&_transform._viewport, batch.readData(batch._params[paramOffset]._uint), sizeof(Vec4i));

#ifdef GPU_STEREO_DRAWCALL_INSTANCED
    {
        ivec4& vp = _transform._viewport;
        glViewport(vp.x, vp.y, vp.z, vp.w);

        // Where we assign the GL viewport
        if (_stereo.isStereo()) {
            vp.z /= 2;
            if (_stereo._pass) {
                vp.x += vp.z;
            }
        }
    }
#else
    if (!_inRenderTransferPass && !isStereo()) {
        ivec4& vp = _transform._viewport;
        glViewport(vp.x, vp.y, vp.z, vp.w);
    }
#endif

    // The Viewport is tagged invalid because the CameraTransformUBO is not up to date and will need update on next drawcall
    _transform._invalidViewport = true;
}
Пример #19
0
void GLBackend::do_glUniformMatrix4fv(Batch& batch, uint32 paramOffset) {
    glUniformMatrix4fv(
        batch._params[paramOffset + 3]._int,
        batch._params[paramOffset + 2]._uint,
        batch._params[paramOffset + 1]._uint,
        (const GLfloat*)batch.editData(batch._params[paramOffset + 0]._uint));
    (void) CHECK_GL_ERROR();
}
Пример #20
0
    void testBackend (beast::String type, std::int64_t const seedValue,
                      int numObjectsToTest = 2000)
    {
        std::unique_ptr <Manager> manager (make_Manager ());

        DummyScheduler scheduler;

        testcase ((beast::String ("Backend type=") + type).toStdString());

        beast::StringPairArray params;
        beast::File const path (beast::File::createTempFile ("node_db"));
        params.set ("type", type);
        params.set ("path", path.getFullPathName ());

        // Create a batch
        Batch batch;
        createPredictableBatch (batch, 0, numObjectsToTest, seedValue);

        beast::Journal j;

        {
            // Open the backend
            std::unique_ptr <Backend> backend (manager->make_Backend (
                                                   params, scheduler, j));

            // Write the batch
            storeBatch (*backend, batch);

            {
                // Read it back in
                Batch copy;
                fetchCopyOfBatch (*backend, &copy, batch);
                expect (areBatchesEqual (batch, copy), "Should be equal");
            }

            {
                // Reorder and read the copy again
                Batch copy;
                beast::UnitTestUtilities::repeatableShuffle (batch.size (), batch, seedValue);
                fetchCopyOfBatch (*backend, &copy, batch);
                expect (areBatchesEqual (batch, copy), "Should be equal");
            }
        }

        {
            // Re-open the backend
            std::unique_ptr <Backend> backend (manager->make_Backend (
                                                   params, scheduler, j));

            // Read it back in
            Batch copy;
            fetchCopyOfBatch (*backend, &copy, batch);
            // Canonicalize the source and destination batches
            std::sort (batch.begin (), batch.end (), NodeObject::LessThan ());
            std::sort (copy.begin (), copy.end (), NodeObject::LessThan ());
            expect (areBatchesEqual (batch, copy), "Should be equal");
        }
    }
Пример #21
0
void RecordGUI::update_batch_tools()
{
//printf("RecordGUI::update_batch_tools 1\n");
	char string[BCTEXTLEN];
	Batch *batch = record->get_editing_batch();
	batch_path->update(batch->get_current_asset()->path);

// File is open in editing batch
// 	if(record->current_batch == record->editing_batch && record->file)
// 		batch_path->disable();
// 	else
// 		batch_path->enable();

	batch_start->update(&batch->start_day, &batch->start_time);
	batch_duration->update(0, &batch->duration);
	batch_source->update(batch->get_source_text());
	batch_mode->update(Batch::mode_to_text(batch->record_mode));
	flush();
}
bool InstancedRendering::Batch::onCombineIfPossible(GrBatch* other, const GrCaps& caps) {
    Batch* that = static_cast<Batch*>(other);
    SkASSERT(fInstancedRendering == that->fInstancedRendering);
    SkASSERT(fTailDraw);
    SkASSERT(that->fTailDraw);

    if (!BatchInfo::CanCombine(fInfo, that->fInfo) ||
        !GrPipeline::CanCombine(*this->pipeline(), this->bounds(),
                                *that->pipeline(), that->bounds(), caps)) {
        return false;
    }

    BatchInfo combinedInfo = fInfo | that->fInfo;
    if (!combinedInfo.isSimpleRects()) {
        // This threshold was chosen with the "shapes_mixed" bench on a MacBook with Intel graphics.
        // There seems to be a wide range where it doesn't matter if we combine or not. What matters
        // is that the itty bitty rects combine with other shapes and the giant ones don't.
        constexpr SkScalar kMaxPixelsToGeneralizeRects = 256 * 256;
        if (fInfo.isSimpleRects() && fPixelLoad > kMaxPixelsToGeneralizeRects) {
            return false;
        }
        if (that->fInfo.isSimpleRects() && that->fPixelLoad > kMaxPixelsToGeneralizeRects) {
            return false;
        }
    }

    this->joinBounds(*that);
    fInfo = combinedInfo;
    fPixelLoad += that->fPixelLoad;

    // Adopt the other batch's draws.
    fNumDraws += that->fNumDraws;
    fNumChangesInGeometry += that->fNumChangesInGeometry;
    if (fTailDraw->fGeometry != that->fHeadDraw->fGeometry) {
        ++fNumChangesInGeometry;
    }
    fTailDraw->fNext = that->fHeadDraw;
    fTailDraw = that->fTailDraw;

    that->fHeadDraw = that->fTailDraw = nullptr;

    return true;
}
Пример #23
0
void BatchQueue::Draw(View* view, bool markToStencil, bool usingLightOptimization) const
{
    Graphics* graphics = view->GetGraphics();
    Renderer* renderer = view->GetRenderer();
    
    // If View has set up its own light optimizations, do not disturb the stencil/scissor test settings
    if (!usingLightOptimization)
    {
        graphics->SetScissorTest(false);
        
        // During G-buffer rendering, mark opaque pixels' lightmask to stencil buffer if requested
        if (!markToStencil)
            graphics->SetStencilTest(false);
    }
    
    // Instanced
    for (PODVector<BatchGroup*>::ConstIterator i = sortedBatchGroups_.Begin(); i != sortedBatchGroups_.End(); ++i)
    {
        BatchGroup* group = *i;
        if (markToStencil)
            graphics->SetStencilTest(true, CMP_ALWAYS, OP_REF, OP_KEEP, OP_KEEP, group->lightMask_);
        
        group->Draw(view);
    }
    // Non-instanced
    for (PODVector<Batch*>::ConstIterator i = sortedBatches_.Begin(); i != sortedBatches_.End(); ++i)
    {
        Batch* batch = *i;
        if (markToStencil)
            graphics->SetStencilTest(true, CMP_ALWAYS, OP_REF, OP_KEEP, OP_KEEP, batch->lightMask_);
        if (!usingLightOptimization)
        {
            // If drawing an alpha batch, we can optimize fillrate by scissor test
            if (!batch->isBase_ && batch->lightQueue_)
                renderer->OptimizeLightByScissor(batch->lightQueue_->light_, batch->camera_);
            else
                graphics->SetScissorTest(false);
        }
        
        batch->Draw(view);
    }
}
Пример #24
0
void GLBackend::do_setViewportTransform(Batch& batch, size_t paramOffset) {
    memcpy(&_transform._viewport, batch.editData(batch._params[paramOffset]._uint), sizeof(Vec4i));

    if (!_inRenderTransferPass && !isStereo()) {
        ivec4& vp = _transform._viewport;
        glViewport(vp.x, vp.y, vp.z, vp.w);
    }

    // The Viewport is tagged invalid because the CameraTransformUBO is not up to date and will need update on next drawcall
    _transform._invalidViewport = true;
}
Пример #25
0
void GLBackend::do_setStateScissorRect(Batch& batch, size_t paramOffset) {
    Vec4i rect;
    memcpy(&rect, batch.editData(batch._params[paramOffset]._uint), sizeof(Vec4i));

    if (_stereo._enable) {
        rect.z /= 2;
        if (_stereo._pass) {
            rect.x += rect.z;
        }
    }
    glScissor(rect.x, rect.y, rect.z, rect.w);
    (void)CHECK_GL_ERROR();
}
Пример #26
0
    void storeBatch (Batch const& batch)
    {
        EncodedBlob::Pool::ScopedItem item (m_blobPool);

        for (Batch::const_iterator iter (batch.begin());
            iter != batch.end(); ++iter)
        {
            EncodedBlob& encoded (item.getObject ());
            encoded.prepare (*iter);

            int rv (sp_set (m_db,
                encoded.getKey(), m_keyBytes,
                    encoded.getData(), encoded.getSize()));

            if (rv != 0)
            {
                String s;
                s << "Sophia failed with error code " << rv;
                Throw (std::runtime_error (s.toStdString()), __FILE__, __LINE__);
            }
        }
    }
Пример #27
0
void GLBackend::do_glUniform4iv(const Batch& batch, size_t paramOffset) {
    if (_pipeline._program == 0) {
        // We should call updatePipeline() to bind the program but we are not doing that
        // because these uniform setters are deprecated and we don;t want to create side effect
        return;
    }
    updatePipeline();
    glUniform4iv(
        GET_UNIFORM_LOCATION(batch._params[paramOffset + 2]._int),
        batch._params[paramOffset + 1]._uint,
        (const GLint*)batch.readData(batch._params[paramOffset + 0]._uint));

    (void)CHECK_GL_ERROR();
}
Пример #28
0
void Chunk::build()
{
	Batch batch;
	batch.start();
    for (uint8_t x = 0; x < 16 ; x++)
    {
		for (uint8_t y = 0; y < 16; y++)
		{
			for (uint8_t z = 0; z < 16; z++)
			{
				if (getBlockId(x, y, z) == 0) continue;
				if (getBlockId(x + 1, y, z) != 0 &&
					getBlockId(x, y + 1, z) != 0 &&
					getBlockId(x, y, z + 1) != 0 &&
					getBlockId(x - 1, y, z) != 0 &&
					getBlockId(x, y - 1, z) != 0 &&
					getBlockId(x, y, z - 1) != 0) continue;
				addCube(batch, x, y, z);
			}
		}
    }
	mesh_.generateMesh(batch);
}
Пример #29
0
bool ManejadorMetadatos::eliminarPermiso (string usernameOrigen, string filepath, string usernameDestino) {
    if (not validador->verificarPermisos(usernameOrigen, filepath))
        return false;
    if (not dbMetadatos->contains(filepath)) {
        Logger::logWarn("Se quiso eliminar un permiso del archivo " + filepath + " pero este no existe.");
        return false;
    }
    string pathPermisos = PERMISOS + "/" + usernameDestino;
    if (not dbMetadatos->contains(pathPermisos)) {
        Logger::logWarn("Se quiso eliminar un permiso del usuario " + usernameDestino + " pero este no existe.");
        return false;
    }

    string jsonModificado = metadatosConPermisosDepurados(filepath, usernameDestino);
    string archivosPermitidos = jsonArchivosPermitidos(pathPermisos, filepath);

    Batch batch;
    batch.modify(filepath, jsonModificado);
    batch.modify(pathPermisos, archivosPermitidos);
    dbMetadatos->writeBatch(batch);

    return true;
}
Пример #30
0
void GLBackend::do_glUniformMatrix4fv(Batch& batch, uint32 paramOffset) {
    if (_pipeline._program == 0) {
        // We should call updatePipeline() to bind the program but we are not doing that
        // because these uniform setters are deprecated and we don;t want to create side effect
        return;
    }
    updatePipeline();
    glUniformMatrix4fv(
        batch._params[paramOffset + 3]._int,
        batch._params[paramOffset + 2]._uint,
        batch._params[paramOffset + 1]._uint,
        (const GLfloat*)batch.editData(batch._params[paramOffset + 0]._uint));
    (void) CHECK_GL_ERROR();
}