optimize renderSamples
only render sample which has changed
This commit is contained in:
parent
6b6a8518ce
commit
624e45afa8
|
@ -396,13 +396,13 @@ int DivEngine::loadSampleROMs() {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::renderSamplesP() {
|
void DivEngine::renderSamplesP(int whichSample) {
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
renderSamples();
|
renderSamples(whichSample);
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::renderSamples() {
|
void DivEngine::renderSamples(int whichSample) {
|
||||||
sPreview.sample=-1;
|
sPreview.sample=-1;
|
||||||
sPreview.pos=0;
|
sPreview.pos=0;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
|
@ -418,9 +418,13 @@ void DivEngine::renderSamples() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 1: render samples
|
// step 1: render samples
|
||||||
|
if (whichSample==-1) {
|
||||||
for (int i=0; i<song.sampleLen; i++) {
|
for (int i=0; i<song.sampleLen; i++) {
|
||||||
song.sample[i]->render(formatMask);
|
song.sample[i]->render(formatMask);
|
||||||
}
|
}
|
||||||
|
} else if (whichSample>=0 && whichSample<song.sampleLen) {
|
||||||
|
song.sample[whichSample]->render(formatMask);
|
||||||
|
}
|
||||||
|
|
||||||
// step 2: render samples to dispatch
|
// step 2: render samples to dispatch
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
|
|
|
@ -1064,10 +1064,14 @@ class DivEngine {
|
||||||
unsigned int getSampleFormatMask();
|
unsigned int getSampleFormatMask();
|
||||||
|
|
||||||
// UNSAFE render samples - only execute when locked
|
// UNSAFE render samples - only execute when locked
|
||||||
void renderSamples();
|
void renderSamples(int whichSample=-1);
|
||||||
|
|
||||||
// public render samples
|
// 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
|
// public swap channels
|
||||||
void swapChannelsP(int src, int dest);
|
void swapChannelsP(int src, int dest);
|
||||||
|
|
|
@ -919,7 +919,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
sample->strip(start,end);
|
sample->strip(start,end);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
sampleSelStart=-1;
|
sampleSelStart=-1;
|
||||||
sampleSelEnd=-1;
|
sampleSelEnd=-1;
|
||||||
|
@ -965,7 +965,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
memcpy(&(sample->data16[pos]),sampleClipboard,sizeof(short)*sampleClipboardLen);
|
memcpy(&(sample->data16[pos]),sampleClipboard,sizeof(short)*sampleClipboardLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
sampleSelStart=pos;
|
sampleSelStart=pos;
|
||||||
sampleSelEnd=pos+sampleClipboardLen;
|
sampleSelEnd=pos+sampleClipboardLen;
|
||||||
|
@ -995,7 +995,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
sample->data16[pos+i]=sampleClipboard[i];
|
sample->data16[pos+i]=sampleClipboard[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
sampleSelStart=pos;
|
sampleSelStart=pos;
|
||||||
sampleSelEnd=pos+sampleClipboardLen;
|
sampleSelEnd=pos+sampleClipboardLen;
|
||||||
|
@ -1032,7 +1032,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
sample->data16[pos+i]=val;
|
sample->data16[pos+i]=val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
sampleSelStart=pos;
|
sampleSelStart=pos;
|
||||||
sampleSelEnd=pos+sampleClipboardLen;
|
sampleSelEnd=pos+sampleClipboardLen;
|
||||||
|
@ -1104,7 +1104,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
@ -1135,7 +1135,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
@ -1166,7 +1166,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
@ -1195,7 +1195,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
@ -1211,7 +1211,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
sample->strip(start,end);
|
sample->strip(start,end);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
sampleSelStart=-1;
|
sampleSelStart=-1;
|
||||||
sampleSelEnd=-1;
|
sampleSelEnd=-1;
|
||||||
|
@ -1229,7 +1229,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
sample->trim(start,end);
|
sample->trim(start,end);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
sampleSelStart=-1;
|
sampleSelStart=-1;
|
||||||
sampleSelEnd=-1;
|
sampleSelEnd=-1;
|
||||||
|
@ -1264,7 +1264,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
@ -1291,7 +1291,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
@ -1316,7 +1316,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
@ -1441,7 +1441,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
sample->loop=true;
|
sample->loop=true;
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3254,7 +3254,7 @@ void FurnaceGUI::pointUp(int x, int y, int button) {
|
||||||
if (sampleDragActive) {
|
if (sampleDragActive) {
|
||||||
logD("stopping sample drag");
|
logD("stopping sample drag");
|
||||||
if (sampleDragMode) {
|
if (sampleDragMode) {
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
} else {
|
} else {
|
||||||
if (sampleSelStart>sampleSelEnd) {
|
if (sampleSelStart>sampleSelEnd) {
|
||||||
sampleSelStart^=sampleSelEnd;
|
sampleSelStart^=sampleSelEnd;
|
||||||
|
|
|
@ -432,7 +432,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
}
|
}
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
popWarningColor();
|
popWarningColor();
|
||||||
|
@ -462,7 +462,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
sample->prepareUndo(true);
|
sample->prepareUndo(true);
|
||||||
e->lockEngine([this,sample,i]() {
|
e->lockEngine([this,sample,i]() {
|
||||||
sample->convert((DivSampleDepth)i);
|
sample->convert((DivSampleDepth)i);
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
|
@ -483,7 +483,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
if (ImGui::Checkbox("BRR emphasis",&be)) {
|
if (ImGui::Checkbox("BRR emphasis",&be)) {
|
||||||
sample->prepareUndo(true);
|
sample->prepareUndo(true);
|
||||||
sample->brrEmphasis=be;
|
sample->brrEmphasis=be;
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
if (ImGui::Checkbox("8-bit dither",&di)) {
|
if (ImGui::Checkbox("8-bit dither",&di)) {
|
||||||
sample->prepareUndo(true);
|
sample->prepareUndo(true);
|
||||||
sample->dither=di;
|
sample->dither=di;
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
}
|
}
|
||||||
|
@ -631,7 +631,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
if (ImGui::Selectable(sampleLoopModes[i])) {
|
if (ImGui::Selectable(sampleLoopModes[i])) {
|
||||||
sample->prepareUndo(true);
|
sample->prepareUndo(true);
|
||||||
sample->loopMode=(DivSampleLoopMode)i;
|
sample->loopMode=(DivSampleLoopMode)i;
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
}
|
}
|
||||||
|
@ -657,7 +657,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
}
|
}
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemActive()) {
|
if (ImGui::IsItemActive()) {
|
||||||
|
@ -683,7 +683,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
}
|
}
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemActive()) {
|
if (ImGui::IsItemActive()) {
|
||||||
|
@ -752,7 +752,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
ImGui::PushStyleColor(ImGuiCol_CheckMark,baseColor);
|
ImGui::PushStyleColor(ImGuiCol_CheckMark,baseColor);
|
||||||
|
|
||||||
if (ImGui::Checkbox(id,&sample->renderOn[i][j])) {
|
if (ImGui::Checkbox(id,&sample->renderOn[i][j])) {
|
||||||
e->renderSamplesP();
|
e->renderSamplesP(curSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopStyleColor(4);
|
ImGui::PopStyleColor(4);
|
||||||
|
@ -795,12 +795,6 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (ImGui::Button("Apply")) {
|
|
||||||
e->renderSamplesP();
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
*/
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
pushToggleColors(!sampleDragMode);
|
pushToggleColors(!sampleDragMode);
|
||||||
|
@ -846,7 +840,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
if (!sample->resize(resizeSize)) {
|
if (!sample->resize(resizeSize)) {
|
||||||
showError("couldn't resize! make sure your sample is 8 or 16-bit.");
|
showError("couldn't resize! make sure your sample is 8 or 16-bit.");
|
||||||
}
|
}
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
sampleSelStart=-1;
|
sampleSelStart=-1;
|
||||||
|
@ -901,7 +895,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
if (!sample->resample(targetRate,resampleTarget,resampleStrat)) {
|
if (!sample->resample(targetRate,resampleTarget,resampleStrat)) {
|
||||||
showError("couldn't resample! make sure your sample is 8 or 16-bit.");
|
showError("couldn't resample! make sure your sample is 8 or 16-bit.");
|
||||||
}
|
}
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
sampleSelStart=-1;
|
sampleSelStart=-1;
|
||||||
|
@ -972,7 +966,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
@ -1021,7 +1015,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
if (!sample->insert(pos,silenceSize)) {
|
if (!sample->insert(pos,silenceSize)) {
|
||||||
showError("couldn't insert! make sure your sample is 8 or 16-bit.");
|
showError("couldn't insert! make sure your sample is 8 or 16-bit.");
|
||||||
}
|
}
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
sampleSelStart=pos;
|
sampleSelStart=pos;
|
||||||
|
@ -1182,7 +1176,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
|
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
|
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
});
|
});
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
@ -1869,7 +1863,7 @@ void FurnaceGUI::doUndoSample() {
|
||||||
DivSample* sample=e->song.sample[curSample];
|
DivSample* sample=e->song.sample[curSample];
|
||||||
e->lockEngine([this,sample]() {
|
e->lockEngine([this,sample]() {
|
||||||
if (sample->undo()==2) {
|
if (sample->undo()==2) {
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1881,7 +1875,7 @@ void FurnaceGUI::doRedoSample() {
|
||||||
DivSample* sample=e->song.sample[curSample];
|
DivSample* sample=e->song.sample[curSample];
|
||||||
e->lockEngine([this,sample]() {
|
e->lockEngine([this,sample]() {
|
||||||
if (sample->redo()==2) {
|
if (sample->redo()==2) {
|
||||||
e->renderSamples();
|
e->renderSamples(curSample);
|
||||||
updateSampleTex=true;
|
updateSampleTex=true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue