Ejemplo n.º 1
0
void CLockBox9::on_add_node_child(StateDataNode* parent, StateDataNode* child) {
    if(child->get_id().name == NAME_LOCKBOX) {
        /** @todo Perhaps it's necessary to copy volume DATA to lock DATA, depending on the flags.
            Without this, if application only modifies a region of lock DATA
            the contents of the surface DATA corresponding to a non modified regions
            of lock DATA are overwritten with zeroes.
        */

        // Calculate size of DATA node and resize it
        D3DFORMAT format;
        child->get_parent()->get_child(StateId(NAME_FORMAT))->read_data(&format);
        UINT left, right, top, bottom, front, back;
        child->get_child(StateId(NAME_LEFT))->read_data(&left);
        child->get_child(StateId(NAME_RIGHT))->read_data(&right);
        child->get_child(StateId(NAME_TOP))->read_data(&top);
        child->get_child(StateId(NAME_BOTTOM))->read_data(&bottom);
        child->get_child(StateId(NAME_TOP))->read_data(&front);
        child->get_child(StateId(NAME_BOTTOM))->read_data(&back);
        UINT width = right - left;
        UINT height = bottom - top;
        UINT depth = back - front;
        // Change units for compressed formats
        /// @note Depth is not affected
        if(is_compressed(format)) {
            width = width / 4 + (((width % 4) == 0) ? 0 : 1);
            height = height / 4 + (((height % 4) == 0) ? 0 : 1);
        }
        UINT size = depth * width * height * texel_size(format);
        child->get_child(StateId(NAME_DATA))->set_data_size(size);
        D3D_DEBUG( cout << "CLOCKBOX9: Resizing SLOCKBOX DATA to " << (int)size << endl; )
Ejemplo n.º 2
0
void CAlphaBlending9::on_added_controller(StateDataNode* node) {
    if(node->get_id().name == NAME_DEVICE_9) {
        // Watch Alpha Blend state
        node->get_child(StateId(NAME_ALPHA_BLEND_ENABLED))->add_controller(this);
        node->get_child(StateId(NAME_SEPARATE_ALPHA_BLEND_ENABLED))->add_controller(this);
        node->get_child(StateId(NAME_BLEND_FACTOR))->add_controller(this);
        node->get_child(StateId(NAME_SRC_BLEND))->add_controller(this);
        node->get_child(StateId(NAME_DST_BLEND))->add_controller(this);
        node->get_child(StateId(NAME_SRC_BLEND_ALPHA))->add_controller(this);
        node->get_child(StateId(NAME_DST_BLEND_ALPHA))->add_controller(this);
        node->get_child(StateId(NAME_BLEND_OP))->add_controller(this);
        node->get_child(StateId(NAME_BLEND_OP_ALPHA))->add_controller(this);
    }
}
void CIndexVertexBuffers9::on_added_controller(StateDataNode* node) {
    if((node->get_id().name == NAME_INDEXBUFFER_9) ||
       (node->get_id().name == NAME_VERTEXBUFFER_9)) {

        UINT lenght;
        node->get_child(StateId(NAME_LENGTH))->read_data(&lenght);
        // Reserve storage in state
        node->get_child(StateId(NAME_DATA))->set_data_size(lenght);
        // Obtain GPU memory
        u32bit md;
        md = GPUProxy::get_instance()->obtainMemory(size_t(lenght));

        /* GPU memory is assigned to resource, so add the assignation
           to the assignation table */
        ResourceAssignationTable* a_resource_memory;
        a_resource_memory = AssignationsRegistry::get_table(NAME_IVBUFFER_MEMORY);
        a_resource_memory->add_resource(ResourceId(NAME_MEMORY, ResourceIndex(md)));
        a_resource_memory->assign( UsageId(NAME_IVBUFFER, node->get_id().index),
            ResourceId(NAME_MEMORY, ResourceIndex(md)));
        D3D_DEBUG( cout << "CINDEXVERTEXBUFFERS9: Memory descriptor is " << md << " size is " << lenght << endl; )
    }
Ejemplo n.º 4
0
IVolumeImp9::IVolumeImp9(StateDataNode* s_parent, IDeviceImp9* _i_parent, UINT Width, UINT Height, UINT Depth,
    DWORD Usage , D3DFORMAT Format, D3DPOOL Pool) {
    i_parent = _i_parent;
    // Create state
    state = D3DState::create_volume_state_9(this);
    // Fill state with parameters
    D3DRESOURCETYPE type = D3DRTYPE_VOLUME;
    state->get_child(StateId(NAME_TYPE))->write_data(&type);
    state->get_child(StateId(NAME_WIDTH))->write_data(&Width);
    state->get_child(StateId(NAME_HEIGHT))->write_data(&Height);
    state->get_child(StateId(NAME_DEPTH))->write_data(&Depth);
    state->get_child(StateId(NAME_FORMAT))->write_data(&Format);
    state->get_child(StateId(NAME_USAGE))->write_data(&Usage);
    state->get_child(StateId(NAME_POOL))->write_data(&Pool);

    // Add state
    s_parent->add_child(state);
}
// ---------------------------------------------------------------------------
// CMMCScBkupStateArchiveOpJavaData::CMMCScBkupStateArchiveOpJavaData()
// 
// C++ constructor.
// ---------------------------------------------------------------------------
CMMCScBkupStateArchiveOpJavaData::CMMCScBkupStateArchiveOpJavaData( MMMCScBkupDriver& aDriver )
:   CMMCScBkupStateOpAware( aDriver ), iIndexValueCurrent( -1 )
    {
    __LOG1("CMMCScBkupStateArchiveOpJavaData::CMMCScBkupStateArchiveOpJavaData() - 0x%08x", StateId().iUid );
    }
// ---------------------------------------------------------------------------
// CMMCScBkupStateValidateDiskSpace::CMMCScBkupStateValidateDiskSpace()
// 
// C++ constructor.
// ---------------------------------------------------------------------------
CMMCScBkupStateValidateDiskSpace::CMMCScBkupStateValidateDiskSpace( MMMCScBkupDriver& aDriver )
:   CMMCScBkupState( aDriver ), iCumulatedSize(0)
    {
    __LOG1("CMMCScBkupStateValidateDiskSpace::CMMCScBkupStateValidateDiskSpace() - 0x%08x", StateId().iUid );
    }
// ---------------------------------------------------------------------------
// CMMCScBkupStateNotifyAllSnapshotsSupplied::CMMCScBkupStateNotifyAllSnapshotsSupplied()
// 
// C++ constructor.
// ---------------------------------------------------------------------------
CMMCScBkupStateNotifyAllSnapshotsSupplied::CMMCScBkupStateNotifyAllSnapshotsSupplied( MMMCScBkupDriver& aDriver )
:   CMMCScBkupState( aDriver )
    {
    __LOG1("CMMCScBkupStateNotifyAllSnapshotsSupplied::CMMCScBkupStateNotifyAllSnapshotsSupplied() - 0x%08x", StateId().iUid );
    }
// ---------------------------------------------------------------------------
// CMMCScBkupStateRequestListOfPublicFiles::CMMCScBkupStateRequestListOfPublicFiles()
// 
// C++ constructor.
// ---------------------------------------------------------------------------
CMMCScBkupStateRequestListOfPublicFiles::CMMCScBkupStateRequestListOfPublicFiles( MMMCScBkupDriver& aDriver )
:   CMMCScBkupState( aDriver )
    {
    __LOG1("CMMCScBkupStateRequestListOfPublicFiles::CMMCScBkupStateRequestListOfPublicFiles() - 0x%08x", StateId().iUid );
    }
// ---------------------------------------------------------------------------
// CMMCScBkupState::RunError()
// 
// 
// ---------------------------------------------------------------------------
TInt CMMCScBkupState::RunError(TInt aError)
    {
#ifdef MMCSCBKUP_USE_BREAKPOINTS
    __BREAKPOINT();
#endif
    //
    if  ( aError == KErrNoMemory || aError == KErrDiskFull || aError == KErrNotReady || aError == KErrServerTerminated || aError == KErrWrite )
        {
        __LOGFILE2("CMMCScBkupState::RunError() - **** - FATAL ERROR - state: 0x%08x, aError: %d - Notifying Observer (Engine)", StateId().iUid, aError );
        CompleteObserver( aError );
        }
    else
        {
        __LOGFILE2("CMMCScBkupState::RunError() - **** - ATTEMPT TO HANDLE ERROR - state: 0x%08x, aError: %d...", StateId().iUid, aError );

        const TBool errorHandled = PerformAsynchronousErrorCleanup( aError );

        __LOGFILE1("CMMCScBkupState::RunError() - **** - handle error result: %d", errorHandled );

        // If the cleanup callback didn't set us active again, then
        // assume the object didn't perform any recovery. Therefore 
        // inform our observer about the error and give up.
        if  (!errorHandled || !IsActive())
            {
            CompleteObserver( aError );
            }
        }
    //
    return KErrNone;
    }
// ---------------------------------------------------------------------------
// CMMCScBkupState::DoCancel()
// 
// 
// ---------------------------------------------------------------------------
void CMMCScBkupState::DoCancel()
    {
    __LOG3("CMMCScBkupState::DoCancel() - START - state: 0x%08x, IsActive: %d, status: %d", StateId().iUid, IsActive(), iStatus.Int() );
    PerformAsynchronousCancellation();
    CompleteObserver( KErrCancel );
    __LOG3("CMMCScBkupState::DoCancel() - END - state: 0x%08x, IsActive: %d, status: %d", StateId().iUid, IsActive(), iStatus.Int() );
    }
// ---------------------------------------------------------------------------
// CMMCScBkupState::PerformAsynchronousErrorCleanup()
// 
// 
// ---------------------------------------------------------------------------
TBool CMMCScBkupState::PerformAsynchronousErrorCleanup( TInt aError )
    {
    (void) aError;
    __LOGFILE2("CMMCScBkupState::PerformAsynchronousErrorCleanup() - error: %d, state id: 0x%08x", aError, StateId().iUid );
    return EFalse;
    }
// ---------------------------------------------------------------------------
// CMMCScBkupState::PerformAsynchronousCancellation()
// 
// 
// ---------------------------------------------------------------------------
void CMMCScBkupState::PerformAsynchronousCancellation()
    {
    // Derived classes are expected to implement this if they have
    // resources to free. For calls to CompleteSelf(), no action is needed.
    __LOG3("CMMCScBkupState::PerformAsynchronousCancellation() - ERROR - cancellation not implemented for state: 0x%08x, IsActive: %d, status: %d", StateId().iUid, IsActive(), iStatus.Int() );
    }
// ---------------------------------------------------------------------------
// CMMCScBkupStateRequestSizeOfBackupData::CMMCScBkupStateRequestSizeOfBackupData()
// 
// C++ constructor.
// ---------------------------------------------------------------------------
CMMCScBkupStateRequestSizeOfBackupData::CMMCScBkupStateRequestSizeOfBackupData( MMMCScBkupDriver& aDriver )
:   CMMCScBkupState( aDriver )
    {
    __LOG1("CMMCScBkupStateRequestSizeOfBackupData::CMMCScBkupStateRequestSizeOfBackupData() - 0x%08x", StateId().iUid );
    }
Ejemplo n.º 14
0
void CAlphaBlending9::on_write_node_data(StateDataNode* node, size_t size, unsigned int offset) {
    if(node->get_id().name == NAME_ALPHA_BLEND_ENABLED) {
        DWORD value;
        node->read_data(&value);
        GPURegData data;
        data.booleanVal = (value == TRUE);
        GPUProxy::get_instance()->writeGPURegister(GPU_COLOR_BLEND, data);
    }
    else if(node->get_id().name == NAME_SEPARATE_ALPHA_BLEND_ENABLED) {
        DWORD value;
        node->read_data(&value);
        if(value == FALSE) {
            // Propagate color functions  to alpha functions
            DWORD color;
            node->get_parent()->get_child(StateId(NAME_SRC_BLEND))->read_data(&color);
            update_blend_functions(D3DRS_SRCBLENDALPHA, color, false);
            node->get_parent()->get_child(StateId(NAME_DST_BLEND))->read_data(&color);
            update_blend_functions(D3DRS_DESTBLENDALPHA, color, false);
        }
    }
    else if(node->get_id().name == NAME_BLEND_OP) {
        DWORD value;
        node->read_data(&value);
        DWORD separate;
        node->get_parent()->get_child(StateId(NAME_SEPARATE_ALPHA_BLEND_ENABLED))->read_data(&separate);
        bool sep = (separate == 0 ? false : true);
        update_blend_op(D3DRS_BLENDOP, value, sep);
    }
    else if(node->get_id().name == NAME_BLEND_OP_ALPHA) {
        DWORD value;
        node->read_data(&value);
        DWORD separate;
        node->get_parent()->get_child(StateId(NAME_SEPARATE_ALPHA_BLEND_ENABLED))->read_data(&separate);
        bool sep = (separate == 0 ? false : true);
        update_blend_op(D3DRS_BLENDOPALPHA, value, sep);
    }
    else if(node->get_id().name == NAME_SRC_BLEND) {
        DWORD value;
        node->read_data(&value);
        DWORD separate;
        node->get_parent()->get_child(StateId(NAME_SEPARATE_ALPHA_BLEND_ENABLED))->read_data(&separate);
        bool sep = (separate == 0 ? false : true);
        update_blend_functions(D3DRS_SRCBLEND, value, sep);
    }
    else if(node->get_id().name == NAME_SRC_BLEND_ALPHA) {
        DWORD value;
        node->read_data(&value);
        DWORD separate;
        node->get_parent()->get_child(StateId(NAME_SEPARATE_ALPHA_BLEND_ENABLED))->read_data(&separate);
        bool sep = (separate == 0 ? false : true);
        update_blend_functions(D3DRS_SRCBLENDALPHA, value, sep);
    }
    else if(node->get_id().name == NAME_DST_BLEND) {
        DWORD value;
        node->read_data(&value);
        DWORD separate;
        node->get_parent()->get_child(StateId(NAME_SEPARATE_ALPHA_BLEND_ENABLED))->read_data(&separate);
        bool sep = (separate == 0 ? false : true);
        update_blend_functions(D3DRS_DESTBLEND, value, sep);
    }
    else if(node->get_id().name == NAME_DST_BLEND_ALPHA) {
        DWORD value;
        node->read_data(&value);
        DWORD separate;
        node->get_parent()->get_child(StateId(NAME_SEPARATE_ALPHA_BLEND_ENABLED))->read_data(&separate);
        bool sep = (separate == 0 ? false : true);
        update_blend_functions(D3DRS_DESTBLENDALPHA, value, sep);
    }
    else if(node->get_id().name == NAME_BLEND_FACTOR) {
        DWORD value;
        node->read_data(&value);
        QuadFloat qf_value;
        d3dcolor2quadfloat(value, &qf_value);
        GPURegData data;
        for(u32bit i = 0; i < 4; i++)
            data.qfVal[i] = qf_value[i];
        GPUProxy::get_instance()->writeGPURegister(GPU_BLEND_COLOR, data);
    }
}