void Render3D::SetTextureProcessingProperties(size_t scalingFactor, bool willDeposterize, bool willSmooth) { const bool isScaleValid = ( (scalingFactor == 2) || (scalingFactor == 4) ); const size_t newScalingFactor = (isScaleValid) ? scalingFactor : 1; bool needTexCacheReset = false; if ( willDeposterize && (this->_textureDeposterizeBuffer == NULL) ) { // 1024x1024 texels is the largest possible texture size. // We need two buffers, one for each deposterize stage. const size_t bufferSize = 1024 * 1024 * 2 * sizeof(u32); this->_textureDeposterizeBuffer = (u32 *)malloc_alignedCacheLine(bufferSize); memset(this->_textureDeposterizeBuffer, 0, bufferSize); needTexCacheReset = true; } else if ( !willDeposterize && (this->_textureDeposterizeBuffer != NULL) ) { free_aligned(this->_textureDeposterizeBuffer); this->_textureDeposterizeBuffer = NULL; needTexCacheReset = true; } if (newScalingFactor != this->_textureScalingFactor) { u32 *oldTextureBuffer = this->_textureUpscaleBuffer; u32 *newTextureBuffer = (u32 *)malloc_alignedCacheLine( (1024 * newScalingFactor) * (1024 * newScalingFactor) * sizeof(u32) ); this->_textureScalingFactor = newScalingFactor; this->_textureUpscaleBuffer = newTextureBuffer; free_aligned(oldTextureBuffer); needTexCacheReset = true; } if (willSmooth != this->_textureSmooth) { this->_textureSmooth = willSmooth; needTexCacheReset = true; } if (needTexCacheReset) { TexCache_Reset(); } }
void* Render3D::operator new(size_t size) { void *newPtr = malloc_alignedCacheLine(size); if (newPtr == NULL) { #if defined(__vita__) //sceKernelExitProcess(0); #else throw std::bad_alloc(); #endif } return newPtr; }
FragmentAttributesBuffer::FragmentAttributesBuffer(size_t newCount) { count = newCount; depth = (u32 *)malloc_alignedCacheLine(count * sizeof(u32)); opaquePolyID = (u8 *)malloc_alignedCacheLine(count * sizeof(u8)); translucentPolyID = (u8 *)malloc_alignedCacheLine(count * sizeof(u8)); stencil = (u8 *)malloc_alignedCacheLine(count * sizeof(u8)); isFogged = (u8 *)malloc_alignedCacheLine(count * sizeof(u8)); isTranslucentPoly = (u8 *)malloc_alignedCacheLine(count * sizeof(u8)); }
Render3DError Render3D::SetFramebufferSize(size_t w, size_t h) { if (w < GPU_FRAMEBUFFER_NATIVE_WIDTH || h < GPU_FRAMEBUFFER_NATIVE_HEIGHT) { return RENDER3DERROR_NOERR; } const size_t newFramebufferColorSizeBytes = w * h * sizeof(FragmentColor); FragmentColor *oldFramebufferColor = this->_framebufferColor; FragmentColor *newFramebufferColor = (FragmentColor *)malloc_alignedCacheLine(newFramebufferColorSizeBytes); this->_framebufferWidth = w; this->_framebufferHeight = h; this->_framebufferColorSizeBytes = newFramebufferColorSizeBytes; this->_framebufferColor = newFramebufferColor; free_aligned(oldFramebufferColor); return RENDER3DERROR_NOERR; }
static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const WAVEFORMATEX* pwfex) { int error = 1; int result = 0; do { // close existing first DRV_AviEnd(); if(!truncate_existing(filename)) break; if(!pbmih) break; // create the object avi_create(&avi_file); // open the file if(FAILED(AVIFileOpen(&avi_file->avi_file, filename, OF_CREATE | OF_WRITE, NULL))) break; // create the video stream set_video_format(pbmih, avi_file); memset(&avi_file->avi_video_header, 0, sizeof(AVISTREAMINFO)); avi_file->prescaleLevel = video.prescaleHD; avi_file->convert_buffer = (u8*)malloc_alignedCacheLine(video.prescaleHD*video.prescaleHD*256*384*3); avi_file->avi_video_header.fccType = streamtypeVIDEO; avi_file->avi_video_header.dwScale = 6*355*263; avi_file->avi_video_header.dwRate = 33513982; avi_file->avi_video_header.dwSuggestedBufferSize = avi_file->bitmap_format.biSizeImage; if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[VIDEO_STREAM], &avi_file->avi_video_header))) break; if(use_prev_options) { avi_file->compress_options[VIDEO_STREAM] = saved_avi_info.compress_options[VIDEO_STREAM]; avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0]; } else { // get compression options memset(&avi_file->compress_options[VIDEO_STREAM], 0, sizeof(AVICOMPRESSOPTIONS)); avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0]; //retryAviSaveOptions: //mbg merge 7/17/06 removed error = 0; if(!AVISaveOptions(MainWindow->getHWnd(), 0, 1, &avi_file->streams[VIDEO_STREAM], &avi_file->compress_options_ptr[VIDEO_STREAM])) break; error = 1; } // create compressed stream if(FAILED(AVIMakeCompressedStream(&avi_file->compressed_streams[VIDEO_STREAM], avi_file->streams[VIDEO_STREAM], &avi_file->compress_options[VIDEO_STREAM], NULL))) break; // set the stream format if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[VIDEO_STREAM], 0, (void*)&avi_file->bitmap_format, avi_file->bitmap_format.biSize))) break; // add sound (if requested) if(pwfex) { // add audio format set_sound_format(pwfex, avi_file); // create the audio stream memset(&avi_file->avi_sound_header, 0, sizeof(AVISTREAMINFO)); avi_file->avi_sound_header.fccType = streamtypeAUDIO; avi_file->avi_sound_header.dwQuality = (DWORD)-1; avi_file->avi_sound_header.dwScale = avi_file->wave_format.nBlockAlign; avi_file->avi_sound_header.dwRate = avi_file->wave_format.nAvgBytesPerSec; avi_file->avi_sound_header.dwSampleSize = avi_file->wave_format.nBlockAlign; avi_file->avi_sound_header.dwInitialFrames = 1; if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[AUDIO_STREAM], &avi_file->avi_sound_header))) break; // AVISaveOptions doesn't seem to work for audio streams // so here we just copy the pointer for the compressed stream avi_file->compressed_streams[AUDIO_STREAM] = avi_file->streams[AUDIO_STREAM]; // set the stream format if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[AUDIO_STREAM], 0, (void*)&avi_file->wave_format, sizeof(WAVEFORMATEX)))) break; } // initialize counters avi_file->video_frames = 0; avi_file->sound_samples = 0; avi_file->tBytes = 0; avi_file->ByteBuffer = 0; avi_file->audio_buffer_pos = 0; // success error = 0; result = 1; avi_file->valid = 1; } while(0); if(!result) { avi_destroy(&avi_file); if(error) EMU_PrintError("Error writing AVI file"); } return result; }