optimize renderSamples

only render sample which has changed
This commit is contained in:
tildearrow 2023-09-08 01:19:48 -05:00
parent 6b6a8518ce
commit 624e45afa8
5 changed files with 45 additions and 43 deletions

View file

@ -396,13 +396,13 @@ int DivEngine::loadSampleROMs() {
return error;
}
void DivEngine::renderSamplesP() {
void DivEngine::renderSamplesP(int whichSample) {
BUSY_BEGIN;
renderSamples();
renderSamples(whichSample);
BUSY_END;
}
void DivEngine::renderSamples() {
void DivEngine::renderSamples(int whichSample) {
sPreview.sample=-1;
sPreview.pos=0;
sPreview.dir=false;
@ -418,8 +418,12 @@ void DivEngine::renderSamples() {
}
// step 1: render samples
for (int i=0; i<song.sampleLen; i++) {
song.sample[i]->render(formatMask);
if (whichSample==-1) {
for (int i=0; i<song.sampleLen; i++) {
song.sample[i]->render(formatMask);
}
} else if (whichSample>=0 && whichSample<song.sampleLen) {
song.sample[whichSample]->render(formatMask);
}
// step 2: render samples to dispatch

View file

@ -1064,10 +1064,14 @@ class DivEngine {
unsigned int getSampleFormatMask();
// UNSAFE render samples - only execute when locked
void renderSamples();
void renderSamples(int whichSample=-1);
// public render samples
void renderSamplesP();
// values for whichSample
// -2: don't render anything - just update chip sample memory
// -1: render all samples
// >=0: render specific sample
void renderSamplesP(int whichSample=-1);
// public swap channels
void swapChannelsP(int src, int dest);